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

Home » Public Forums » archive » Re: closed surface
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: closed surface [message #32183] Fri, 20 September 2002 16:04 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
I've looked into this a little farther. If you choose the SPHERE option
of TRIANGULATE, then the CONNECTIVITY option is ignored. The
connectivity information is, instead, stored in the myS.iadj array. In
any event, you don't really want the connectivity list, you want the
triangles list.

There's another problem. The triangles list from TRIANGULATE is a long
array of index triplets, each of which represents one triangle. However,
the POLYGONS argument of idlgrPolygon::init() requires an argument which
can contain multiple polygons, each with an arbitrary and different
number of sides. Therefore, it needs some way of knowing the how many
sides each one has. It does this by expecting the first element of each
polygon to be a number telling how many sides that polygon has.
Therefore, to create a polygon list suitable for idlgrPolygon::init()
from the triangles list generated by TRIANGULATE, you'll have to insert
a 3 just before each triangle.

If you're just trying to make a sphere, you can ignore the CV_COORD
stuff, and just use myS.XYZ for your vertex list.

One additional point: your points are not evenly distributed over the
surface of the sphere. They have a density proportional to
1.0/cos(latitude). To get a more evenly distributed set of points, use:

latitude = asin(2.0*RANDOMU(200)-1.0)*!RADEG

So, here's my revised version of your code:

longitude = RANDOMU(seed, 200) * 360. - 180.
latitude = ASIN(2.0*RANDOMU(seed, 200)-1.0)*!RADEG
radius = REPLICATE(300.0,200)

TRIANGULATE, longitude, latitude, triangles, $
FVALUE=radius,/DEGREES, SPHERE=myS

; I'll bet that IDL experts have a better way of doing this, but
; this works
ntri = SIZE(triangles,/DIMENSIONS)
ntri = ntri[1]
connect = LONARR(4,ntri)
connect[0,*] = 3
connect[1:3,*] = triangles

oSurf = OBJ_NEW('IDLgrPolygon', TRANSPOSE(myS.XYZ), POLYGON=connect, $
STYLE=2, SHADING=1, COLOR=[0,20,255])
oGroup = OBJ_NEW('IDLgrModel')
oGroup->ADD, oSurf
XOBJVIEW,oGroup

It still looks lumpy, but it's a lot better than before.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Announcing RSI User-Contributed Library
Next Topic: Re: IDL Student Edition released

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

Current Time: Wed Oct 08 18:29:16 PDT 2025

Total time taken to generate the page: 0.00478 seconds