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

Home » Public Forums » archive » Re: 3D Vector Field Plot?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: 3D Vector Field Plot? [message #20242 is a reply to message #20234] Tue, 30 May 2000 00:00 Go to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
John Boccio wrote:
>
> Hi,
>
> Is there any straightforward way to plot
> directed arrows representing a vector field
> in 3 dimensions?
>
> Anyone have a sample code for direct graphics?
> using IDLgrpolyline?
>
> Thanks,
>
> John Boccio
> boccio@swarthmore.edu

Here is a small sample function I extracted from one of my programs.
I simplified it and did not test it, but I think you can get the idea.
The 'trick' is that the top of the vectors consist of two more
IDLgrPolyline
objects which are thicker than the rest of the vector to fake an arrow.
Another thicker part is drawn at the actual position of the vector
(the middle of the vector line here).
With this you save the need to caculate the projection for the vector
top.
I think therefore this gives not the nicest vectors, but it should be
quite fast.
Just add the returned objarr to a IDLgrModel.
Hope this is helpful.
:-) marc

;; ---
;; vectorPosition, vectorDirection: [3,numVectors] float arrays
;; colorArray: [3,numVectors] byte array for color of each vector

function sample,vectorPosition,vectorDirection,colorArray

vectorObj=objarr(4)

line1=[[vectorPosition[*,*]-vectorDirection[*,*]],$
[vectorPosition[*,*]+vectorDirection[*,*]]]

linkList=intarr(3,numPlot)
linkList[0,*]=2
linkList[1,*]=indgen(numPlot)
linkList[2,*]=indgen(numPlot)+numPlot

;; if we do not do this, polyline thinks we are using colortable
if numVectors eq 1 then vertColors=[[vertColors],[vertColors]]

line2=[[vectorPosition[*,*]+vectorDirection[*,*]*0.7],[vecto rPosition[*,*]+vectorDirection[*,*]*.8]]
line3=[[vectorPosition[*,*]+vectorDirection[*,*]*0.8],[vecto rPosition[*,*]+vectorDirection[*,*]*.9]]
line4=[[vectorPosition[*,*]-vectorDirection[*,*]*0.05],[vect orPosition[*,*]+vectorDirection[*,*]*.05]]

vectorObj[0]=obj_new('IDLgrPolyline',$
line1,$
POLYLINES=linkList,$
VERT_COLORS=vertColors,$
THICK=arrowThickness,$
COLOR=colorArray)

vectorObj[1]=obj_new('IDLgrPolyline',$
line2,$
POLYLINES=linkList,$
VERT_COLORS=vertColors,$
THICK=arrowThickness*4,$
COLOR=colorArray)

vectorObj[2]=obj_new('IDLgrPolyline',$
line3,$
POLYLINES=linkList,$
VERT_COLORS=vertColors,$
THICK=arrowThickness*2,$
COLOR=colorArray)

vectorObj[3]=obj_new('IDLgrPolyline',$
line4,$
POLYLINES=linkList,$
VERT_COLORS=vertColors,$
THICK=arrowThickness*2,$
COLOR=colorArray)

return,vectorObj
end
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Create postscript (vector) file with any size using IDLgrClipboard.
Next Topic: Re: what does this error mean

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

Current Time: Wed Oct 08 18:10:26 PDT 2025

Total time taken to generate the page: 0.00562 seconds