Phone: 905 409-1589
Trigonometry:
 In this tutorial I will not attept to explain all the math involved in working out triangles but will provide examples of how to use some of the simple equations in Max to drive angles and lengths. It is up to you to sort out what you might use them for. I will be providing more examples in the future as I have time to create them as well as add to this page with more advanced trig functions. I use trig regularly in my character, vehicle and mechanical rigging to help drive objects using angles. Consider a piston moving in a cylinder, this is something that can be completely calculated using trig as it is all about angles. There are known sides defined by the length of the connecting rod, the length of the stroke and the angle around the drive shaft. This is all that you need to solve the distances the piston should be moving up and down in a cylinder. For now I will let you sort out how to do that.

Trig is used to calculate the angles and sides of a triangle. There are some great resources on the web for more information.
 Assuming that we have a right angle triangle there are six functions that will calculate the angles and sides of a triangle. We assign a triangle with the traditional A,B and C for the angles and because Max Script is not case sensitive we will use sa, sb and sc for the sides. It is also important to know the names of the sides as this is what you will often see in other help documents on the subject. The Hypotenuse is always the long side in a right angle triangle, Opposite is opposite the angle that you are trying to calculate and Adjacent is the side beside the angle you are calculating. In the example on the right we will be calculating the angle at A. We know the angle C, as it is always 90° and if you wanted to calculate B all you have to do is use the same functions but transpose A and B where they occur.

Calculating the length of the sides:
 To get the length of any one of the sides we need to know the length of the other two. The basic formula will look something like this in your old math text book but I'm going to write it in Max script using our letter representations of the sides. sc^2 = sa^2 + sb^2 What the above assumes is we already have the length of sa and sb. Lets make some assumptions about our triangle to get started. sa=10.0 --Length of Opposite side sb=20.0 --Length of Adjacent side To calculate sc we will need to remove the ^2 from the left side and add the opposite of that to the right side which will be sqrt (square root). sc = sqrt (sa^2 + sb^2) --calculates the length of the Hypotenuse. What we have done above is calculate the length of the hypotenuse. We can use similar functions to get the length of sa or sb if we know the other two. Here they are... sa = sqrt (sc^2 - sb^2) --Calculates the length of the Opposite. sb = sqrt (sc^2 - sa^2) --Calculates the length of the Adjacent.

Calculating the angle at A:
 To be able to calcualte the angle at A we need to have three other pieces of information about the triangle. Since we already know that we are dealing with a right angle triangle we can assume that C is 90° we only need to know the length of two of the sides. There are three ways to calculate the angle at A, we will start with using the Opposite and the Hypotenuse. sin A = (sa / sc) We need to remove the sin from the left and add the opposite to the right. A = asin (sa / sc) --Calculate the angle at A usng the Opposite and Hypotenuse. The two other methods are just as simple. A = acos (sb / sc) --Calculate A using Adjacent and Hypotenuse. A = atan (sa / sb) --Calculate A using Opposite and Adjacent.