Basically, a point's coordinates is an angle and a distance.

At the moment I'm just doing 2d. The coordinates help me build things easier programmatically. I know this has programming but it is the math that is tripping me up.

In any case, I am putting together some computer functions that converts a point's coordinates from one origin point to another origin point.

However, in the tests, the results seem to be backwards. The test points that should be between the two origins have their new coordinates on the far side, while the test points on the far side has it's new coordinates place it in between.

For example, I have the second origin point at 90 degrees and 20 units distant from the primary origin point. From that second origin, the test point A is at 90 degrees and 10 units out. Therefore, it's total distance from the primary origin should be 30 units, but I get 10 instead. Meanwhile, the test point B that is at 270 degrees from the second origin and 10 units distant, placing it directly between the two origin points, comes up as a distance of 30.

The numbers all come up correctly, just for a reciprocal point.

The method I'm using is solving SAS triangles. I know two sides (originA to originB and point to originB), and the angle between those sides. Thus I use law of cosines then law of sines.

Any ideas why this might be the case?

For reference,

F is primary origin, L is secondary origin, and P is the point whose coordinates are being translated.

x is distance, y is angle (for the coordinates)

a is an intermediate angle of the triangle.

These stack together for easy recognition of values.

I.E.

Lx is the distance from F to L.

Px is the distance from P to L,

Fx is from F to P.

Ly is the angle of L from reference with F as the vertex,

Py is the angle of P from reference with L as vertex.

Fy is the angle of P from reference with F as the vertex. (one of the values I want to find)

Pa is the angle from Px to Fx, with P as the vertex.

Fa is the angle from Fx to Lx with F as the vertex.

La is the angle from Lx to Px with L as the vertex.

getInverseAngle just returns the reciprocal angle (I.E. 90 degrees returns as 270 degrees)

correctAngle just ensures no negative angle nor angle of more than one full rotation, thus all angles are between 0 and 360 degrees.

I have the angles measured as 1 = 360 degrees, and thus get converted to radians for the sin, asin, and cos functions as needed.

if (Ly < Py && Py < getInverseAngle(Ly)){

La = correctAngle(getInverseAngle(Ly) - Py);

Fx = sqrt((Px*Px) + (Lx*Lx) + (2 * Px*Lx*cos(La*(2 * PI))));

if (Px <= Lx){//if Px is not larger than Lx, then can go straight to Fa, Px is used as known angle/side

Fa = (sin(La*(2 * PI)) / Fx)*Px;

Fa = asin(Fa) / (2 * PI);

Fy = Fa + Ly;

}//close if Px is smaller

else {

Pa = (sin(La*(2 * PI)) / Fx)*Px;

Pa = asin(Pa) / (2 * PI);

Fa = .5 - La - Pa;

Fy = Fa + Ly;

}//close if Lx is smaller

}

else {

La = correctAngle(.5-(Ly- Py));

Fx = sqrt((Px*Px) + (Lx*Lx) + (2 * Px*Lx*cos(La*(2 * PI))));

if (Px <= Lx){//if Px is not larger than Lx, then can find Fa directly, Px is used as known angle/side

Fa = (sin(LoA*(2 * PI)) / Fx)*Px;

Fa = asin(Fa) / (2 * PI);

Fy = correctAngle(Ly - Fa);

}//close if Px is smaller

else {//if Px is larger than Lx, then need to find the smaller angle first, then find Fa,

Pa = (sin(La*(2 * PI)) / Fx)*Lx;

Pa = asin(Pa) / (2 * PI);

Fa = .5 - La - Pa;

Fy = correctAngle(Ly - Fa);

}//close if Lx is smaller