paya.runtime.plugs.Vector#

class Vector(*args, **kwargs)#

Inheritance

Math Attribute Attribute PyNode ProxyUnicode

classmethod createAttr(attrName, node=None, angle=False, time=False, distance=False, keyable=None, channelBox=None, defaultValue=None, asData=False, childSuffixes='XYZ')#
Creates a Vector,

Point or EulerRotation attribute.

Parameters
  • attrName (str) – the attribute name

  • node (str, DependNode) – the node on which to add the attribute; if omitted, a network node will be created; defaults to None

  • angle/a (bool) – create an EulerRotation; defaults to False

  • time/t (bool) – create a compound of three time channels; defaults to False

  • distance/d (bool) – create a Point; defaults to False

  • keyable/k (bool) – make the children keyable; ignored if asData; defaults to False

  • channelBox/cb (bool) – make the children settable; ignored if asData; defaults to False

  • defaultValue/dv (list [float], Vector, Point, EulerRotation) – a default value for the attribute (ignored if asData)

  • asData/ad (bool) – create as a non-compound ‘data’ attribute

  • childSuffixes/cs (bool) – ignored if asData; suffixes for the child attributes

Returns

The constructed attribute.

Return type

Vector, Point, EulerRotation

createLocator(name=None, size=1.0)#
Shorthand

cl

Parameters
  • name/n (str) – an optional name for the locator transform; defaults to a contextual name

  • size/siz (float) – a single scalar for the locator’s localScale channels; defaults to 1.0

Returns

A locator with this 3D compound piped into its translate channel.

Return type

Transform

isTranslateChannel()#
Returns

True if this is the translate channel of a transform node, otherwise False.

Return type

bool

get(plug=False, **kwargs)#

Overrides get() to return Point values if this is the translate channel of a transform node.

__add__(other, swap=False)#

Implements element-wise addition (+).

__radd__(other)#

Implements element-wise reflected addition (-).

__sub__(other, swap=False)#

Implements element-wise subtraction (-).

__rsub__(other)#

Implements element-wise reflected subtraction (-).

__mul__(other, swap=False)#

Implements multiplication (*).

__rmul__(other)#

Implements reflected multiplication (*).

__neg__()#

Implements element-wise unary negation (-).

__truediv__(other, swap=False)#

Implements element-wise division (/).

__rtruediv__(other)#

Implements element-wise reflected division (/).

__pow__(other, swap=False)#

Implements element-wise power (**).

__rpow__(other)#

Implements element-wise reflected power (**).

blend(other, weight=0.5, swap=False, includeLength=False, clockNormal=None, unwindSwitch=None)#

Blends this triple towards other. Blending will be linear or, if clockNormal is provided, by vector angle.

Parameters
  • other (list [float], Vector, Math3D, str) – the triple or vector towards which to blend

  • weight/w (str, float, Math1D) – 0.5: the blending weight; when this is 1.0, other will take over fully; can be a value or plug; defaults to 0.5

  • swap/sw (bool) – swap the inputs around; defaults to False

  • clockNormal/cn (list [float], Vector, Math3D, str) – if this is True, this output and other will be regarded as vectors, and blended by angle; should be a vector perpendicular to both inputs; defaults to None

  • includeLength/ilg (bool) – ignored if clockNormal was omitted; include vector lengths in the blending calculation; defaults to False

  • unwindSwitch/uws (int, str, Math1D) –

    ignored if clockNormal was omitted; an integer value or plug to pick an angle unwinding mode:

    • 0 for shortest (the default)

    • 1 for positive

    • 2 for negative

Returns

The blended triple or vector.

Return type

paya.runtime.plugs.Math3D

__xor__(other)#

Uses the exclusive-or operator (^) to implement point-matrix multiplication.

Parameters

other – a matrix value or plug

length()#
Returns

The length of this vector.

Return type

Math1D

normal()#
Returns

This vector, normalized.

Return type

Vector

dot(other, normalize=False)#

Returns the dot product of self and other.

Parameters
  • other (list, tuple, Math3D) – the other vector

  • normalize/nr (bool) – normalize the output; defaults to False

Returns

paya.runtime.plugs.Math1D

cross(other, normalize=False, guard=False, inlineGate=None)#
Parameters
  • other (tuple, list, str, Vector, Vector) – the other vector

  • normalize/nr (bool) – normalize the output; defaults to False

  • guard/g (bool) – switch the node to 'No Operation' when the input vectors are aligned in either direction; defaults to False

  • inlineGate/ig (bool) – if you have a precooked gate for alignment (typically the output of a comparison operation), provide it here to prevent redundant checks; if provided, will override guard to True; defaults to None

Returns

The cross product.

Return type

Vector

angleTo(other, clockNormal=None)#
Parameters
Returns

The angle from this vector to other.

Return type

Angle

projectOnto(other)#

See https://en.wikipedia.org/wiki/Vector_projection.

Parameters

other (list, tuple, str, Vector, Vector) – the vector onto which to project this one

Returns

The project of this vector onto other.

Return type

Vector

rejectFrom(other)#

Same as ‘make perpendicular to’ (although length will change). See https://en.wikipedia.org/wiki/Vector_projection.

Parameters

other (list, tuple, str, Vector, Vector) – the vector from which to reject this one

Returns

The rejection of this vector from other.

Return type

Vector

rotateByAxisAngle(axisVector, angle)#
Parameters
  • axisVector (list, tuple, Vector or Vector) – the vector around which to rotate this vector

  • angle (float, Angle, str or class:~paya.runtime.plugs.Math3D) – the angle of rotation

Returns

This vector, rotated around axisVector by the specified angle.

Return type

Vector

asTranslateMatrix()#

Inserts this into the translate row of an identity matrix, and returns the matrix.

Returns

The translate matrix.

Return type

Matrix

asScaleMatrix()#

Uses this output’s three components as the magnitudes of an identity matrix’s base vectors.

Returns

The scale matrix.

Return type

Matrix

asRotateMatrix()#
Returns

This vector’s orientation as a rotate matrix.

Return type

Matrix

asShearMatrix()#

Composes this output’s three components into a shear matrix.

Returns

The shear matrix.

Return type

Matrix

asEulerRotation()#

Returns XYZ euler rotations for this vector.

Returns

A compound of three euler channels.

Return type

EulerRotation

asQuaternion()#
Returns

A quaternion representation of this vector’s orientation.

Return type

Quaternion

asAxisAngle()#
Returns

An axis, angle representation of this vector.

Return type

tuple (Vector, Angle)