c4d.Vector4d

New in version R18.020.

Members

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)
Initalizes a new 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:
  • number: All components are set to this number.
  • c4d.Vector: X/Y/Z components of the passed vector are copied to the new vector and W is set 1.
If 2 arguments are passed:
  • The first argument has to be a 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.
If 4 arguments are passed:
  • x, y, z, w have to be floats and are respectively assigned to X/Y/Z/W components.

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:
  • x (Union[int, float, c4d.Vector]) – If x is a number and is the only passed argument, set this to X/Y/Z components. If x is a c4d.Vector, its X/Y/Z components are copied to the new vector. Otherwise set the X component.
  • y (number) – The Y component. If 2 arguments are passed, set to W component.
  • z (number) – The Z component.
  • w (number) – The W component.
Return type:

c4d.Vector4d

Returns:

A new c4d.Vector4d.

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__(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__(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:
  • key (int) – The component index.
  • value (float) – The new value for the c4d.Vector4d component.
Raises:

IndexError – If the index key is out of range : 0<=key<3.

Vector4d.__add__(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__(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__(other)
If other is a 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 (Union[int, float, c4d.Vector]) – The other argument.
Return type:c4d.Vector4d
Returns:The result vector.
Vector4d.__eq__(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__(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()

Scales the vector so that Vector4d.w equals 1.

Vector4d.NormalizeW()

New in version R20.

Scales the vector so that Vector4d.w equals 1.

Vector4d.GetVector3()

Retrieves a c4d.Vector from the c4d.Vector4d.

Return type:c4d.Vector
Returns:The converted c4d.Vector.