bgdev.utils.vector¶
Utility methods to help dealing with vectors.
- created
10/10/2016
- author
Benoit GIELLY <benoit.gielly@gmail.com>
-
aim_in_plane
(positions, aim_vector=(1, 0, 0), up_vector=(0, 1, 0))[source]¶ Align selected locators based on plane made of the first and last.
-
from_euler
(rotation, translate=(0, 0, 0), radians=False)[source]¶ Convert euler rotation into 3-axis matrix.
- Parameters
rotation (tuple) – Rotation values to add to the matrix table.
translate (tuple) – Translation values to add to the matrix table.
radians (bool) – If True, converts degrees to radians.
- Returns
Matrix of given euler rotates, with translate if given.
- Return type
list
-
get_closest_point
(source, targets, furthest=False)[source]¶ Find the closest node to the source of each targets.
- Parameters
source (str) – source node to use as starting point for distance calculation.
targets (list) – each nodes to process.
furthest (bool) – If True, gets the furthest node instead.
- Returns
the target node that’s the closest to the source.
- Return type
str
-
get_distance_between
(node1, node2, distance_between=False, bounding_box=False, rotate_pivot=False)[source]¶ Get the distance between two objects.
- Parameters
node1 (str) – Node that determines start position
node2 (str) – Node that determines end position
distance_between (bool) – If True, creates a distance_between node, query its value and delete it.
bounding_box (bool) – If True, creates a distance_between node,
rotate_pivot (bool) – If True, creates a distance_between node,
- Returns
distance between two given nodes.
- Return type
float
-
get_manipulator_xforms
(as_matrix=False)[source]¶ Query the manipulator position and orientation.
- Parameters
as_matrix (bool) – if True, returns a as_matrix built from manip xforms.
- Returns
- list of “XYZ” position and rotation values
or matrix array if as_matrix is True.
- Return type
list
-
get_matrix_from_nodes
(nodes, middle=True, aim_vector=(1, 0, 0), up_vector=(0, 1, 0))[source]¶ Return a matrix based on given nodes.
If passed nodes are 1 or more than 3, it simply return the manipulator position as a matrix. Otherwise, it’ll use the second node as the aim axis and the third as up.
- Parameters
nodes (list) – list of nodes to get matrix
middle (bool) – snap in between nodes 1 and 2 if True, else on first.
aim_vector (tuple) – default aim vector for the aimConstraint.
up_vector (tuple) – default up vector for the aimConstraint.
- Returns
matrix array.
- Return type
list
-
get_matrix_from_transforms
(position, normal, tangent)[source]¶ Construct an MMatrix from position, normal and tangent.
- Parameters
position (list) – XYZ position.
normal (list) – The normal vector used to compute rotation.
tangent (list) – The tangent vector used to compute rotation.
- Returns
The MMatrix array.
- Return type
MMatrix
-
get_vectors
(nodes, mode='xform')[source]¶ Generate world position vectors of each given nodes.
- Parameters
nodes (list) – list of nodes to return position as vector.
mode (str) – choose between default “xform” or “pivot” to get world position.
- Yields
maya.api.OpenMaya.MVector – MVector of the node’s world position