I wanted to let my program know whether a point X is at the right or the left of a line that crosses A and B I found that solution in this forum (How to tell whether a point is to the right or left side of a line) and it was really helpful, but once I changed the angle of the line it just stopped working and started to give me the result of a line that has 0° as heading
I work with Lines that rarely have 0°
I tried also to rotate the point I have using an equation but still giving me the same result I'm trying to achieve the results I want in Unity Engine so I can visualize what I'm doing before actually jumping to the original program
float Ax = Stop.transform.position.x;
float Ay = Stop.transform.position.y;
float Bx = Ref.transform.position.x;
float By = Ref.transform.position.y;
float X = Wheel.transform.position.x;
float Y = Wheel.transform.position.y;
float x = X * Cos(Gate.transform.rotation.eulerAngles.y) - Y * Sin(Gate.transform.rotation.eulerAngles.y);
float y = Y * Cos(Gate.transform.rotation.eulerAngles.y) + X * Sin(Gate.transform.rotation.eulerAngles.y);
float position = System.Math.Sign((Bx - Ax) * (Y - Ay) - (By - Ay) * (X - Ax));
if (position > 0)
{
lg.Log("Left");
}
else
{
lg.Log("Right");
}
I expect the program to return right or left whatever the heading of the line is and whatever is the distance between A & B & X but it just gives me results of straight 0° heading line which is weird as the B point is not aligned with the Y axes :|