mgear.core.vector

Functions to work with vectors

class mgear.core.vector.Blade(t=Matrix([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]))

The Blade object for shifter guides

mgear.core.vector.getDistance(v0, v1)

Get the distance between 2 vectors

Parameters:
  • v0 (vector) – vector A.
  • v1 (vector) – vector B.
Returns:

Distance length.

Return type:

float

mgear.core.vector.getDistance2(obj0, obj1)

Get the distance between 2 objects.

Parameters:
  • obj0 (dagNode) – Object A
  • obj1 (dagNode) – Object B
Returns:

Distance length

Return type:

float

mgear.core.vector.getPlaneBiNormal(v0, v1, v2)

Get the binormal vector of a plane (Defined by 3 positions).

Parameters:
  • v0 (vector) – First position on the plane.
  • v1 (vector) – Second position on the plane.
  • v2 (vector) – Third position on the plane.
Returns:

The binormal.

Return type:

vector

mgear.core.vector.getPlaneNormal(v0, v1, v2)

Get the normal vector of a plane (Defined by 3 positions).

Parameters:
  • v0 (vector) – First position on the plane.
  • v1 (vector) – Second position on the plane.
  • v2 (vector) – Third position on the plane.
Returns:

The normal.

Return type:

vector

mgear.core.vector.getTransposedVector(v, position0, position1, inverse=False)

Get the transposed vector.

Parameters:
  • v (vector) – Input Vector.
  • position0 (vector) – Position A.
  • position1 (vector) – Position B.
  • inverse (bool) – Invert the rotation.
Returns:

The transposed vector.

Return type:

vector

>>> normal = vec.getTransposedVector(self.normal,
                                     [self.guide.apos[0],
                                      self.guide.apos[1]],
                                     [self.guide.apos[-2],
                                      self.guide.apos[-1]])
mgear.core.vector.linearlyInterpolate(v0, v1, blend=0.5)

Get the vector interpolated between 2 vectors.

Parameters:
  • v0 (vector) – vector A.
  • v1 (vector) – vector B.
  • blend (float) – Blending value.
Returns:

The interpolated vector.

Return type:

vector

mgear.core.vector.rotateAlongAxis(v, axis, a)

Rotate a vector around a given axis defined by other vector.

Parameters:
  • v (vector) – The vector to rotate.
  • axis (vector) – The axis to rotate around.
  • a (float) – The rotation angle in radians.