CCentroid:new


The new method constructs a new instance of a CCentroid object. The CCentroid class includes properties that control calculation of centroid positions. Two different constructor overloads are available to create a new CCentroid and initialize the properties.

Syntax

C = CCentroid:new()

C = CCentroid:new( CCentroid2 )

where

 

    Of no arguments are passed, a default CCentroid object is created with properties initialized to default values.

    CCentroid2 is an existing CCentroid object whose properties are used to initialize the new CCentroid object. If you pass something other than nil or another CCentroid—such as a string—then the default constructor is used.

Example

The following script illustrates using the 2 constructors:

 

C1 = CCentroid:new()

-- create CCentroid C1 with defaults

C2 = CCentroid:new( C1 )

-- copy C1 to a new CCentroid C2

C2.bPositive = false

-- change the sign

Printf("C1 sign= %d", C1.bPositive )

-- result: C1 sign = 1

Printf("C2 sign= %d", C2.bPositive )

-- result: C2 sign = 0

Related Topics

delete

CCentroid class