0

Given an initial set of coords in a 2d space:

A = 0,0
B = 0,20
C = 10,10

Then after an interval a moved set of points, i.e

A = 0,0
B = 0,20
C = 5,5

How do I calculate to what degree left or right Point B has moved in relation to point A.

Context: Say three people are standing in a field, its dark and they cant see each other, no internet, no gps, but the devices they are holding know of the distances between nodes, and we can calculate the basic triangle. If I am at point A and want to get to point B, in which direction do I travel?

1 Answers1

0

use the dot or cross product to calcualte the position inside the two triangles, the calculate the diffrence.

Or if you want there are answers on stack overflow about points inside triangles that can be found here

float sign (fPoint p1, fPoint p2, fPoint p3)
{
    return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
}

bool PointInTriangle (fPoint pt, fPoint v1, fPoint v2, fPoint v3)
{
    bool b1, b2, b3;

    b1 = sign(pt, v1, v2) < 0.0f;
    b2 = sign(pt, v2, v3) < 0.0f;
    b3 = sign(pt, v3, v1) < 0.0f;

    return ((b1 == b2) && (b2 == b3));
}
Paddy
  • 772
  • 2
  • 11
  • 28
  • Thanks Paddy. I'm not sure how that helps? I know the positions (using an arbitrarily assigned grid), I'm just not sure of the calculation to work out the relative change in angle between the two time frames. The issue stems from the fact that I have no way to orientate the 'map' so have to use an arbitrary grid reference. I am trying to find a way of orientating the map in some way. Apologies if i've missed the point. I'm not great with this stuff! – Mark Stephenson Sep 13 '16 at 13:54