0

I need to draw a circle on the plane orthogonal to a vector. I have the point which will be the center of the circle, the vector I have to be orthogonal to, the radius of the circle and the resolution of the circle.

How can I compute the coordinates of the circle ?

Something like :

double point[3] = {x, y, z}
double normal[3] = {u, v ,w}
double r = radius()
int res = resolution()
double circlePoint[3];

for (int i = 0; i < res; i++)
{
  circlePoint[0] = point[0] + radius * ?
  circlePoint[1] = point[1] + radius * ?
  circlePoint[2] = point[2] + radius * ?
}
Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33
  • see [glCircle3D](https://stackoverflow.com/a/25182327/2521214) simply construct 2 basis vectors describing the plane and perpendicular to each and plane normal exploiting cross product and then use them to convert standard 2D circle into 3D or construct [transform matrix](https://stackoverflow.com/a/28084380/2521214) and apply it on a circle instead. – Spektre Jul 18 '19 at 16:55
  • The duplicate is for another language but the code in the accepted answer would compile as C++ so I don't think there should be much of an issue with it. – Max Langhof Jul 18 '19 at 16:56
  • @MaxLanghof If that is a problem mine first link is GL/C++ directly doing the same from the looks of it – Spektre Jul 18 '19 at 16:59
  • perfect, thanks @MaxLanghof – Mathieu Westphal Jul 19 '19 at 08:28

0 Answers0