Determining 3D points on a 3d circle with center and normal vector

Started by
12 comments, last by datadawgx 18 years ago
hey space dude that sounds very promising! i'm going to experiment with it a little and see what it does.

the other alternative i came up with so far involves breaking all the trig down into 2D planes and changing each point in stages. lots of steps make it more confusing.

i'll try space dudes approach today.
Advertisement
ok spacedude i got a problem already. in your equation: A = P + R * radius, how do i account for the point A's position on the circle? i'm trying to represent that as an angle. see imagine a circle drawn on the xy plane. it's normal points directly down the z axis. at 0 degrees, the point is on the rightmost part of the circles arc (A.x = P.x + cos(theta) * R). If the angle is 90 degrees, A.x = P.x, but A.y = P.y + sin(theta) * R. So with an angle, radius, and center point, I can calculate a point on the circle on a 2D plane. No sweat. But, now if i want to rotate that entire circle (rotate its plane) such that its normal will then point in the direction of another vector, how do I rotate every possible point A? The amount of change in position for A.x, A.y, and A.z is going to be distinctly different depending on that points angle as described above.

Image the 2D circle on the XY plane with an angle of 90 degrees (top of the circle). If the circle's plane is rotated around the Y-axis only, the point won't change at all. But, if that same point has an angle of 180 degrees, A.x and A.z will change significantly. The angle of the point has to be a part of whatever method used.
Ok, say you've created your circle vertices centered at the origin and in the xy plane, as you've described. What you now need to do is to apply a transformation that will position and orient it as you wish. There are various ways to do this, but the most common is probably via a 4x4 matrix.

The translation for the matrix is simply the point at which you want the circle to be centered. The rotation is a bit harder. Part of the problem is that there's no unique rotation that will do what you want. If you imagine the circle where you want it, you can see that you could 'spin' it around its center (and in its plane) with no change to the shape. This means that your choice of rotation will be at least somewhat arbitrary.

So now your task is basically to fill in the upper-left 3x3 portion of the 4x4 transformation matrix. One method would be similar to spacedude's, i.e. cross the direction vector with a random vector, and then perform another cross to fill out the basis. You could also do it with spherical coordinates. Or, you could calculate an axis-angle rotation to rotate the circle into alignment with the direction vector. There are probably other methods as well, and each has its own advantages and disadvantages.

Without knowing exactly what you're trying to do I can't say which method would be best. But feel free to ask if you need further details on any of the aforementioned methods.
i'm having problems wrapping my head around the trig idea. what would be involved with using matrices to rotate the circle and its points?

This topic is closed to new replies.

Advertisement