Need help from maths people regarding sine(Solved)

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.

1 Like

Ah yes, I remember the first time I did that, circa 1979 on a TRS-80 Model 1 with Level II BASIC.

For future finders, in Unity3D you can convert to / from radians to degrees by multiplying by Mathf.Rad2Deg and Mathf.Deg2Rad .

You WILL need this: tons of Quaternion functions are in degrees while the trig math functions are all radians.

1 Like

Yeah I misread the I formation given with the mathf.sin I thought you had to put the degrees in not the radians. Got there in the end thankfully :smiling_face: