Find the limit point between two points

  • I have the coordinate of point A and another point (e.g. B, C or D).
  • I also have a distance between A and another point.
  • I know the maximum permissible distance between A and another point (shown by the purple line and the imaginary circle).
  • Question: How to find the coordinates of the red dots (B1 or C1 or D1).
  • Example: A = (- 1,1), E = (3, -8) , Maximum allowable distance = 4. What is the coordinate of point E1?

Here is a picture of the problem: problem

Note: I found 2 more questions that are very similar or equal, but I can’t figure it out: Looking for the coordinates of a point between two points?

How to find a point located between two points forming a segment using only the partial length of the segment?

PS This is not homework, I need it for a programming problem, but I forgot my math ...

+4
source share
1 answer

Assuming A is a position vector, B is a position vector, and maxLength is the maximum length you allow.

A and B are Vector2 (since you noted this question ).

 // Create a vector that describes going from A to B var AtoB = (B - A); // Make a vector going from A to B, but only one unit in length var AtoBUnitLength = Vector2.Normalize(AtoB); // Make a vector in the direction of B from A, of length maxLength var AtoB1 = AtoBUnitLength * maxLength; // B1 is the starting point (A) + the direction vector of the // correct length we just created. var B1 = A + AtoB1; // One liner: var B1 = A + Vector2.Normalize(B - A) * maxLength; 
+6
source

All Articles