Global/Matrix

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(fix inconsistency)
(fix example)
Line 18: Line 18:
 
{{Example
 
{{Example
 
|Description=Initializes a matrix, translates it by Vector( 4, 5, 6 ) and then scales it by Vector( 1, 2, 3 ).
 
|Description=Initializes a matrix, translates it by Vector( 4, 5, 6 ) and then scales it by Vector( 1, 2, 3 ).
|Code=local M = Matrix( {
+
|Code=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 },
 
{ 1, 0, 0, 4 },
 
{ 0, 2, 0, 5 },
 
{ 0, 2, 0, 5 },

Revision as of 14:49, 20 April 2016

 Matrix( )

Contents

Description

Returns a VMatrix object.

Arguments

table data=nil

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

Returns

VMatrix

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


Personal tools
Navigation