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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: closed surface [message #32183] Fri, 20 September 2002 16:04
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.
Re: closed surface [message #32209 is a reply to message #32183] Thu, 19 September 2002 13:44 Go to previous message
Chunlei Liu is currently offline  Chunlei Liu
Messages: 4
Registered: August 2002
Junior Member
James,
Thank you very much for the infomation. Following your suggestions, I got
the triangulate work, however the sphere still does not look right.

Maybe my method does not work anyway. Does anybody has any suggetions
about constructing a closed surface from some points sampled on the
surface?

Chunlei

On Thu, 19 Sep 2002, James Kuyper wrote:

> Chunlei Liu wrote:
> ...
>> Triangulate, vertexlist[0, *], vertexlist[1, *], $
>> tri,CONNECTIVITY=connect,/degrees
>
> The online help says that the DEGREES keyword is only effective if the
> SPHERE keyword is also used.
>
> ...
>> --> Triangulate, vertexlist[0, *], vertexlist[1, *], $
>> tri,CONNECTIVITY=connect,/degrees,FVALUE=myF,SPHERE=myS
>> ^^^^^^^^^^
>
> I think that what you want for myF is a copy of vertexlist[2,*]. It's an
> input, as well as an output.
>
> The online help doesn't mention the fact that when you use the FVALUE
> keyword, TRIANGLULATE rearranges not only the FVALUE, but also the
> corresponding 'x' and 'y' arguments. Therefore, 'x', 'y', and 'myF' must
> be passed by reference; which means that they have to be the names of
> variables, not subcript expressions.
>
Re: closed surface [message #32211 is a reply to message #32209] Thu, 19 September 2002 11:21 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Chunlei Liu wrote:
...
> Triangulate, vertexlist[0, *], vertexlist[1, *], $
> tri,CONNECTIVITY=connect,/degrees

The online help says that the DEGREES keyword is only effective if the
SPHERE keyword is also used.

...
> --> Triangulate, vertexlist[0, *], vertexlist[1, *], $
> tri,CONNECTIVITY=connect,/degrees,FVALUE=myF,SPHERE=myS
> ^^^^^^^^^^

I think that what you want for myF is a copy of vertexlist[2,*]. It's an
input, as well as an output.

The online help doesn't mention the fact that when you use the FVALUE
keyword, TRIANGLULATE rearranges not only the FVALUE, but also the
corresponding 'x' and 'y' arguments. Therefore, 'x', 'y', and 'myF' must
be passed by reference; which means that they have to be the names of
variables, not subcript expressions.
  Switch to threaded view of this topic Create a new topic Submit Reply
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 15:27:55 PDT 2025

Total time taken to generate the page: 0.00698 seconds