CMatrix:Copy
The Copy method duplicates the current CMatrix and returns the new object.
M = CMatrix:Copy() |
M is a new CMatrix containing the same values as the current one.
This method copies an existing CMatrix and returns a reference to the new CMatrix. You cannot copy a CMatrix or other class object using the trivial statement B = A, as this simply makes the value of B a reference to the object A. In other words, B becomes an alias to A. To get around this, two copy methods are provided by the CMatrix class:
To create a CMatrix that is a copy of the current object, use the Copy method. This creates a new CMatrix B before duplicating the values of the current object A. For example,
|
-- CMatrix A already exists |
To create a new CMatrix that is a copy of an existing object, use the copy constructor, as in
|
-- CMatrix A already exists |
You can use the copying syntax that fits best with your script.
The following script duplicates the CMatrix M into a new CMatrix M2:
|
-- create a CMatrix |
|
-- set member 2, 44 |
|
-- set member 50, 20 |
|
-- set member 120, 2 |
|
-- creates a duplicate CMatrix M2 |
|
-- result: N = 3 |
|
-- if finished with M, clean up memory |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.