Garry's Mod Wiki

Angle

  Angle Angle( number pitch, number yaw = 0, number roll = 0 )
  Angle Angle( Angle angle )
  Angle Angle( string angleString )

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 ).

Default Arguments

1 number pitch
The pitch value of the angle, in degrees.
2 number yaw = 0
The yaw value of the angle, in degrees.
3 number roll = 0
The roll value of the angle, in degrees.

Argument Overload: Angle Copy

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

Argument Overload: Parse String

1 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.

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