How to find the distance before two points in a 2D plane?

62 Views Asked by At

I have the following scenario:

  • There's two different points in a 2D plane;
  • Both points are circles and haves X and Y coordinates and radius;
  • The X and Y coordinates of the points refers to the middle of each circle;
  • I know the distance between both centers through d=√((x2 – x1)² + (y2 – y1)²);

Now i need to discover what X and Y values one of this points needs to reach to get nearest as possible (in a straigth line) from the other one WIHOUT intersecting each other.

For easier comprehension:

enter image description here

Red: PointA;

Green: PointB;

Blue: PointC (I need to discover this X and Y position);

I've tried:

d=√((x2 – x1)² + (y2 – y1)²); Cx = Bx - (d/2);
Cy = By - (d/2);
and
Cx = Ax - (d/2); Cy = Ay - (d/2);

But it's wrong.

Is there any way to find out this?

2

There are 2 best solutions below

0
On

Draw a line segment between the the centers of the two circles. This line segment has a distance of $\sqrt {(x_2 - x_1)^2 + (y_2 - y_1)^2 }$. This line segment intersects

  • the diameter of circle 1, say, at point $P_1$
  • the diameter of circle 2, say, at point $P_2$

So this segment is composed of three subsegments:

  1. $C_1P_1$ whose length is $r_1$
  2. $P_1P_2$ whose distance you're trying to figure out
  3. $C_2P_2$ whose length is $r_2$

Do you see now, what the distance of $P_1P_2$ should be?


  • $C_1$ denotes the center of circle 1
  • $C_2$ denotes the center of circle 2
0
On

Based on more research i'v arrived this:

Ax = 3;
Ay = 5;
Ar = 1;

Bx = 5;
By = 9;
Br = 1;

deltaX = Bx - Ax;
deltaY = By - Ay;
d = sqrt((deltaX ^2) + (deltaY ^2))
distance = d - Ar;