c4d.Vector4d
¶
New in version R18.020.
c4d.
Vector4d
¶
Vector4d.__init__()
Class Constructor
Vector4d.__str__()
Function
str()
Vector4d.__getitem__()
Operator [] Get
Vector4d.__setitem__()
Operator [] Set
Vector4d.__add__()
Operator +
Vector4d.__sub__()
Operator -
Vector4d.__mul__()
Operator *
Vector4d.__eq__()
Operator ==
Vector4d.__ne__()
Operator !=
Vector4d.
x
¶
X component of the vector.
Type: float
Vector4d.
y
¶
Y component of the vector.
Type: float
Vector4d.
z
¶
Z component of the vector.
Type: float
Vector4d.
w
¶
W component of the vector.
Type: float
Vector4d.
__init__
(
[
x
[
,
y
,
z
,
w
]
]
)
¶
Vector4d
.
All arguments are optional so it is possible to create a new vector without any arguments. X/Y/Z components are simply
0
and W
1
.
If only 1 argument is passed, it can be either a number or
c4d.Vector
:
c4d.Vector
: X/Y/Z components of the passed vector are copied to the new vector and W is set
1
.
c4d.Vector
and the second one a number. X/Y/Z components of the passed vector are copied to the new vector and W is set the number argument.
c4d.Vector4d() # => Vector4d(0,0,0,1) c4d.Vector4d(5) # => Vector4d(5, 5, 5, 5) v = c4d.Vector4d(5, 5, 5) c4d.Vector4d(v) # => Vector4d(5, 5, 5, 1) c4d.Vector4d(v, 2) # => Vector4d(5, 5, 5, 2) c4d.Vector4d(1, 2, 3, 4) # => Vector4d(1, 2, 3, 4)
Parameters: |
|
---|---|
Return type: | |
Returns: |
A new
|
Vector4d.
__str__
(
)
¶
Returns a string representation of the
c4d.Vector4d
. Called if
str()
is wrapped around a
c4d.Vector4d
object. (See
__str__
):
v = c4d.Vector4d(3.0, 4.0, 2.0, 5.0) print v # => Vector4d(3, 4, 2, 5)
Return type: | str |
---|---|
Returns: |
The
c4d.Vector4d
as string.
|
Vector4d.
__getitem__
(
self
,
key
)
¶
Retrieves X/Y/Z/W components by index:
v = c4d.Vector4d(1, 2, 3, 4) x = v[0] y = v[1] z = v[2] w = v[3] print x, y, z, w # => 1.0 2.0 3.0 4.0
Parameters: | key ( int ) – The component index. |
---|---|
Raises: | IndexError – If the index key is out of range : 0<=key<3 . |
Return type: | float |
Returns: |
The
c4d.Vector4d
component.
|
Vector4d.
__setitem__
(
self
,
key
,
value
)
¶
Assigns X/Y/Z/W components by index:
v = c4d.Vector4d(1, 2, 3, 4) v[3] = 0 print v # => Vector4d(1, 2, 3, 0)
Note
The
c4d.Vector4d
objects does not support item deletion. For instance by calling
del(v[0])
.
Parameters: |
|
---|---|
Raises: |
IndexError – If the index key is out of range : 0<=key<3 . |
Vector4d.
__add__
(
self
,
other
)
¶
Adds another
c4d.Vector4d
to the
c4d.Vector4d
:
c4d.Vector4d(1,2,3,4)+c4d.Vector4d(2,3,4,5) # => Vector4d(3, 5, 7, 9)
Parameters: |
other
(
c4d.Vector4d
) – The other vector.
|
---|---|
Return type: |
c4d.Vector4d
|
Returns: | The result vector. |
Vector4d.
__sub__
(
self
,
other
)
¶
Subtracts another
c4d.Vector4d
from the
c4d.Vector4d
:
c4d.Vector4d(1, 2, 3, 4)-c4d.Vector4d(2, 3, 4, 5) # => Vector4d(-1, -1, -1, -1)
Parameters: |
other
(
c4d.Vector4d
) – The other vector.
|
---|---|
Return type: |
c4d.Vector4d
|
Returns: | The result vector. |
Vector4d.
__mul__
(
self
,
other
)
¶
c4d.Vector4d
, multiplies each vector component in the left-hand vector by its counterpart in the right-hand vector and returns the vector result.
If
other
is a number, multiplies each vector components by the scalar and returns the vector result.
c4d.Vector4d(1, 2, 3, 4)*c4d.Vector4d(2, 3, 4, 5) # => Vector4d(2, 6, 12, 20) c4d.Vector4d(1, 2, 3, 4)*5 # => Vector4d(5, 10, 15, 20)
Parameters: |
other
(
c4d.Vector4d
or number) – The other argument.
|
---|---|
Return type: |
c4d.Vector4d
|
Returns: | The result vector. |
Vector4d.
__eq__
(
self
,
other
)
¶
Checks if 2 vectors are equal.
Parameters: |
other
(
c4d.Vector4d
) – The other vector.
|
---|---|
Return type: | bool |
Returns: | True if both vectors are equal, otherwise False . |
Vector4d.
__ne__
(
self
,
other
)
¶
Check if 2 vectors are not equal.
Parameters: |
other
(
c4d.Vector4d
) – The other vector.
|
---|---|
Return type: | bool |
Returns: | True if both vectors are not equal, otherwise False . |
Vector4d.
SetZero
(
)
¶
Sets all vector components to zero.
Vector4d.
Dot
(
b
)
¶
Calculates the dot product of the
c4d.Vector4d
and
c4d.Vector4d
b
.
Parameters: |
b
(
c4d.Vector4d
) – The other vector.
|
---|---|
Return type: | float |
Returns: | The dot product. |
Vector4d.
MakeVector3
(
)
¶
Normalizes the vector so that
Vector4d.w
is
1
.
Note
Vector4d.w
must not be
0
.
Vector4d.
GetVector3
(
)
¶
Retrieves a
c4d.Vector
from the
c4d.Vector4d
.
Return type: |
c4d.Vector
|
---|---|
Returns: |
The converted
c4d.Vector
.
|