Garry's Mod Wiki

Angle

  Angle Angle( number pitch = 0, number yaw = 0, number roll = 0 )

Description

Creates an Angle object, representing a Euler Angle made up of pitch, yaw, and roll components.

This function is relatively expensive, in terms of performance, in situations where it is being called multiple times every frame (Like a loop, for example.) This is due to the overhead associated with object creation and garbage collection. Where possible, it is generally better to store an Angle in a variable and re-use that variable rather than re-creating it repeatedly. In cases where an empty Angle is needed, the global variable angle_zero is the preferred solution instead of Angle( 0, 0, 0 ).

Arguments

1 number pitch = 0
This is an Overloaded Function with these available first arguments:

Number pitch = 0
The pitch value of the angle, in degrees. Use this with the second and third arguments.

Angle angle
Creates a new Angle that is a copy of the Angle passed in.

String angleString
Attempts to parse the input String from the Print format of an Angle.
Returns an Angle with its pitch, yaw, and roll set to 0 if the String cannot be parsed.

2 number yaw = 0
The yaw value of the angle, in degrees.
Note: Only valid if the first argument is a Number.
3 number roll = 0
The roll value of the angle, in degrees.
Note: Only valid if the first argument is a Number.

Returns

1 Angle
The newly created Angle

Example

Creates an angle and prints the value to the console.

print( Angle( 1, 2, 3 ) ) print( Angle( "4 5 6" ) ) local test = Angle( 7, 8, 9 ) print( Angle( test ) ) print( Angle( "4 5 test" ) ) print( Angle() )
Output:
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 0.00 0.00 0.00 0.00 0.00 0.00