# Trigonometry In 3D Space

Apologies if this has been asked, but I can’t find an answer specific enough that I can understand it.

I’m trying to perform some trig in 3D space in order to calculate a point in the form of a Vector3. I have the angle (‘t’ in the image below) and the Vector3 coordinates of the ‘t’ corner and the right angle corner. I need to calculate the remaining hypotenuse-opposite corner in C# script. However, I don’t know where or at what orientation this triangle is going to appear in space when the calculation takes place, so I need to be able to calculate the hypotenuse-opposite corner as a Vector3 with just the given points and angles. In case it’s important, I also know a point on the hypotenuse.

Can anyone give me some examples or direction that are easy to digest for someone new to 3D worldspace math?

For reference: Without knowing how the triangle is to be oriented, it isn’t really possible to find the point using just the other two corners and an angle. However, if you already know a point on the hypotenuse then we can use that to figure out the orientation of the triangle;

``````//Where;
// - t = angle in radians. if t is in degrees then you can multiply it by Mathf.Deg2Rad
// - pT = the 3D coords of the known corner
// - pR = the 3D coords of the right-angle
// - pH = the 3D coords of a point on the hypotenuse

//First, we need to find the length of the adjacent side
float adjacent = Vector3.Distance (pT, pR);

//Then, we can use that and some trig to find the length of the hypotenuse
// - cos (t) = adj / hyp
// - hyp = adj / cos (t)
float hypotenuse = adjacent / Mathf.Cos (t);

//Now, we can find the direction of the final corner from pT by subtracting it from pH and normalising the vector
Vector3 pTH = (pH - pT).normalized;

//Which we can then add to pT and scale by the length of the hypotenuse to find the coordinates of the remaining corner
Vector3 corner = pT + pTH * hypotenuse;
``````