I’m trying to find out the intersection point along 2 transform axis.
I thought the easiest way of doing this would be using trigonometry, as i have the length of one side of the triangle(the distance between the 2 points). and with the axis i can work out all 3 angles. However i am pretty sure i am using the right equation however the lengths of the other 2 sides are massively off. cna anyone have a look and give me some tips would be much appreciated.
public static Vector3 Interception(Vector3 pointA, Transform axisA, Vector3 pointB, Transform axisB)
{
float A = 180 - Vector3.Angle(pointB - pointA, axisA.forward);
float B = 180 - Vector3.Angle(pointA - pointB, axisB.forward);
float c = Vector3.Distance(pointA, pointB);
float C = 180 - (A + B);
A = Mathf.Sin(A);
B = Mathf.Sin(B);
C = Mathf.Sin(C);
float a = (c * A) / C;
float b = (c * B) / C;
if (a < 0) a = a * -1;
if (b < 0) b = b * -1;
Debug.Log(A);
Debug.Log(C);
Debug.DrawLine(pointA, pointB);
Debug.DrawLine(pointA, pointA - (axisA.forward * a));
Debug.DrawLine(pointB, pointB - (axisB.forward * b));
return Vector3.zero;
}
ignore the return at the end just put that in so it does not throw errors at me.
And solved it i forgot to convert the angles to radians XD been bugging me for days this has.