IC8 Python API:RLPy RVector2

From Reallusion Wiki!
Jump to: navigation, search

Contents

Description

This class represents a 2D vector (x, y). This class provides access to RLPy's internal 2D vector math library allowing 2D vectors to be handled easily, in a manner compatible with internal RLPy data structures. It also supports operators and provides some constants for your convenience: {|class = "wikitable" !Constant !Description |- |RVector2.ZERO |2D zero vector2: (0, 0) |- |RVector2.UNIT_X |2D x unit vector2: (1, 0) |- |RVector2.UNIT_Y |2D y unit vector2: (0, 1) |- |RVector2.UNIT_XY |2D unit vector2: (1, 1) |}

Constructor & Destructor

__init__ (self, *args)

Initialize a new RVector2 object as a zeroed 2D vector: (0, 0).

Parameters

  • args

Member Functions

AddWithWeight (self, vSrc, fWeight)

Add this and another 2D vector with weighting.

Parameters

  • vSrc
  • fWeight

Sample code

Calls `RLPy.RVector2.AddWithWeight` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(0, 1)
    b = RLPy.RVector2(1, 2)
    a.AddWithWeight(b, 2)

    print(str(a.x) + ', ' + str(a.y)) # 2.0, 5.0

AlmostSame (self, vV, fThreshold)

Reports whether this vector is approximately equal to another vector.

Parameters

  • vV
  • fThreshold

AlmostZero (self)

Reports whether this vector is approximately zero.

Clear (self)

Sets both components of this vector to zero.

Dot (self, vV)

Calculate dot production of the two vectors.

Parameters

  • vV

Sample code

Calls `RLPy.RVector2.Dot` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 2)
    dot = a.Dot( RLPy.RVector2(3, 5) )

    print(dot) #13.0

Inverse (self)

Return the inverse of this 2D vector by inverting its x, y elements.

Sample code

Calls `RLPy.RVector2.Inverse` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(0.5, 4)
    b = a.Inverse()

    print(str(b.x) + ', ' + str(b.y)) # 2.0, 0.25

Length (self)

Get the length of this 2D vector.

Sample code

Calls `RLPy.RVector2.Length` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(3, 4)

    print( str(a.Length()) ) # 5.0

Normalize (self)

Normalize this 2D vector.

Sample code

Calls `RLPy.RVector2.Normalize` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 1)
    b = a.Normalize()

    print(str(a.x) + ', ' + str(a.y)) # 0.7071067690849304, 0.7071067690849304
    print(b) # 1.4142135381698608

SetX (self, tX)

Set the value of the x-axis on this 2D vector.

Parameters

  • tX

Sample code

Calls `RLPy.RVector2.SetX` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 1)
    a.SetX(10)

    print(str(a.x) + ', ' + str(a.y)) # 10.0, 1.0

SetY (self, tY)

Set the value of the y-axis on this 2D vector.

Parameters

  • tY

Sample code

Calls `RLPy.RVector2.SetY` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 1)
    a.SetY(10)

    print(str(a.x) + ', ' + str(a.y)) # 1.0, 10.0

SquaredLength (self)

Get the squared length of this 2D vector.

Sample code

Calls `RLPy.RVector2.SquaredLength` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 1)

    print(a.SquaredLength()) # 2.0

X (self, *args)

Returns the x component of this vector.

Parameters

  • args

Y (self, *args)

Returns the y component of this vector.

Parameters

  • args

__add__ (self, vV)

The "addition" operator. Perform 2D vector addition. See Also: +=

Parameters

  • vV

Sample code

Calls `RLPy.RVector2.__add__` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(0, 1)
    b = RLPy.RVector2(1, 2)
    c = a + b

    print(str(c.x) + ', ' + str(c.y)) # 1.0, 3.0

__eq__ (self, vV)

The "equal to" operator. See Also: !=

Parameters

  • vV

__ge__ (self, vV)

Reports whether this value is greater than or equal to another value.

Parameters

  • vV

__getitem__ (self, i)

Returns the element at the specified index.

Parameters

  • i

__gt__ (self, vV)

Reports whether this value is greater than another value.

Parameters

  • vV

__iadd__ (self, vV)

Adds another value to this value in place.

Parameters

  • vV

__imul__ (self, *args)

Multiplies this value by another value in place.

Parameters

  • args

__isub__ (self, vV)

Subtracts another value from this value in place.

Parameters

  • vV

__itruediv__ (self, *args)

Divides this value by another value in place.

Parameters

  • args

__le__ (self, vV)

Reports whether this value is less than or equal to another value.

Parameters

  • vV

__lt__ (self, vV)

Reports whether this value is less than another value.

Parameters

  • vV

__mul__ (self, *args)

The "multiplication" operator. Perform a scalar multiplication when the second operand is an integer or float. If the second operand is another 2D vector, then the corresponding elements are multiplied. See Also: *=

Parameters

  • args

Sample code

Calls `RLPy.RVector2.__mul__` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 2)
    b = a * 2
    c = RLPy.RVector2(2, 3)
    d = a * c

    print(str(b.x) + ', ' + str(b.y)) # 2.0, 4.0
    print(str(d.x) + ', ' + str(d.y)) # 2.0, 6.0

__ne__ (self, vV)

The "not equal to" operator. See Also: ==

Parameters

  • vV

__neg__ (self)

Returns the negated value.

__sub__ (self, vV)

The "subtraction" operator. Perform 2D vector subtraction. See Also: -=

Parameters

  • vV

Sample code

Calls `RLPy.RVector2.__sub__` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(0, 1)
    b = RLPy.RVector2(1, 3)
    c = b - a

    print(str(c.x) + ', ' + str(c.y)) # 1.0, 2.0

__truediv__ (self, *args)

The "division" operator. Perform a scalar division when the second operand is an integer or float. If the second operand is another 2D vector, then the corresponding elements are divided. See Also: /=

Parameters

  • args

Sample code

Calls `RLPy.RVector2.__truediv__` with the inputs shown in the example.

def run_script():
    import RLPy
    a = RLPy.RVector2(1, 2)
    b = a / 2
    c = RLPy.RVector2(2, 3)
    d = a / c

    print(str(b.x) + ', ' + str(b.y)) # 0.5, 1.0
    print(str(d.x) + ', ' + str(d.y)) # 0.5, 0.6666666865348816

Properties

thisown

Indicates whether this SWIG proxy owns the underlying C++ object.

x

The vector's X coordinate.

y

The vector's Y coordinate.

Constants

COUNT

DIMENSION

UNIT_X

UNIT_XY

UNIT_Y

ZERO