Re: Need an "atom" object [message #14895] |
Fri, 02 April 1999 00:00 |
rmlongfield
Messages: 68 Registered: August 1998
|
Member |
|
|
In article <37036F0B.2ABBE82F@astro.estec.esa.nl>,
Michael Werger <mwerger@astro.estec.esa.nl> wrote:
> Hy object'lers,
>
> I re-arranged code from the recent IDL distribution and
> put it in some way together what we would think of a simple
> atom/molecule demo..
>
> IDL> .run cristal
> IDL> cristal
>
> be warned: have the examples directories of IDL also in
> your searchable path because it uses surf_track.pro (wonderful app)
> and orb__define.pro
>
> (Oh' it doesn't work? feedback is appreciated and I will then
> return code which should work...)
Hi Michael,
Just tried your program and it works on a Silicon Graphics with IDL5.2
(Once I realized that the name was cristal and not crystal :-).
The code looks very simple and its almost tempting to start learing objects.
I found just one problem when I pressed the right button:
% Tag name WLABEL is undefined for structure <Anonymous>.
% Execution halted at: CRISTAL_EVENT 91
/usr/people/dlhopols/IDL/crystal.pro
% WIDGET_PROCESS_EVENTS
% $MAIN$
Also, after the error, I couldn't delete the widget at all and had to exit
IDL. Is there a command that would do this from within IDL?
Rose
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
|
|
|
|
Re: Need an "atom" object [message #14910 is a reply to message #14909] |
Thu, 01 April 1999 00:00  |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
David Fanning wrote:
> I'm trying to save myself a bit of time and help out a friend
> at the same time. We are looking for some kind of "atom"
> object that would be a sphere with a particular color
> and radius. It might have its own light source associated
> with it. The idea would be to clump these atoms together
> into a rotatable "molecule", if you like.
I think Richard Adams' suggestion of using the "orb" data
type would probably fill your needs, David, but just in case
you'd like a small, quick'n dirty thing to build on, I made
the following implementation of a "ball" object the other
day.
Like the "orb" object, it's subclassed from the IDLgrModel
class, and contains a polygon object. The surface is built
up by a square array, equally spaced in [theta,phi] "space".
Input radius r and number of points n.
The polygon vertex list forms a "quad strip" to take
advantage of polygon mesh optimization.
I see the "orb" class has an inherent "position", personally
I like to implement this through a translation of the "ball"
model itself.
Regars,
Stein Vidar
------------------------------------------------------------ ------------
PRO ball::cleanup
self->idlgrmodel::cleanup
END
FUNCTION ball::init,r,n,color=color
if n_elements(color) eq 0 then color=[255,255,255]
dummy = self->idlgrmodel::init()
x = rebin(reform(findgen(n)/n,n,1,/overwrite),n,n,/sample)
y = rebin(reform(findgen(n)/(n-1),1,n,/overwrite),n,n,/sample)
theta = x*(360.0*!dtor)
phi = (y-0.5)*(180.0*!dtor)
sinphi = sin(phi)
cosphi = cos(temporary(phi))
costheta = cos(theta)
sintheta = sin(temporary(theta))
xp = r* temporary(costheta)*cosphi
yp = r* temporary(sintheta)*temporary(cosphi)
zp = r* temporary(sinphi)
gons = lindgen(5,n*(n-1))
FOR yi=0,n-2 DO BEGIN
yyi = [yi,yi,yi+1,yi+1]
FOR xi=0,n-1 DO BEGIN
xxi = [xi,(xi+1) MOD n,(xi+1) MOD n,xi]
gons(0,yi*n+xi) = [4,xxi + yyi*n]
END
END
stop
xp = reform(xp,n*n,/overwrite)
yp = reform(yp,n*n,/overwrite)
zp = reform(zp,n*n,/overwrite)
ball = obj_new('idlgrpolygon',xp,yp,zp,polygons=gons,color=color)
self->add,ball
self->translate,100,0,2*r
return,1
END
PRO ball__define
dummy = {BALL,$
INHERITS idlgrmodel $
}
END
|
|
|
Re: Need an "atom" object [message #14913 is a reply to message #14909] |
Thu, 01 April 1999 00:00  |
Richard J Adams
Messages: 1 Registered: April 1999
|
Junior Member |
|
|
Dear David,
I have used the 'orb' class that comes with the IDL distribution - I think
it is with the planet example. I don't remember that it has its own lamp.
However,once you get a few hundred of these, animation get a bit slow on my
poor Mac :-(
Richard.
--
Richard J Adams richard.adams@physiol.ox.ac.uk
Confocal Microscopy Laboratory T: + 44 1865 272506
University Laboratory of Physiology F: + 44 1865 272469
Parks Road
Oxford OX1 3PT
UK
----------
In article <MPG.116c07a333e3cd2b98973e@news.frii.com>, davidf@dfanning.com
(David Fanning) wrote:
> Hi Folks,
>
> I'm trying to save myself a bit of time and help out a friend
> at the same time. We are looking for some kind of "atom"
> object that would be a sphere with a particular color
> and radius. It might have its own light source associated
> with it. The idea would be to clump these atoms together
> into a rotatable "molecule", if you like.
>
> I believe I know how to make such a thing, but I'm
> busy getting ready for an IDL class and would prefer to
> spend my evenings doing other things. :-)
>
> Any help would be greatly appreciated.
>
> 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
|
|
|