Discussion:
draw spheres in 3D space
(too old to reply)
Junum
2011-06-06 18:50:57 UTC
Permalink
Hello,

I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.

Sincerely,
Jun
Junum
2011-06-06 18:52:11 UTC
Permalink
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a type.
A center of last sphere should be (0,0,-2).

Jun
Junum
2011-06-06 18:53:41 UTC
Permalink
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a typo.
A center of the last sphere should be (0,0,-2).

Jun
Paulo Penteado
2011-06-06 19:03:36 UTC
Permalink
Post by Junum
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a typo.
A center of the last sphere should be (0,0,-2).
Jun
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
Junum
2011-06-06 19:14:05 UTC
Permalink
Post by Paulo Penteado
Post by Junum
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a typo.
A center of the last sphere should be (0,0,-2).
Jun
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
Thank you for suggestion, but I got error message,

IDL> xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
IDL> p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')

p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
^
% Syntax error.

I am using IDL 7.0.
Michael Galloy
2011-06-06 19:21:49 UTC
Permalink
Post by Junum
Post by Paulo Penteado
Post by Junum
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a typo.
A center of the last sphere should be (0,0,-2).
Jun
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
Thank you for suggestion, but I got error message,
IDL> xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
IDL> p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
^
% Syntax error.
I am using IDL 7.0.
This should work on older versions of IDL:

model = obj_new('IDLgrModel')
model->add, obj_new('orb', pos=[ 0, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 2, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[-2, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 2, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0,-2, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 0, 2], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 0,-2], radius=1., color=[255, 215, 0])

xobjview, model

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Junum
2011-06-06 19:31:22 UTC
Permalink
Post by Michael Galloy
Post by Junum
Post by Paulo Penteado
Post by Junum
Post by Junum
Hello,
I wan to know how to draw spheres in 3D space with xyz axes.
For example, I have 7 spheres with radius of 1 and its center is at
(0,0,0)
(2,0,0)
(-2,0,0)
(0,2,0)
(0,-2,0)
(0,0,2)
(0,0,-1).
Since I don't have idea for 3D drawing, it is hard to start.
Could you let me know any clue, help, suggestion?
Thank you very much.
Sincerely,
Jun
There was a typo.
A center of the last sphere should be (0,0,-2).
Jun
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
Thank you for suggestion, but I got error message,
IDL>  xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
IDL>  p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
                                                ^
% Syntax error.
I am using IDL 7.0.
model = obj_new('IDLgrModel')
model->add, obj_new('orb', pos=[ 0, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 2, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[-2, 0, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 2, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0,-2, 0], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 0, 2], radius=1., color=[255, 215, 0])
model->add, obj_new('orb', pos=[ 0, 0,-2], radius=1., color=[255, 215, 0])
xobjview, model
Mike
--
Michael Galloywww.michaelgalloy.com
Modern IDL, A Guide to Learning IDL:http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Thank you very much for help.
It is really cool.
How can I add xyz axes on this plot?
Thank you.

Jun
Paulo Penteado
2011-06-06 19:26:26 UTC
Permalink
Post by Junum
Thank you for suggestion, but I got error message,
IDL> xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
IDL> p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
                                               ^
% Syntax error.
I am using IDL 7.0.
That will not work in 7.0. This will:

xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
orb=obj_new('orb')
iplot,xyz,/scatter,sym_object=orb
Junum
2011-06-06 19:40:04 UTC
Permalink
Post by Paulo Penteado
Post by Junum
Thank you for suggestion, but I got error message,
IDL> xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
IDL> p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
                                               ^
% Syntax error.
I am using IDL 7.0.
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
orb=obj_new('orb')
iplot,xyz,/scatter,sym_object=orb
Dear Paulo Penteado

Thank you for your help.
Now I don't have any problem, except symbols are too small.
I can change symbol size manually, but what I wanted is seven spheres
attached, so I specified size and center of spheres.
Can I specify the size of sphere?
Thank you.

Jun
David Fanning
2011-06-06 19:19:38 UTC
Permalink
Post by Paulo Penteado
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
I admit that's pretty cool. But what does a "radius
of one" mean in this context? For example, here are
orb objects with a radius of 5, but clearly this
radius has nothing whatsoever to do with the axes:

p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*], $
sym_object=orb(radius=5),/ undocumented,$
linestyle='none')

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Paulo Penteado
2011-06-06 23:15:29 UTC
Permalink
Post by David Fanning
Post by Paulo Penteado
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
I admit that's pretty cool. But what does a "radius
of one" mean in this context? For example, here are
orb objects with a radius of 5, but clearly this
  p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*], $
     sym_object=orb(radius=5),/ undocumented,$
     linestyle='none')
Yes, I had not noticed that a "hard" radius was intended. Those sizes
are unrelated to the data space because the spheres are taken as plot
symbols, and as such have "soft" sizes. You can see that if you change
the size of the window: the symbols will remain the same size, while
the axes will change.

Borrowing from Mike's example, this could be done with iplot
(similarly with plot3d()) by making a bunch o spheres with the proper
sizes and positions in a model, then putting that model into the
plot's data space:

xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
model = obj_new('IDLgrModel')
for i=0,6 do model-
Post by David Fanning
add,obj_new('orb',pos=xyz[*,i],radius=1.,color=[255, 215, 0])
iplot,xyz,/scale_isotropic,/scatter,sym_index=0
id=itgetcurrent(tool=ot)
oplot3d=ot->getbyidentifier(ot->findidentifiers('*/PLOT3D',/
visualization))
oplot3d->add,model
Junum
2011-06-07 04:26:23 UTC
Permalink
Post by Paulo Penteado
Post by David Fanning
Post by Paulo Penteado
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*],sym_object=orb(),/
undocumented,linestyle='none')
I admit that's pretty cool. But what does a "radius
of one" mean in this context? For example, here are
orb objects with a radius of 5, but clearly this
  p=plot3d(xyz[0,*],xyz[1,*],xyz[2,*], $
     sym_object=orb(radius=5),/ undocumented,$
     linestyle='none')
Yes, I had not noticed that a "hard" radius was intended. Those sizes
are unrelated to the data space because the spheres are taken as plot
symbols, and as such have "soft" sizes. You can see that if you change
the size of the window: the symbols will remain the same size, while
the axes will change.
Borrowing from Mike's example, this could be done with iplot
(similarly with plot3d()) by making a bunch o spheres with the proper
sizes and positions in a model, then putting that model into the
xyz=[[0,0,0],[2,0,0],[-2,0,0],[0,2,0],[0,-2,0],[0,0,2],[0,0,-2]]
model = obj_new('IDLgrModel')
for i=0,6 do model->add,obj_new('orb',pos=xyz[*,i],radius=1.,color=[255, 215, 0])
iplot,xyz,/scale_isotropic,/scatter,sym_index=0
id=itgetcurrent(tool=ot)
oplot3d=ot->getbyidentifier(ot->findidentifiers('*/PLOT3D',/
visualization))
oplot3d->add,model
Thank very much Paulo.
It helps me a lot.

Jun

Continue reading on narkive:
Loading...