comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Create curves
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Create curves [message #92124] Fri, 16 October 2015 06:41 Go to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Hi

I created an ellipsoid shape as follows

NX=128
NY=128
Ellipxe = fltarr(NX,NY)

for i=0L, NX-1 do begin
for j=0L, NY-1 do begin
if (0.1*(j-50)^2.+0.23*(i-95)^2. LT 100) then begin
Ellipse[i,j] = 10.
endif
endfor
endfor
tvscl, Ellipse


I wanted to change the direction of the ellipse to be diagonal (i.e. not plotted vertically). Does anyone knows how to do that?


Also I found that the bean curve in Cartesian coordinates has the following form:

(x^2+y^2)^2 = x^3+y^3

I tried the following but it doesn't work

NX=128
NY=128
Bean_curve = fltarr(NX,NY)

for i=0L, NX-1 do begin
for j=0L, NY-1 do begin
if ((0.1*(j)^2.+0.23*(i)^2.)^2. EQ (0.1*(j)^3.+0.23*(i)^3.)) then begin
Bean_Curve[i,j] = 10.
endif
endfor
endfor

tvscl, bean_Curve

Can anyone help with this?
Re: Create curves [message #92127 is a reply to message #92124] Fri, 16 October 2015 06:56 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
g.nacarts@gmail.com writes:

> I created an ellipsoid shape as follows
>
> NX=128
> NY=128
> Ellipxe = fltarr(NX,NY)
>
> for i=0L, NX-1 do begin
> for j=0L, NY-1 do begin
> if (0.1*(j-50)^2.+0.23*(i-95)^2. LT 100) then begin
> Ellipse[i,j] = 10.
> endif
> endfor
> endfor
> tvscl, Ellipse
>
>
> I wanted to change the direction of the ellipse to be diagonal (i.e. not plotted vertically). Does anyone knows how to do that?

I think I would use TVEllipse from the NASA Astronomy Library with the
angle parameter set to 45 degrees.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Create curves [message #92128 is a reply to message #92127] Fri, 16 October 2015 07:13 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Other way beside the NASA Astronomy Library?

I don't want to use the TVEllipse because I want to create the ellipse as an array not just to display it.
Re: Create curves [message #92129 is a reply to message #92124] Fri, 16 October 2015 07:46 Go to previous messageGo to next message
Russell[1] is currently offline  Russell[1]
Messages: 101
Registered: August 2011
Senior Member
This is probably going to sound more complicated than it actually is. But all you need to do is the rotation matrix to rotate your coordinate system.

https://en.wikipedia.org/wiki/Rotation_matrix

so if the center of your ellipse is at (xc,yc) then the coordinates of the new ellipse will be

theta=45.
s=sin(theta*!PI/180)
c=cos(theta*!PI/180.)
dx=x-xc
dy=y-yc

x = xc + c*dx+s*dy
y = yc - s*dx+c*dy

and now you use the definition of an ellipse:

r^2 = (x/a)^2 + (y/b)^2

This is all tvellipse does. If you don't want to use tvellipse, then just open it up and you'll see pretty much the same equations there. I didn't test this cause I didn't understand exactly what you want, so you'll need to work it over a bit (but it's the correct idea). I think I used a negative angle (when wiki uses a positive one) and used the fact that sin is an odd function.





On Friday, October 16, 2015 at 9:41:08 AM UTC-4, g.na...@gmail.com wrote:
> Hi
>
> I created an ellipsoid shape as follows
>
> NX=128
> NY=128
> Ellipxe = fltarr(NX,NY)
>
> for i=0L, NX-1 do begin
> for j=0L, NY-1 do begin
> if (0.1*(j-50)^2.+0.23*(i-95)^2. LT 100) then begin
> Ellipse[i,j] = 10.
> endif
> endfor
> endfor
> tvscl, Ellipse
>
>
> I wanted to change the direction of the ellipse to be diagonal (i.e. not plotted vertically). Does anyone knows how to do that?
>
>
> Also I found that the bean curve in Cartesian coordinates has the following form:
>
> (x^2+y^2)^2 = x^3+y^3
>
> I tried the following but it doesn't work
>
> NX=128
> NY=128
> Bean_curve = fltarr(NX,NY)
>
> for i=0L, NX-1 do begin
> for j=0L, NY-1 do begin
> if ((0.1*(j)^2.+0.23*(i)^2.)^2. EQ (0.1*(j)^3.+0.23*(i)^3.)) then begin
> Bean_Curve[i,j] = 10.
> endif
> endfor
> endfor
>
> tvscl, bean_Curve
>
> Can anyone help with this?
Re: Create curves [message #92132 is a reply to message #92129] Fri, 16 October 2015 08:56 Go to previous message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Yes, I found the TVEllipse document and I had a look on that one.
The problem is that I want to make an array with this ellipse and they way I did it I only got a black window when I display it. My code is shown below

xc=90. ;center in x-direction
yc=50. ;center in y-direction

theta=45. ;angle to rotate
s=sin(theta*!pi/180.)
c=cos(theta*!pi/180.)
dx=xc
dy=yc

for x=0L, NX-1 do begin
for y=0L, NY-1 do begin
if ((xc + c*dx+s*dy )/2.)^2 + (( yc - s*dx+c*dy )/4.)^2 LT 100 then begin
Ellipse[x,y] = 10.
endif
endfor
endfor
tvscl, Ellipse
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Plotting symbols filled with pattern(s)
Next Topic: Read ENVI file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:40:37 PDT 2025

Total time taken to generate the page: 0.00674 seconds