IC8 Python API:RLPy RVector4
Contents
- 1 Description
- 2 Constructor & Destructor
- 3 Member Functions
- 3.1 AlmostSame (self, vV, fThreshold)
- 3.2 AlmostZero (self)
- 3.3 Dot (self, vV)
- 3.4 Inverse (self)
- 3.5 Length (self)
- 3.6 Normalize (self)
- 3.7 SetW (self, tW)
- 3.8 SetX (self, tX)
- 3.9 SetY (self, tY)
- 3.10 SetZ (self, tZ)
- 3.11 SquaredLength (self)
- 3.12 W (self, *args)
- 3.13 X (self, *args)
- 3.14 XY (self)
- 3.15 XYZ (self)
- 3.16 Y (self, *args)
- 3.17 Z (self, *args)
- 3.18 __add__ (self, vV)
- 3.19 __eq__ (self, vV)
- 3.20 __ge__ (self, vV)
- 3.21 __getitem__ (self, i)
- 3.22 __gt__ (self, vV)
- 3.23 __iadd__ (self, vV)
- 3.24 __imul__ (self, *args)
- 3.25 __isub__ (self, vV)
- 3.26 __itruediv__ (self, *args)
- 3.27 __le__ (self, vV)
- 3.28 __lt__ (self, vV)
- 3.29 __mul__ (self, *args)
- 3.30 __ne__ (self, vV)
- 3.31 __neg__ (self)
- 3.32 __sub__ (self, vV)
- 3.33 __truediv__ (self, *args)
- 4 Properties
- 5 Constants
Description
This class represent a 4D vector (x, y, z, w). This class provides access to RLPy's internal 4D vector math library allowing 4D vectors to be handled easily, and in a manner compatible with internal RLPy data structures. It also supports operators and provides some convenient constants: {| class="wikitable" !Constant !Description |- |RVector4.ZERO |4D zero vector: (0, 0, 0, 0) |- |RVector4.UNIT_X |4D x unit vector: (1, 0, 0, 0) |- |RVector4.UNIT_Y |4D y unit vector: (0, 1, 0, 0) |- |RVector4.UNIT_Z |4D z unit vector: (0, 0, 1, 0) |- |RVector4.UNIT_W |4D w unit vector: (0, 0, 0, 1) |- |RVector4.UNIT_XYZW |4D vector: (1, 1, 1, 1) |}
Constructor & Destructor
__init__ (self, *args)
Initialize a new 4D vector object that is zeroed out: (0, 0, 0, 0).
Parameters
- args
Member Functions
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.
Dot (self, vV)
Calculate dot product with the given vector.
Parameters
- vV
Sample code
Calls `RLPy.RVector4.Dot` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 2, 3, 4)
b = RLPy.RVector4(1, 2, 3, 4)
print(a.Dot(b)) #30.0
Inverse (self)
Invert every element of this 4D vector.
Sample code
Calls `RLPy.RVector4.Inverse` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(0.5, 2, 4, 1)
b = a.Inverse()
print(str(b.x) + ', ' + str(b.y) + ', ' + str(b.z) + ', ' + str(b.w)) # 2.0, 0.5, 0.25, 1.0
Length (self)
Get the length (magnitude) of this 4D vector.
Sample code
Calls `RLPy.RVector4.Length` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
print(a.Length()) # 2.0
Normalize (self)
Normalize this 4D vector.
SetW (self, tW)
Set the value of the w-axis.
Parameters
- tW
Sample code
Calls `RLPy.RVector4.SetW` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
a.SetW(10)
print(str(a.x) + ', ' + str(a.y) + ', ' + str(a.z) + ', ' + str(a.w)) # 1.0, 1.0, 1.0, 10.0
SetX (self, tX)
Set the value of the x-axis.
Parameters
- tX
Sample code
Calls `RLPy.RVector4.SetX` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
a.SetX(10)
print(str(a.x) + ', ' + str(a.y) + ', ' + str(a.z) + ', ' + str(a.w)) # 10.0, 1.0, 1.0, 1.0
SetY (self, tY)
Set the value of the y-axis.
Parameters
- tY
Sample code
Calls `RLPy.RVector4.SetY` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
a.SetY(10)
print(str(a.x) + ', ' + str(a.y) + ', ' + str(a.z) + ', ' + str(a.w)) # 1.0, 10.0, 1.0, 1.0
SetZ (self, tZ)
Set the value of the z-axis.
Parameters
- tZ
Sample code
Calls `RLPy.RVector4.SetZ` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
a.SetZ(10)
print(str(a.x) + ', ' + str(a.y) + ', ' + str(a.z) + ', ' + str(a.w)) # 1.0, 1.0, 10.0, 1.0
SquaredLength (self)
Squared length of this 4D vector.
Sample code
Calls `RLPy.RVector4.SquaredLength` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 1, 1, 1)
print(a.SquaredLength()) # 4.0
W (self, *args)
Returns the w component of this vector.
Parameters
- args
X (self, *args)
Returns the x component of this vector.
Parameters
- args
XY (self)
Get the first 2 elements of this 4D vector (X, Y) as a 2D vector.
Sample code
Calls `RLPy.RVector4.XY` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 2, 3, 4)
b = a.XY()
print(str(b.x) + ', ' + str(b.y)) # 1.0, 2.0
XYZ (self)
Get the first 3 elements of this 4D vector (X, Y, Z) as a 3D vector.
Sample code
Calls `RLPy.RVector4.XYZ` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 2, 3, 4)
b = a.XYZ()
print(str(b.x) + ', ' + str(b.y) + ', ' + str(b.z)) # 1.0, 2.0, 3.0
Y (self, *args)
Returns the y component of this vector.
Parameters
- args
Z (self, *args)
Returns the z component of this vector.
Parameters
- args
__add__ (self, vV)
The "addition" operator. Perform a 4D vector addition. See Also: +=
Parameters
- vV
Sample code
Calls `RLPy.RVector4.__add__` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(0, 1, 2, 3)
b = RLPy.RVector4(1, 2, 3, 4)
c = a + b
print(str(c.x) + ', ' + str(c.y) + ', ' + str(c.z) + ', ' + str(c.w)) # 1.0, 3.0, 5.0, 7.0
__eq__ (self, vV)
Reports whether this value equals another value.
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 4D vector, then the corresponding elements are multiplied. See Also: *=
Parameters
- args
Sample code
Calls `RLPy.RVector4.__mul__` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 2, 3, 4)
b = a * 2
c = a * a
print(str(b.x) + ', ' + str(b.y) + ', ' + str(b.z) + ', ' + str(b.w)) # 2.0, 4.0, 6.0, 8.0
print(str(c.x) + ', ' + str(c.y) + ', ' + str(c.z) + ', ' + str(c.w)) # 1.0, 4.0, 9.0, 16.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 a 4D vector subtraction. See Also: -=
Parameters
- vV
Sample code
Calls `RLPy.RVector4.__sub__` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(0, 1, 2, 3)
b = RLPy.RVector4(3, 2, 1, 0)
c = b - a
print(str(c.x) + ', ' + str(c.y) + ', ' + str(c.z) + ', ' + str(c.w)) # 3.0, 1.0, -1.0, -3.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 4D vector, then the corresponding elements are divided. See Also: /=
Parameters
- args
Sample code
Calls `RLPy.RVector4.__truediv__` with the inputs shown in the example.
def run_script():
import RLPy
a = RLPy.RVector4(1, 2, 3, 4)
b = a / 2
c = RLPy.RVector4(2, 2, 10, 2)
d = a / c
print(str(b.x) + ', ' + str(b.y) + ', ' + str(b.z) + ', ' + str(b.w)) # 0.5, 1.0, 1.5, 2.0
print(str(d.x) + ', ' + str(d.y) + ', ' + str(d.z) + ', ' + str(d.w)) # 0.5, 1.0, 0.3, 2.0
Properties
thisown
Indicates whether this SWIG proxy owns the underlying C++ object.
w
The vector's W component.
x
The vector's X component.
y
The vector's Y component.
z
The vector's Z component.