Trigonometry
| Function | Signature | Description |
|---|---|---|
sin | (x: f64) => f64 | Sine |
cos | (x: f64) => f64 | Cosine |
tan | (x: f64) => f64 | Tangent |
asin | (x: f64) => f64 | Arc sine |
acos | (x: f64) => f64 | Arc cosine |
atan | (x: f64) => f64 | Arc tangent |
atan2 | (y: f64, x: f64) => f64 | Arc tangent of y/x |
degToRad | (degrees: f64) => f64 | Convert degrees to radians |
radToDeg | (radians: f64) => f64 | Convert radians to degrees |
sin()
Returns the sine of an angle in radians.
Signature
sin(x: f64): f64tyrus
const radians: f64 = 1.5708; // ~PI/2
const result: f64 = sin(radians);
print(result); // ~1.0cos()
Returns the cosine of an angle in radians.
Signature
cos(x: f64): f64tyrus
const radians: f64 = 0.0;
const result: f64 = cos(radians);
print(result); // 1.0tan()
Returns the tangent of an angle in radians.
Signature
tan(x: f64): f64tyrus
const radians: f64 = 0.7854; // ~PI/4
const result: f64 = tan(radians);
print(result); // ~1.0asin()
Returns the arc sine (inverse sine) of a value in radians.
Signature
asin(x: f64): f64tyrus
const value: f64 = 0.5;
const result: f64 = asin(value);
print(result); // ~0.5236 (PI/6)acos()
Returns the arc cosine (inverse cosine) of a value in radians.
Signature
acos(x: f64): f64tyrus
const value: f64 = 0.5;
const result: f64 = acos(value);
print(result); // ~1.0472 (PI/3)atan()
Returns the arc tangent (inverse tangent) of a value in radians.
Signature
atan(x: f64): f64tyrus
const value: f64 = 1.0;
const result: f64 = atan(value);
print(result); // ~0.7854 (PI/4)atan2()
Returns the arc tangent of y/x, handling the quadrant correctly.
Signature
atan2(y: f64, x: f64): f64tyrus
const y: f64 = 1.0;
const x: f64 = 1.0;
const result: f64 = atan2(y, x);
print(result); // ~0.7854 (PI/4)degToRad()
Converts an angle from degrees to radians.
Signature
degToRad(degrees: f64): f64tyrus
const degrees: f64 = 180.0;
const result: f64 = degToRad(degrees);
print(result); // ~3.1416 (PI)radToDeg()
Converts an angle from radians to degrees.
Signature
radToDeg(radians: f64): f64tyrus
const radians: f64 = 3.1416; // ~PI
const result: f64 = radToDeg(radians);
print(result); // ~180.0