Trigonometry
Trigonometry - the math that deals with the side lengths and angles of triangles, plays an important role in many games. The trigonometric functions Sine, Cosine, and Tangent relate to the ratios of sides in a right triangle:
You can use the System.MathF
library to compute
float
values:
MathF.Sin(float radians)
computes the of the supplied angleMathF.Cos(float radians)
computes the of the supplied angleMathF.Tan(float radians)
computes the of the supplied angle
You can inverse these operations (compute the angle whose
MathF.Asin(float s)
computes the angle which produces the supplied valueMathF.Acos(float c)
computes the angle which produces the supplied valueMathF.Atan(float t)
computes the angle which produces the supplied valueMathF.Atan2(float x, float y)
computes the angle with produces the supplied x/y ratio. This form can be helpful to avoid a division by 0 error ify
is 0.
These angles are measured in radians - fractions of
The angle of
float
constants for common measurements in radians:
MathHelper.TwoPi
represents , a full rotation around the unit circle ( ).MathHelper.Pi
represents , a half-rotation around the unit circle ( ).MathHelper.PiOver2
represents , a quarter rotation around the unit circle ( ).MathHelper.PiOver4
represents , an eighth rotation around the unit circle ( ).
Inside the unit circle you can inscribe a right triangle with angle at the origin of