Angle
List of all possible functions to manipulate angles.
Created by Angle.
Type | Name | Description |
---|---|---|
number | p or pitch or x or 1 |
The pitch component of the angle. |
number | y or yaw or y or 2 |
The yaw component of the angle. |
number | r or roll or z or 3 |
The roll component of the angle. |
Metamethod | Second Operand | Description |
---|---|---|
__add |
Angle | Returns new Angle with the result of addition. |
__div |
number | Returns new Angle with the result of division. |
__eq |
any | Compares 2 operands, if they both are Angle, compares each individual component. Doesn't normalize the angles (360 is not equal to 0). |
__index |
number or string | Gets the component of the Angle. Returns a number. |
__mul |
number | Returns new Angle with the result of multiplication. |
__newindex |
number or string | Sets the component of the Angle. Accepts number and string. |
__sub |
Angle | Returns new Angle with the result of subtraction. |
__tostring |
Returns p y r . |
|
__unm |
Returns new Angle with the result of negation. |
Methods
Angle:Add( Angle angle )
Adds the values of the argument angle to the orignal angle.
This functions the same as angle1 + angle2 without creating a new angle object, skipping object construction and garbage collection.
Angle:Div( number scalar )
Divides all values of the original angle by a scalar. This functions the same as angle1 / num without creating a new angle object, skipping object construction and garbage collection.
Angle:Mul( number scalar )
Multiplies a scalar to all the values of the orignal angle. This functions the same as num * angle without creating a new angle object, skipping object construction and garbage collection.
Angle:Normalize()
Normalizes the angles by applying a module with 360 to pitch, yaw and roll.
Vector Angle:Right()
Returns a normal vector facing in the direction that points right relative to the angle's direction.
Angle:RotateAroundAxis( Vector axis, number rotation )
Rotates the angle around the specified axis by the specified degrees.
Angle Angle:SnapTo( string axis, number target )
Snaps the angle to nearest interval of degrees.
This will modify the original angle too!
Angle:Sub( Angle angle )
Subtracts the values of the argument angle to the orignal angle. This functions the same as angle1 - angle2 without creating a new angle object, skipping object construction and garbage collection.
Vector Angle:Up()
Returns a normal vector facing in the direction that points up relative to the angle's direction.
Angle:Zero()
Sets pitch, yaw and roll to 0.
This function is faster than doing it manually.
Example
Indexing by angular single-character component.
Output: 1 2 3
Example
Indexing by angular named component.
Output: 1 2 3
Example
Indexing by vector single-character component.
Output: 1 2 3