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

Home » Public Forums » archive » plotting vectors in 3D
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
plotting vectors in 3D [message #22277] Fri, 03 November 2000 04:05 Go to next message
M Carmen Gonzalez is currently offline  M Carmen Gonzalez
Messages: 3
Registered: November 2000
Junior Member
Dear all,

I am new in IDL programming and I'm still a bit lost, so may be some of you
can help me...

I am trying to plot the measured wind speed (2 components) by a balloon in
vertical ascension. At each point of the trajectory i want to plot a vector
indicating the wind direction at that point.

Does someone know how could I do it?

Thanks a lot,

M� Carmen
Re: plotting vectors in 3D [message #22349 is a reply to message #22277] Mon, 06 November 2000 13:15 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"M Carmen Gonzalez" <mcgonzal@uv.es> wrote in message
news:8tu9l1$uhb$1@peque.uv.es...
>
> I am trying to plot the measured wind speed (2 components) by a balloon
in
> vertical ascension. At each point of the trajectory i want to plot a
vector
> indicating the wind direction at that point.

Well, I'm not suggesting this is better or worse than the other responses to
your post, but you might want to check out my MGHgrBarbPlot object. If so,
you'll need to go to

http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/

fetch MARKS_ROUTINES.zip, unpack it somewhere on your IDL path, then look at
the MGH_EXAMPLE_BARB routine for examples.

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
Re: plotting vectors in 3D [message #22353 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Carmen,

I would not fall for that David's

> You have at least an hour of IDL consulting sitting
> in your account here. :-)

Just ask him to implement all that he wrote before:

> First, I would do this in the object graphics
> system, because at the end of the day, you will
> want to rotate this plot to get the maximum
> amount of information out of it. It is unlikely
> to be saliently "visible" otherwise.
>
> I would probably create some kind of an "arrow"
> object for myself, which would be subclassed on
> a model object for ease of rotation and scaling.
> The arrow would probably consist of a cylindrical
> "shaft" and some kind of an arrow "head", both
> constructed from filled polygon objects that I could
> shade them with one or more light objects, to give the
> scene some depth.

I think that for David that'll be about that promised hour worth of
work, as he seems to have a pretty clear idea about it :-)

Cheers,
Pavel
RE: plotting vectors in 3D [message #22354 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
M Carmen Gonzalez (mcgonzal@uv.es) writes:

> First of all I'd like to thank everybody for the answers. I'm eager to start
> working....(by the way, I think this is going to be a cold long long
> winter...). I didn't get ofended, but from now on, I'd rather be addressed
> as Mrs, : )),

Whoops! I knew I had a 50% chance of getting that
wrong, but since 80% of the programmers I see in
Europe are men, I thought perhaps my first instincts
were wrong. My sincerest apologies, Mrs. Gonzalez.
You have at least an hour of IDL consulting sitting
in your account here. :-)

Best Regards,

David

P.S. Let's just say things must be changing in
Europe. I gave a lecture last week to 100+ first
year science students in Copenhagen and I would
say nearly 50% were women. This is always a good
sign, since they are sometimes the only ones who
laugh at my poorer jokes. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
RE: plotting vectors in 3D [message #22355 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
M Carmen Gonzalez is currently offline  M Carmen Gonzalez
Messages: 3
Registered: November 2000
Junior Member
Hello again,

First of all I'd like to thank everybody for the answers. I'm eager to start
working....(by the way, I think this is going to be a cold long long
winter...). I didn't get ofended, but from now on, I'd rather be addressed
as Mrs, : )),

Best regards,
Carmen

David Fanning <davidf@dfanning.com> escribi� en el mensaje de noticias
MPG.14708d2cf441a9a7989c6d@news.frii.com...
> Martin Schultz (martin.schultz@dkrz.de) writes:
>
>> Oh, come on, David, Haloween is over and you don't have to scare
>> people any longer ;-) As far as I can see, you can already get a
>> decent visualization of that data with a 2-D plot - either longitude
>> vs. latitude, neglecting the altitude, or e.g. altitude vs. time
>> neglecting lon and lat (or conveying this information in the form of
>> an additional x axis). Then, the problem is really as simple as using
>> the arrow procedure and figuring out how to position and scale the
>> arrows correctly.
>
> I don't think it's quite *that* easy, but I have
> to admit I'm impressed with the quality of the
> responses. I have hope now that this problem can
> be completely solved by Mr. Gonzalez in an elegant
> manner by the time of the winter solstice. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: plotting vectors in 3D [message #22360 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Martin Schultz (martin.schultz@dkrz.de) writes:

> Oh, come on, David, Haloween is over and you don't have to scare
> people any longer ;-) As far as I can see, you can already get a
> decent visualization of that data with a 2-D plot - either longitude
> vs. latitude, neglecting the altitude, or e.g. altitude vs. time
> neglecting lon and lat (or conveying this information in the form of
> an additional x axis). Then, the problem is really as simple as using
> the arrow procedure and figuring out how to position and scale the
> arrows correctly.

I don't think it's quite *that* easy, but I have
to admit I'm impressed with the quality of the
responses. I have hope now that this problem can
be completely solved by Mr. Gonzalez in an elegant
manner by the time of the winter solstice. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: plotting vectors in 3D [message #22361 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
John Boccio is currently offline  John Boccio
Messages: 12
Registered: December 1999
Junior Member
In article <8tu9l1$uhb$1@peque.uv.es>, M Carmen Gonzalez
<mcgonzal@uv.es> wrote:

> mcgonzal@uv.es

Hi,

Here is a very, very crude program that we use.
No fancy vector objects (just a polyline with
small sphere on end for each vector).

No complaints please from all the experts on the list!

It is an object-based program so that you can
use the mouse to find best view. Requires routine
xobjview in V5.3.

The example is a simple radial field emanating from
the corner of the box.

John Boccio
boccio@swarthmore.edu

------------------------------ cut here -----------------

function fx,x,y,z
xc=-0.2
yc=-0.2
zc=-0.2
r=sqrt((x-xc)^2+(y-yc)^2+(z-zc)^2)
return,(x-xc)/r^2
end

function fy,x,y,z
xc=-0.2
yc=-0.2
zc=-0.2
r=sqrt((x-xc)^2+(y-yc)^2+(z-zc)^2)
return,(y-yc)/r^2
end


function fz,x,y,z
xc=-0.2
yc=-0.2
zc=-0.2
r=sqrt((x-xc)^2+(y-yc)^2+(z-zc)^2)
return,(z-zc)/r^2
end

pro vectfield3d
;Create model to contain surface
omodel = OBJ_NEW('IDLgrModel')
;create vector field
n=6
range=1.0
fac=0.05
step=range/(n-1)
x=step*findgen(n)
y=x
z=x
vx=fltarr(n,n,n)
vy=vx
vz=vx
v=vx
x1=vx
y1=vx
z1=vx
m=n-1
for i=0,m do begin
for j=0,m do begin
for k=0,m do begin
vx(i,j,k)=fx(x(i),y(j),z(k))
vy(i,j,k)=fy(x(i),y(j),z(k))
vz(i,j,k)=fz(x(i),y(j),z(k))
endfor
endfor
endfor
for i=0,m do begin
for j=0,m do begin
for k=0,m do begin
x1(i,j,k)=x(i)+fac*vx(i,j,k)
y1(i,j,k)=y(j)+fac*vy(i,j,k)
z1(i,j,k)=z(k)+fac*vz(i,j,k)
endfor
endfor
endfor
; normalize field
mnx=min([min(x),min(x1)])
mxx=max([max(x),max(x1)])
mny=min([min(y),min(y1)])
mxy=max([max(y),max(y1)])
mnz=min([min(z),min(z1)])
mxz=max([max(z),max(z1)])
max1=max([mxx,mxy,mxz])
min1=min([mnx,mny,mnz])
x1=-1.0+2.0*(x1-min1)/(max1-min1)
y1=-1.0+2.0*(y1-min1)/(max1-min1)
z1=-1.0+2.0*(z1-min1)/(max1-min1)
x=-1.0+2.0*(x-min1)/(max1-min1)
y=-1.0+2.0*(y-min1)/(max1-min1)
z=-1.0+2.0*(z-min1)/(max1-min1)
; create field vectors
for i=0,m do begin
for j=0,m do begin
for k=0,m do begin
xs=[x1(i,j,k),x(i)]
ys=[y1(i,j,k),y(j)]
zs=[z1(i,j,k),z(k)]
opolyline = OBJ_NEW('IDLgrPolyline', xs,ys,zs, $
color=[255,0,0],thick=1,shading=0)
omodel -> ADD, opolyline
mesh_obj,4,verts,conn,Replicate(0.01 ,6,6)
T3d,/Reset
T3d, Translate=[x1(i,j,k),y1(i,j,k),z1(i,j,k)]
verts=Vert_T3d(verts)
oSphere=OBJ_NEW('IDLgrpolygon', verts,poly=conn,
COLOR=[255,0,0],style=0)
omodel -> ADD, oSphere
endfor
endfor
endfor
;create box
opolyline = OBJ_NEW('IDLgrPolyline',
[-1.0,1.0],[-1.0,-1.0],[-1.0,-1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline',
[-1.0,-1.0],[-1.0,-1.0],[-1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [-1.0,1.0],[-1.0,-1.0],[1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [1.0,1.0],[-1.0,-1.0],[-1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [1.0,1.0],[-1.0,1.0],[-1.0,-1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [1.0,1.0],[1.0,1.0],[-1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [-1.0,-1.0],[-1.0,1.0],[1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline',
[-1.0,-1.0],[-1.0,1.0],[-1.0,-1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [-1.0,-1.0],[1.0,1.0],[-1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [-1.0,1.0],[1.0,1.0],[1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [1.0,1.0],[-1.0,1.0],[1.0,1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline
opolyline = OBJ_NEW('IDLgrPolyline', [-1.0,1.0],[1.0,1.0],[-1.0,-1.0], $
color=[0,255,0],thick=1,shading=0)
omodel -> ADD, opolyline

;Create a fixed light
ofixedlight = OBJ_NEW('IDLgrLight', TYPE = 1, $
LOCATION = [-1,-1,1], COLOR = [128,128,128])
omodel -> ADD, ofixedlight
;Create another fixed light
ofixedlight1 = OBJ_NEW('IDLgrLight', TYPE = 1, $
LOCATION = [-1,1,1], COLOR = [128,128,128])
omodel -> ADD, ofixedlight1
;Create movable light that goes with surface
olight = OBJ_NEW('IDLgrLight', TYPE = 2, LOCATION = [-1,-1,-1])

omodel -> ADD, olight
xobjview,omodel
end
Re: plotting vectors in 3D [message #22363 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
M Carmen Gonzalez wrote:
>
> Dear all,
>
> I am new in IDL programming and I'm still a bit lost, so may be some of you
> can help me...
>
> I am trying to plot the measured wind speed (2 components) by a balloon in
> vertical ascension. At each point of the trajectory i want to plot a vector
> indicating the wind direction at that point.
>
> Does someone know how could I do it?
>
> Thanks a lot,
>
> M� Carmen

You might look at
http://www.astro.washington.edu/deutsch-bin/getpro/library09 .html?VECFLD
for inspiration. I always search for routines there first before
setting out into the darkest days of snow-blinded wandering through the
dense forest of IDL graphics. I also found
http://www.colorado.edu/ITS/docs/scientific/idl/idlvf.html, with a bonus
Runge-Kutta integrator built in. Oh my. Not very advanced though.

In any case, if you take David's advice and spend the better part of the
next year coding up a generic OG 3-D vector field plotter, look at
http://www.math.armstrong.edu/mmacalc/gallery/vecfld.gif for
motivation. I especially like the 3-D arrow tips.

JD

--
J.D. Smith | WORK: (607) 255-6263
Cornell Dept. of Astronomy | (607) 255-5842
304 Space Sciences Bldg. | FAX: (607) 255-5875
Ithaca, NY 14853 |
Re: plotting vectors in 3D [message #22364 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> M Carmen Gonzalez (mcgonzal@uv.es) writes:
>
>> am new in IDL programming and I'm still a bit lost, so may be some of you
>> can help me...
>>
>> I am trying to plot the measured wind speed (2 components) by a balloon in
>> vertical ascension. At each point of the trajectory i want to plot a vector
>> indicating the wind direction at that point.
>>
>> Does someone know how could I do it?
>
> Oh, oh. I think there are probably a number of us
> would know *how* to do this. The problem comes about
> in trying to convey that information to a novice
> IDL programmer in 10,000 words or less. :-)
>
Oh, come on, David, Haloween is over and you don't have to scare
people any longer ;-) As far as I can see, you can already get a
decent visualization of that data with a 2-D plot - either longitude
vs. latitude, neglecting the altitude, or e.g. altitude vs. time
neglecting lon and lat (or conveying this information in the form of
an additional x axis). Then, the problem is really as simple as using
the arrow procedure and figuring out how to position and scale the
arrows correctly.

Cheers,
Martin

PS: But if you really want to have everything in 3D and illuminated
from within, it might be easier to fly this balloon again, attach some
nice colored stripes to it and take pictures ;-)


--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: plotting vectors in 3D [message #22366 is a reply to message #22277] Mon, 06 November 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
M Carmen Gonzalez (mcgonzal@uv.es) writes:

> am new in IDL programming and I'm still a bit lost, so may be some of you
> can help me...
>
> I am trying to plot the measured wind speed (2 components) by a balloon in
> vertical ascension. At each point of the trajectory i want to plot a vector
> indicating the wind direction at that point.
>
> Does someone know how could I do it?

Oh, oh. I think there are probably a number of us
would know *how* to do this. The problem comes about
in trying to convey that information to a novice
IDL programmer in 10,000 words or less. :-)

But here is a general outline. I don't think
this is a particularly difficult problem for
an experienced IDL programmer. Perhaps a couple of
days work. But for an inexperienced programmer, it
could be an excellent way to pass the darks days
of winter. :-)

First, I would do this in the object graphics
system, because at the end of the day, you will
want to rotate this plot to get the maximum
amount of information out of it. It is unlikely
to be saliently "visible" otherwise.

I would probably create some kind of an "arrow"
object for myself, which would be subclassed on
a model object for ease of rotation and scaling.
The arrow would probably consist of a cylindrical
"shaft" and some kind of an arrow "head", both
constructed from filled polygon objects that I could
shade them with one or more light objects, to give the
scene some depth.

You could look at a program like FSC_SURFCE for
information on how to create and rotate a 3D
coordinate system in object graphics, but
placing the objects in the 3D environment (if you
get this far) will be trivial.

Hope this gives you some ideas. This is, unfortunately,
a fairly advanced "beginner" project. Good luck! :-)

Cheers,

David

P.S. Another approach, which I don't think is
as likely to give good results, but which might
be faster to implement, would be to do this in
direct graphics. Set up a 3D coordinate system
with something like SCALE3D, then modify the
ARROW procedure in the lib subdirectory to
work in 3D space. (If you can live with "flat"
arrows, then this may be no more complicated than
adding a Z value to the PLOTS command that draws
the arrows.)

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: HDF_Browser only works when SD data available ?
Next Topic: Re: java vs. IDL

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

Current Time: Wed Oct 08 13:53:09 PDT 2025

Total time taken to generate the page: 0.00732 seconds