# Global/Matrix

From Garry's Mod

(Difference between revisions)

(fix example) |
(this was wrong) |
||

Line 3: | Line 3: | ||

|Realm=Shared | |Realm=Shared | ||

|IsClass=No | |IsClass=No | ||

− | |||

− | |||

}} | }} | ||

{{Arg | {{Arg | ||

|type=table | |type=table | ||

|name=data | |name=data | ||

− | |desc=Initial data to initialize the matrix with. Leave empty to initialize an | + | |desc=Initial data to initialize the matrix with. Leave empty to initialize an identity matrix. See examples for usage. |

|default=nil | |default=nil | ||

}} | }} |

## Revision as of 00:24, 15 September 2017

## Contents |

# Description

Returns a VMatrix object.

# Arguments

table data=nil

Initial data to initialize the matrix with. Leave empty to initialize an identity matrix. See examples for usage.

# Returns

New matrix.

# Examples

## Example

Initializes a matrix, translates it by Vector( 4, 5, 6 ) and then scales it by Vector( 1, 2, 3 ).

local M = Matrix() M:Translate( Vector( 4, 5, 6 ) ) M:Scale( Vector( 1, 2, 3 ) ) -- This matrix is equivalent: local M2 = Matrix( { { 1, 0, 0, 4 }, { 0, 2, 0, 5 }, { 0, 0, 3, 6 }, { 0, 0, 0, 1 } } )