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

From Reallusion Wiki!
Jump to: navigation, search
m
m (Detailed Description)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
==Description==
This class represent the 2D vector.
+
 
 +
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:
 +
 
 +
{|class = "wikitable"
 +
!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)
 +
|}
 +
 
 
==Operators==
 
==Operators==
 
This class supports the following operators:
 
This class supports the following operators:

Revision as of 22:43, 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)

Operators

This class supports the following operators:

Member Operation Syntax Description Example
__add__ Addition a + b Adds values on either side of the operator. a + b = 30
__sub__ Subtraction a - b Subtracts right hand operand from left hand operand. a – b = -10
__mul__ Multiplication a * b Multiplies values on either side of the operator. a * b = 200
__truediv__ Division a / b Divides left hand operand by right hand operand. b / a = 2
__eq__ Equality a == b If the values of two operands are equal, then the condition becomes true. (a == b) is not true.
__ne__ Difference a != b If values of two operands are not equal, then condition becomes true. (a != b) is true.
__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.
__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.
__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.
__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.
__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
__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
__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
__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

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