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

Home » Public Forums » archive » 2D and 3D filled objects.
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
2D and 3D filled objects. [message #33373] Thu, 26 December 2002 12:34 Go to next message
biomedthesis2002 is currently offline  biomedthesis2002
Messages: 12
Registered: November 2002
Junior Member
HI..
I'm trying to draw a circle and fill the circle with value 255. I
want to extend this to 3D to draw a sphere and fill the sphere with
value 255. Can anybody tell me how to obtain this.

Thanks.
Re: 2D and 3D filled objects. [message #33466 is a reply to message #33373] Fri, 27 December 2002 09:16 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning (david@dfanning.com) writes:

> Well, then, how about this:
>
> sphere = FltArr(20, 20, 20)
> FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
> sphere(x, y, z) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
> indices = Where(sphere GT 0)
> sphere(indices) = 255

Whoops! I guess I should have tested that code. I was
distracted by the plumber telling me know what the problem
is in the bathroom. Let's just say the era of free advice
may be a thing of the past. :-(

Try this:

sphere = FltArr(40, 40, 40)
FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
sphere(x+10, y+10, z+10) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
indices = Where(sphere Lt 9.5 AND sphere NE 0)
sphere(indices) = 255

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: 2D and 3D filled objects. [message #33467 is a reply to message #33373] Fri, 27 December 2002 09:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
New2IDL (biomedthesis2002@yahoo.com) writes:

> I already tried to generate the sphere the same way but the problem is
> it has various densities. I want a sphere with one density and that
> density is White.
>
> I've written my own code for 3D thinning. I'm not sure if the
> algorithm is right. I know what to expect when i thin a binary sphere.
> That's the reason for this question. To cross check that in 2D, i need
> a binary circle that is completely filled with each pixel value as
> 255.

Well, then, how about this:

sphere = FltArr(20, 20, 20)
FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
sphere(x, y, z) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
indices = Where(sphere GT 0)
sphere(indices) = 255

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@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: Re: 2D and 3D filled objects.
Next Topic: Can't get an cell select event

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

Current Time: Sun Oct 12 06:27:58 PDT 2025

Total time taken to generate the page: 1.19936 seconds