   3D Circle-point collision
  How would I check if a point is inside a circle in 3D space?I can't do a check to see if the radius is <= the distance between the point and the centre of the circle because this would be a spherical check.[Edited by - MrPickle on April 18, 2010 4:11:11 PM]
  First, see if the point lies within the radius of the circle (i.e., if it's inside the sphere with the same radius as the circle). Second, see if the point and the circle are coplanar. If both are true, the point is contained by the circle.   ;  A circle has no thickness, so basically, you would be checking for a point in cylinder check (cylinder with very small thickness maybe). A point (p) is in cylinder [c, d, r] if((p - c) x d)^2 <= r^2where c is a point on the cylinder centre line, d is the cylinder direction (normalised), and r the radius.I suppose you would first need to check if the point is close to the circle plane, so basically if the distance is within a tolerance.so the checks would be...fabs((p - c) . d) <= tolerance.and((p - c) x d)^2 <= r^2;Quote:Original post by oliii((p - c) x d)^2 <= r^2where c is a point on the cylinder centre line, d is the cylinder direction (normalised), and r the radius.Would d just be c normalized in the case of a circle?;  c is the centre of the circle. d is the direction the circle is facing towards.   ;Quote:Original post by oliiic is the centre of the circle. d is the direction the circle is facing towards.Yes, I understand that but I'm not sure how to work out the direction. (we've only just learnt about 3D vectors in math)I'm use to seeing vector lines like so:r = a + tbwhere b is the direction and I'm not entirely sure how to work out the direction from one point?With a line (I think) you just subtract two points along the line from each other. but you can't do that with just one point.   ;Quote:Original post by MrPickleQuote:Original post by oliiic is the centre of the circle. d is the direction the circle is facing towards.Yes, I understand that but I'm not sure how to work out the direction. (we've only just learnt about 3D vectors in math)I'm use to seeing vector lines like so:r = a + tbwhere b is the direction and I'm not entirely sure how to work out the direction from one point?With a line (I think) you just subtract two points along the line from each other. but you can't do that with just one point.If you have a circle in 3-d space, you must have some bit of information that specifies its orientation. This could be a matrix, a quaternion, one, two, or three basis vectors, etc. Whatever representation you're using though, you can derive from it the direction vector that oliii is referring to.So how is your circle represented? What information do you have?   ;Quote:Original post by jykSo how is your circle represented? What information do you have?I have the centre point of the circle, the radius and 24 points on the circumference of the circle.Would the cross product of any two vectors from the circumference to the centre give me the direction?   ;  yep, that should do it. d = (v[0] - c) x (v[1] - c)normalise 'd' as well.   ;Quote:I have the centre point of the circle, the radius and 24 points on the circumference of the circle.You (or someone) must have had an orientation for the circle at some point in order to generate those 24 points. Is that information not available to you?In any case:Quote:Would the cross product of any two vectors from the circumference to the centre give me the direction?Yeah, you can take the cross product of the vectors from the center to two of the points on the circle, and normalize the result. It'll probably work fine as long as you don't use points that are directly opposite one another, but for maximum stability you'll want the vectors to be around 90 degrees from one another (e.g. use points '0' and '6').   