Jump to content
  • Advertisement
Sign in to follow this  

Circle in 3D

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I usually draw circles in 3D using the following formula: point = (center.x + (radius * cos(a)), center.y + (radius * sin(a)), center.z) Not the most efficient way considering the cos and sin but performance is not my primary concern here. The problem with this is that the circle is always draw along 2 axis (in that case X and Y). What if I want to draw a circle on any plane in 3D space, given 3 points on that plane (I have 3 points on the circle as well as its center, I'm just missing the formula to render it on the screen). Thanks for your help!

Share this post

Link to post
Share on other sites
3 points + centre is overkill (a plane is defined by three points).

Say, a centre and two points :) these points create a frame that you can use to orientate your circle.


// three vector (right, up, dir) for a orthormal frame.
// each vector will be of unit length, and perpendicular to each other.
// they form an orientation matrix, or a othonormal coordinate system.
Vector right = (a - centre);
Vector dir = (b - centre);
Vector up;

right = (a - centre);
dir = (b - centre);
up = dir.cross_product(right);

dir = right.cross_product(up);

from then on, you can do...


float a = 0.0f;
const int slices = 32;
float da = two_pi() / slices;

for(int i = 0; i < slices; i++, a+= da)
point = centre + (right * (cos(a) * radius)) + (dir * (sin(a) * radius));

Normal of circle will be 'up'. 'right' is, if you will, the x-axis of your circle, and 'dir' will be the 'y' axis of your circle.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!