Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the third point

Tags:

math

drawing

I have 2 points P1 and P2. I need to find the P3, in order that

  • all points to be on the same line;
  • P3 should be at the distance d from the P2 (away from P1)

I started a complicated system apparently hardly to resolve...
alt text

PS.

Vectorial answers is cool, but I use C# and don't know how to add vectors over there.

like image 263
serhio Avatar asked Nov 25 '10 20:11

serhio


People also ask

What is the formula to find a point?

To find points on the line y = mx + b, choose x and solve the equation for y, or. choose y and solve for x.

What is the third coordinate?

Three coordinate axes are given, each perpendicular to the other two at the origin, the point at which they cross. They are usually labeled x, y, and z.

How do you find a point on a triangle?

A simple way is to: find the vectors connecting the point to each of the triangle's three vertices and sum the angles between those vectors. If the sum of the angles is 2*pi then the point is inside the triangle.


2 Answers

P3 = P2 + d * ±(P2 - P1) / |P2 - P1|

EDIT:

Because shopping is easy:

mag = sqrt((P2x - P1x) ** 2 + (P2y - P1y) ** 2)
P3x = P2x + d * (P2x - P1x) / mag
P3y = P2y + d * (P2y - P1y) / mag
like image 76
Ignacio Vazquez-Abrams Avatar answered Jan 03 '23 08:01

Ignacio Vazquez-Abrams


I have translated the code to Objective C

float distanceFromPx2toP3 = 1300.0;    

float mag = sqrt(pow((px2.x - px1.x),2) + pow((px2.y - px1.y),2));
float P3x = px2.x + distanceFromPx2toP3 * (px2.x - px1.x) / mag;
float P3y = px2.y + distanceFromPx2toP3 * (px2.y - px1.y) / mag;

CGPoint  P3 = CGPointMake(P3x, P3y);
like image 45
Registered User Avatar answered Jan 03 '23 08:01

Registered User