• Advertisement
Sign in to follow this  

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

This topic is 4342 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

Hey guys. Here's a funcky question I haven't found a good answer for yet. I have a point in 3d space and a direction vector (basically, a ray). I want to determine a 3d point on the outer edge of the circle for some radius and some theta. I know it's possible, but the math isn't clear to me. Anyone have any clues as to how I can do it?

Share this post


Link to post
Share on other sites
Advertisement
If you mean circle:

You can always find the edge on the xy-parrelel-plane by adding (sinv, cosv) to the coordinate. You'll have to turn the apropriately if you want it to be on some other plane.

If you mean sphere:

No idea, but you'd need two angles two describe an exact point.

Share this post


Link to post
Share on other sites
right i know how to find values in 2d... i guess i'm trying to figure out how to rotate that circle's plane, like you said, such that the points on the actual circle rotate properly around the circle's center point.

i need to calculate this... cant use transforms. surely someone's done it.

Share this post


Link to post
Share on other sites
Quote:
Original post by datadawgx
i need to calculate this... cant use transforms. surely someone's done it.
The question probably has an easy answer, but perhaps you could clarify what you're after. It sounds like you have a point and a vector, and you want to create points on a circle centered on that point, and lying in a plane whose normal is perpendicular to the vector. Is that right?

Share this post


Link to post
Share on other sites
Quote:
Original post by datadawgx
right i know how to find values in 2d... i guess i'm trying to figure out how to rotate that circle's plane, like you said, such that the points on the actual circle rotate properly around the circle's center point.

Find the normal vector of the plane and rotate it?

Share this post


Link to post
Share on other sites
Quote:
Original post by datadawgx
any tips?
It kind of depends on what you're really doing (creating a mesh around a curve of some sort, for example), and what the constraints are. One solution though is to build an arbitrary local coordinate system around the point and the vector, and then use it to construct the vertices of the circle. Ask if you need help with the details (actually, this could probably stand to be in an FAQ somewhere, as it comes up quite often).

Share this post


Link to post
Share on other sites
i'm not trying to create geometry, per se, but i am looking for vertex-like information (3d points on the circle's arc). i think i understand what you are saying about the local coordinate system... essentially, i'd be picking points from a circle that lies on a plane in 3d space, and then i want to rotate the circle's plane (and the defined points) such that the circle's normal points in the desired direction.

i can't wrap myself around the math. are matrix transforms in inevidable?

Share this post


Link to post
Share on other sites
This is all you need.

It's about moving cameras around without gimbal lock, but think about it: you want to rotate a vector around another one. Quaternions are (I haven't gotten into them much) fast and easy to use.

Have fun!

Share this post


Link to post
Share on other sites
Say you have point 'P' which is the centre of your circle and normal 'N'. You can create a random point 'A' that lies on the circle of given radius as follows:

- create a random vector 'V' (e.g. 0.34234, 0.565754, -0.5443) those numbers can be picked randomly. Just make sure the numbers you pick do not result in a null vector or one that is parallel with your vector N, or you will have trouble in the normalisation stage.

- create vector 'R' where: R = crossproduct(N, V)

- normalise(R)

// R is a random vector of unit length lying in the plane defined by normal N

- A = P + R * radius

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


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

  • Advertisement