Difference between revisions of "IC Python API:RLPy RVector2"

From Reallusion Wiki!
Jump to: navigation, search
m (Detailed Description)
m (Operators)
Line 24: Line 24:
 
|}
 
|}
  
==Operators==
+
==Constructor & Destructor==
This class supports the following operators:
+
 
{| class="wikitable"
+
===__init__===
!Member
+
 
!Operation
+
Initialize a new RVector2 object as a 2D zero vector: (0, 0).
!Syntax
+
 
!Description
+
<syntaxhighlight lang="Python">
!Example
+
a = RLPy.RVector2()
|-
+
</syntaxhighlight>
! scope="row"|__add__
+
 
|Addition
+
----
|a + b
+
 
|Adds values on either side of the operator.
+
===__init__( self, x, y )===
|a + b = 30
+
 
|-
+
Initialize a new RVector2 object as a 2D vector: (x, y).
! scope="row"|__sub__
+
 
|Subtraction
+
<syntaxhighlight lang="Python">
|a - b
+
a = RLPy.RVector2(1, 2)
|Subtracts right hand operand from left hand operand.
+
</syntaxhighlight>
|a – b = -10
+
 
|-
+
====Parameters====
! scope="row"|__mul__
+
 
|Multiplication
+
x  [IN]    a numerical value for x coordinate - float or int<br/>
|a * b
+
y  [IN]    a numerical value for y coordinate - float or int<br/>
|Multiplies values on either side of the operator.
+
 
|a * b = 200
+
----
|-
+
 
! scope="row"|__truediv__
+
===__init__( self, args )===
|Division
+
 
|a / b
+
Initialize a new RVector2 object with another RVector2 object: args. This new RVector2 object has the same value as args.
|Divides left hand operand by right hand operand.
+
 
|b / a = 2
+
<syntaxhighlight lang="Python">
|-
+
 
! scope="row"|__eq__
+
a = RLPy.RVector2(1, 2)
|Equality
+
b = RLPy.RVector2(a)
|a == b
+
 
|If the values of two operands are equal, then the condition becomes true.
+
</syntaxhighlight>
|(a == b) is not true.
+
 
|-
+
! scope="row"|__ne__
+
|Difference
+
|a != b
+
|If values of two operands are not equal, then condition becomes true.
+
|(a != b) is true.
+
|-
+
! scope="row"|__gt__
+
|Greater Than
+
|a > b
+
|If the value of left operand is greater than the value of right operand, then condition becomes true.
+
|(a > b) is not true.
+
|-
+
! scope="row"|__lt__
+
|Less Than
+
|a < b
+
|If the value of left operand is less than the value of right operand, then condition becomes true.
+
|(a < b) is true.
+
|-
+
! scope="row"|__ge__
+
|Greater Than or Equal
+
|a >= b
+
|If the value of left operand is greater than or equal to the value of right operand, then condition becomes true.
+
|(a >= b) is not true.
+
|-
+
! scope="row"|__le__
+
|Less or Equal
+
|a <= b
+
|If the value of left operand is less than or equal to the value of right operand, then condition becomes true.
+
|(a <= b) is true.
+
|-
+
! scope="row"|__iadd__
+
|Addition (Inplace)
+
|a += b
+
|It adds right operand to the left operand and assign the result to left operand.
+
|c += a is equivalent to c = c + a
+
|-
+
! scope="row"|__isub__
+
|Subtraction (Inplace)
+
|a -= b
+
|It subtracts right operand from the left operand and assign the result to left operand.
+
|c -= a is equivalent to c = c - a
+
|-
+
! scope="row"|__imul__
+
|Multiply (Inplace)
+
|a *= b
+
|It multiplies right operand with the left operand and assign the result to left operand.
+
|c *= a is equivalent to c = c * a
+
|-
+
! scope="row"|__itruediv__
+
|Divide (Inplace)
+
|a /= b
+
|It divides left operand with the right operand and assign the result to left operand.
+
|c /= a is equivalent to c = c / ac /= a is equivalent to c = c / a
+
|}
+
 
==Member Functions==
 
==Member Functions==
 
===AddWithWeight===
 
===AddWithWeight===

Revision as of 22:50, 19 February 2020

Main article: Modules.

Description

2D Vector math class for float values. This class provides access to RLPy's internal vector math library allowing vectors to be handled effortlessly, and in a manner compatible with internal RLPy data structures. It also supports operators and vector related functions.

RVector2 also provides some constants for your convenience:

Constant Description
RVector2.ZERO 2D zero vector: (0, 0)
RVector2.UNIT_X 2D x unit vector: (1, 0)
RVector2.UNIT_Y 2D y unit vector: (0, 1)
RVector2.UNIT_XY 2D vector: (1, 1)

Constructor & Destructor

__init__

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

a = RLPy.RVector2()

__init__( self, x, y )

Initialize a new RVector2 object as a 2D vector: (x, y).

a = RLPy.RVector2(1, 2)

Parameters

x [IN] a numerical value for x coordinate - float or int
y [IN] a numerical value for y coordinate - float or int


__init__( self, args )

Initialize a new RVector2 object with another RVector2 object: args. This new RVector2 object has the same value as args.

a = RLPy.RVector2(1, 2)
b = RLPy.RVector2(a)

Member Functions

AddWithWeight

RLPy.RVector2.AddWithWeight ( self, vSrc, fWeight )

Add a vector with weight.

Parameters

vSrc [IN] The vector to add - RLPy.RVector2

fWeight [IN] The value of weight - float


Dot

RLPy.RVector2.Dot ( self, vV )

Calculate dot production of the two vectors.

Parameters

vV [IN] The vector - RLPy.RVector2

Returns

The value of the dot production - float

Inverse

RLPy.RVector2.Inverse ( self )

Inverse this vector.

Returns

The inversed vector - RLPy.RVector2

Length

RLPy.RVector2.Length ( self )

Length of the vector.

Returns

The length of this vector - float

Normalize

RLPy.RVector2.Normalize ( self )

Normalizes this vector.

Returns

The normalized vector - float

SetX

RLPy.RVector2.SetX ( self, tX )

Set the value of the x-axis.

Parameters

tX [IN] the value of the x-axis - float


SetY

RLPy.RVector2.SetY ( self, tY )

Set the value of the y-axis.

Parameters

tX [IN] the value of the y-axis.


SquaredLength

RLPy.RVector2.SquaredLength ( self )

Squared length of the vector.

Returns

The squared length of this vector - float

X

RLPy.RVector2.X ( self, args )

Get the value of the x-axis.

Returns

The value of the x-axis - float

Y

RLPy.RVector2.Y ( self, args )

Get the value of the y-axis.

Returns

The value of the y-axis - float