#### Archived

This topic is now archived and is closed to further replies.

# a circle in 3d?

This topic is 5550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i want to draw a circle in 3d, but not a flat one with z=0... and i don''t know how to do it... any ideas?

##### Share on other sites
Hi
Er... You want to draw a circle that is not flat ... Well its not a circle then. Is it a torus ? a kind of cylinder ? A disc (that is, a circle with inside filled, but it is still a flat geometry)
Maybe you just wanted to draw a flat circle that is rotated so it is not in the Z=0 plane ?
Tell us more !

##### Share on other sites
well, it''s a circle but in 3DSpace...
not a Sphere, but a circle that the radius direction can be toward the Z plane...

##### Share on other sites
So you went a Globe or a Ball?

NeFrUgLe

##### Share on other sites
To get a circle which is not at z=0 (that is, a circle in an arbitrary plane in 3-space), simply use a rotation matrix. Create a normal circle, in whatever plane is easiest for you, and then crank it through a rotation matrix to get the orientation you want. (Works for everything, by the way )

Is that what you''re asking for?

-Odd the Hermit

##### Share on other sites
try using D3DXCreateCylinder or D3DXCreateTorus to create a really skinny mesh and then rotate it as Odd the Hermit suggests. you''ll have to clone it to another FVF if you want to use lighting as the mesh is only created with positions, no normals.

##### Share on other sites
A circle oriented to a specified axis:

P = C + r * (cos(a)*U + sin(a)*V)

a = angle of point around circle
r = radius of circle
C = origin/centre of circle in world space

N = the axis (normal) of the plane the circle is in
U = vector perpendicular to N and V
V = vector perpendicular to N and U

UVN form an orthonormal basis for the circle coordinate system

P = point of circle in plane defined by axis (normal)

You can munge the components of your N vector (the axis) to get a temporary "other" vector (i.e. some vector which isn''t the same as N), then do two cross products to construct U and V.

Then you perform the above (P = C + ...) to make each point around your circle (i.e. step=360_degrees/num_vertices_to_create)

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
that''s what i wanted!
thanks

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 30
• 22
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001800
×