CCentroid:new
The new method constructs a new instance of a CCentroid object. The CCentroid class includes data members that control calculation of centroid positions. Two different constructor overloads are available to create a new CCentroid and initialize the data members.
C = CCentroid:new() Creates a default CCentroid with data members initialized to default values. C = CCentroid:new( CCentroid2 ) This is a copy constructor. It creates a new CCentroid C initialized to the members of the CCentroid2 argument. |
Two overloads are provided for the CCentroid class. They create a default CCentroid and a copy of a CCentroid. If you pass something other than nil or another CCentroid—such as a string—then the default constructor is used.
The following script fragment illustrates using the 2 constructors. All produce the same result:
C1 = CCentroid:new() |
-- create CCentroid C1 and set values |
C1:SetSign(false) |
-- change the default sign |
C2 = CCentroid:new( C1 ) |
-- copy C1 to a new CCentroid C2 |
Printf("C1 sign = %d", C1:GetSign() ) |
-- result: C1 sign = 0 |
Printf("C2 sign = %d", C2:GetSign() ) |
-- result: C2 sign = 0 |