4
$\begingroup$

So let's assume I have a point $P$ in $3D$ space $(x_0, y_0, z_0)$. And I have a circle $C$ that is centered at $(x_1, y_1, z_1)$ with a radius $r$. I need to find the distance from $P$ to the nearest point of $C$. I'm not totally sure how to define a circle in $3D$ space, so suggestions there would help too :D

I really have very little idea where to begin with this (and I only have a very basic understanding of how to do the same thing with a point and a line). I haven't taken a math class in a number of years, but this concept will help tremendously in some $3D$ programming I'm working on.

$\endgroup$
4
  • $\begingroup$ Do you mean a sphere? If you do mean a circle, how is its orientation given? $\endgroup$
    – joriki
    Apr 5, 2011 at 6:45
  • $\begingroup$ I do mean a circle. The orientation is so that it's surrounding the z axis ... but I'd also need to know the distance with an arbitrary rotation about the y axis. $\endgroup$
    – gregghz
    Apr 5, 2011 at 6:47
  • $\begingroup$ We will need more information about the circle: in 3d, center and radius are not enough. $\endgroup$ Apr 5, 2011 at 6:50
  • $\begingroup$ @user6312, I thought that might be the case. Unfortunately I don't know how to define a circle unambiguously in 3d. In my program, I'm able to define the circle with respect to the x and y axes and then rotate it as needed. $\endgroup$
    – gregghz
    Apr 5, 2011 at 6:53

2 Answers 2

5
$\begingroup$

Project the point onto the plane in which the circle lies. Then take the distance to the circle's centre, subtract the radius and take the absolute value to get the distance within the plane. Then you get the total distance from the distance to the plane and the distance within the plane using Pythagoras.

$\endgroup$
2
  • 2
    $\begingroup$ This is assuming that you mean a circle in the mathematical sense. If you actually meant a disc (a circle and its interior), then of course instead of $|d-r|$ you need $\min(0,d-r)$ (where $d$ is the distance from the projected point to the centre). $\endgroup$
    – joriki
    Apr 5, 2011 at 7:03
  • $\begingroup$ That should be $\max(0,d-r)$. $\endgroup$
    – joriki
    Apr 5, 2011 at 10:39
0
$\begingroup$

You need 3 features to define a 3D circle:

center (point)

orientation (direction vector perpendicular to plane of circle3D)

radius (positive scalar)

You need to be clear whether you're interested in the nearest point to P on the disk or the circle edge.

If you know how to set up 3D coordinate rotations and translations, you can greatly simplify the problem by adopting transforms that place the circle at the origin and flat in the z == 0 plane. You apply these desired coordinate translate and coordinate rotate transforms to point P ==>> P' ++> P". Now, with this idealized case, you should be able to solve the problem of the closest point on the circle.

Don't forget to inverse-transform your solution point Psol" ==> Psol' ==> Psol so that it comes out in starting coordinates.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .