eMath#

_images/as_eMath.jpg

eMath Features

:Advanced Math Module:

The eMath module, specifically developed for Autodesk Maya and VFX applications, focuses on enhancing mathematical functionalities in rigging scripts. Here’s a simplified overview with four key points:

  1. Complex Mathematical Functions: eMath provides advanced mathematical operations essential for intricate rigging and animation tasks in Maya.

  2. Geometry and Spatial Calculations: The module includes algorithms for precise geometry calculations, crucial for accurate modeling and rigging in 3D space.

  3. Optimized Vector and Matrix Operations: eMath offers efficient support for vector and matrix operations, fundamental in 3D animation and rig manipulation.

  4. Scripting Support for Rigging Calculations: The module integrates complex mathematical calculations into rigging scripts, streamlining the rigging process in Maya.

eMath.__init__(self)#

To Support main auto rig scripts via “eMath”

as_eMathMain_v1.2

About

Author: (Subbaiah) Subbu Addanki
Character Supervisor (Rigging) & Programmer

Visit

http://www.pythonscripting.com
http://subbuadd.blogspot.com

Contact

Mail Id: subbu.add@gmail.com
Mobile No: +91-9741454400 / +91-9949005359

Copyright (c) as_eMathMain

** (Subbaiah) Subbu Addanki. All Rights Reserved. **
eMath.as_eMath(self)#

To Support main scripts with repetitive tasks via eMath

eMath.buildMatrix(self, translate=(0, 0, 0), xAxis=(1, 0, 0), yAxis=(0, 1, 0), zAxis=(0, 0, 1), **shArgs)#

[shArgs : t=translate, xa=xAxis, ya=yAxis, za=zAxis]

Purpose:

:: Constructs a transformation matrix from translation and axis vectors. This function builds a transformation matrix given translation values and vectors defining the X, Y, and Z axes.

Parameters:
  • translate<tuple/list> #Translation values for the matrix.

  • xAxis<tuple/list> #Vector defining the X-axis of the matrix.

  • yAxis<tuple/list> #Vector defining the Y-axis of the matrix.

  • zAxis<tuple/list> #Vector defining the Z-axis of the matrix.

Returns:

<MMatrix> #The constructed transformation matrix.

If shArgs provided
If shArgs not provided
( Start)
/ Check shArgs
/ Update Translate
/ Update XAxis
/ Update YAxis
/ Update ZAxis
/ Create Transformation Matrix
/ Set XAxis Values
/ Set YAxis Values
/ Set ZAxis Values
/ Set Translate Values
/ Return Matrix
End
Flow Chart Description:

This flowchart illustrates the buildMatrix function:

  • Checks if shArgs exist, and if so, updates the translate, xAxis, yAxis, and zAxis values from it.

  • If shArgs do not exist, initializes parameters with default values.

  • Creates a transformation matrix based on the input vectors translate, xAxis, yAxis, and zAxis.

eMath.closestPointOnLine(self, pnt, lineA, lineB, clampSegment=False, **shArgs)#

[shArgs : pnt=p, lineA=la, lineB=lb, clampSegment=cs]

Purpose:

:: Identifies the closest point on a line segment to a given point. This function determines the nearest point on a line, defined by two points, to a third point. It optionally allows clamping to the segment between the two defining points.

Parameters:
  • pnt – (<type list>) # The point to find the closest position to, represented as a list of three numbers.

  • lineA – (<type list>) # Start point of the line segment.

  • lineB – (<type list>) # End point of the line segment.

  • clampSegment – (<type bool>, optional) # Whether to clamp the closest point to the segment defined by lineA and lineB.

Returns:

(<type list>) # The closest point on the line to pnt, returned as a list of three numbers.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> closest_point = closestPointOnLine([1.0, 2.0, 3.0], [0.0, 0.0, 0.0], [2.0, 2.0, 2.0], True) >>> print(closest_point) [1.0, 1.0, 1.0]

If shArgs provided
If shArgs not provided
If Clamp Segment
If dot < 0.0
If dot > 1.0
If Not Clamp Segment
( Start)
/ Check shArgs
/ Update Pnt
/ Update LineA
/ Update LineB
/ Update Clamp Segment
/ Calculate Vector Offsets
/ Perform Vector Comparison
/ Check Clamp Segment
/ Clamp Dot Product
/ Check Dot Product
/ Return LineA
/ Return LineB
/ Project Vector
/ Return Closest Point
End
Flow Chart Description:

This flowchart illustrates the closestPointOnLine function:

  • Checks if shArgs exist, and if so, updates the pnt, lineA, lineB, and clampSegment values from it.

  • If shArgs do not exist, uses the provided parameters.

  • Calculates vector offsets.

  • Performs a vector comparison and calculates the dot product.

  • Checks if the segment needs to be clamped.

  • Projects the vector if not clamped and returns the closest point on the line.

eMath.dotProduct(self, vector1=[0, 0, 0], vector2=[0, 0, 0], **shArgs)#

[shArgs : vector1=v1, vector2=v2]

Purpose:

:: Calculates the dot product of two vectors. This function computes the dot product, a scalar value, of two vectors. It’s a measure of the extent to which two vectors are parallel.

Parameters:
  • vector1 – (<type list>) # The first vector for the dot product operation, represented as a list of three numbers.

  • vector2 – (<type list>) # The second vector for the dot product operation, similar in format to vector1.

Returns:

(<type float>) # Returns the scalar dot product of the two vectors.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = dotProduct([1.0, 2.0, 3.0], [2.0, 3.0, 4.0]) >>> print(result) 20.0

If shArgs provided
If shArgs not provided
( Start)
/ Check shArgs
/ Update Vector1
/ Update Vector2
/ Convert Vector1 to MVector
/ Convert Vector2 to MVector
/ Calculate Dot Product
/ Return Dot Product
End
Flow Chart Description:

This flowchart illustrates the dotProduct function:

  • Checks if shArgs exist, and if so, updates the vector1 and vector2 values from it.

  • If shArgs do not exist, uses the provided parameters.

  • Converts the input vectors to MVector objects.

  • Calculates the dot product of the two vectors and returns the result as a float.

eMath.getMatrix(self, transform, local=False, time=None, **shArgs)#

[shArgs : t=transform, l=local, tm=time]

Purpose:

:: Retrieves the transformation matrix of a given object, with options for local space and specific time. This function extracts the transformation matrix of a specified object, either in world or local space, and optionally at a specific time frame.

Parameters:
  • transform<str> #The transform object from which to get the matrix.

  • local<bool, optional> #Determines whether to retrieve the local space matrix instead of the world space matrix. Defaults to False.

  • time<int/float, optional> #The specific frame to get the matrix for. If not provided, the current frame is used.

Returns:

<MMatrix> #The transformation matrix of the specified object.

If shArgs provided
If shArgs not provided
If Transform Exists
If Time Specified
If Time Not Specified
If Transform Does Not Exist
( Start)
/ Check shArgs
/ Update Transform
/ Update Local
/ Update Time
/ Check Transform Exists
/ Define Matrix Attribute
/ Check Time
/ Get Matrix At Time
/ Get Matrix
/ Build Matrix
/ Raise Exception
/ Return Matrix
End
Flow Chart Description:

This flowchart illustrates the getMatrix function:

  1. Checks if shArgs exist and, if so, updates transform, local, and time based on the provided arguments.

  2. Checks if the specified transform object exists.

  3. Defines the matrix attribute as either ‘worldMatrix[0]’ or ‘matrix’ based on the local parameter.

  4. Checks if a specific time frame is specified.

  5. Retrieves the transformation matrix based on the defined matrix attribute and time (if specified).

  6. Builds the transformation matrix.

  7. Returns the transformation matrix.

eMath.getRotationMx(self, matrix, rotationOrder='xyz', **shArgs)#

[shArgs : matrix=m, rotationOrder=ro]

Purpose:

:: Extracts the rotation component from a transformation matrix. This function calculates the Euler rotation values from a given transformation matrix, considering the specified rotation order.

Parameters:
  • matrix – (<type MMatrix>): # The transformation matrix to extract the rotation from.

  • rotationOrder – (<type str/int, optional>): # The rotation order for the Euler rotation. Can be a string like ‘xyz’ or an integer representing the order. Defaults to ‘xyz’.

Returns:

(<type tuple>): # A tuple of three values representing the XYZ Euler rotation extracted from the matrix.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> import maya.OpenMaya as om >>> matrix = om.MMatrix() >>> result = getRotationMx(matrix, rotationOrder=’xyz’) >>> print(result) # Returns the XYZ Euler rotation values extracted from the matrix.

If shArgs provided
If shArgs not provided
If Rotation Order is String
If Rotation Order is Int
( Start)
/ Check shArgs
/ Update Matrix
/ Update Rotation Order
/ Calculate Radian Constant
/ Check Rotation Order Type
/ Validate Rotation Order (String)
/ Convert Rotation Order (Int)
/ Get Transformation Matrix
/ Get Euler Rotation
/ Reorder Rotation
/ Return XYZ Rotation
End
Flow Chart Description:

This flowchart illustrates the getRotationMx function:

  1. Checks if shArgs exist, and if so, updates matrix and rotationOrder based on the provided arguments.

  2. If shArgs do not exist, calculates the radian constant.

  3. Checks the type of rotationOrder (string or int).

  4. If rotationOrder is a string, validates it and converts it to an integer representation.

  5. Gets the transformation matrix from the input matrix.

  6. Extracts Euler rotation from the matrix.

  7. Reorders the rotation based on the specified rotation order.

  8. Returns the XYZ Euler rotation values.

eMath.get_2PosExtn(self, srcObj, dirObj, extnRatio=None, locName='Extn_Loc', getLoc=True, extnDist=None, getSpot=False, **shArgs)#

[shArgs : srcObj=so, dirObj=do, extnRatio=er, locName=n, getLoc=gl, extnDist=ed, getSpot=gs]

Purpose:

:: Calculates an extended position or locator based on a directional vector between two objects. This function extends a position in the direction from one object (source) to another (direction object), either by a ratio of the distance between them or by a specified distance.

Parameters:
  • srcObj – (<type str>) # Source object for the directional vector.

  • dirObj – (<type str>) # Direction object for the directional vector.

  • extnRatio – (<type float>, optional) # Ratio value for extended position calculation. # 0 => at dirObj, 1.0 => at srcObj->dirObj distance away from dirObj # -1.0 => at srcObj, -0.5 in the middle of srcObj and dirObj

  • locName – (<type str>, optional) # Name for the locator if created. Defaults to ‘Extn_Loc’.

  • getLoc – (<type bool>, optional) # Whether to return a locator or only the position of the extension point.

  • extnDist – (<type float>, optional) # If provided, the extension distance, overriding the extnRatio. # plusValue -> distance away from dirObj # negValue -> distance from dirObj to towards srcObj

  • getSpot – (<type bool>, optional) # Determines whether to return a specific spot along the extension.

Returns:

# Either a locator or a position list, depending on ‘getLoc’ and ‘getSpot’ parameters.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = get_2PosExtn(“sourceObject”, “directionObject”, extnRatio=0.5, locName=”MyLocator”, getLoc=True, extnDist=None, getSpot=False) >>> print(result) # Returns a locator if getLoc is True, or a position list if getSpot is False

Usage:#

eMath.get_2PosExtn(selected()[0], selected()[1], 0.5)

If shArgs provided
If shArgs not provided
If GetSpot
If Not GetSpot
If ExtnDist
If Not ExtnDist
If GetLoc
If Not GetLoc
If GetSpot
If Not GetSpot
( Start)
/ Check shArgs
/ Update SrcObj
/ Update DirObj
/ Update ExtnRatio
/ Update LocName
/ Update GetLoc
/ Update ExtnDist
/ Update GetSpot
/ Check GetSpot
/ Set GetLoc False
/ Get Direction Vector
/ Check ExtnDist
/ Calculate With ExtnDist
/ Calculate With ExtnRatio
/ Create Locator
/ Snap Locator to SrcObj
/ Center Pivot and Unfreeze
/ Check GetLoc
/ Return Locator
/ Check GetSpot Post-Process
/ Get Spot Position
/ Get Locator Position
/ Delete Locator and Get Spot
/ Delete Locator and Get Position
End
Flow Chart Description:

This flowchart illustrates the get_2PosExtn function:

  • Checks if shArgs exist and updates various parameters from it.

  • Calculates the direction vector between srcObj and dirObj.

  • Extends the position based on the provided extnRatio or extnDist.

  • Creates a locator and positions it based on the extension.

  • Snap the locator to srcObj, centers its pivot, and unfreezes its transformations.

  • Returns either the locator or a position list, depending on getLoc and getSpot parameters.

eMath.get_2PosExtn_Old(self, srcObj, dirObj, extnRatio=None, locName=None, getLoc=True, extnDist=None, getSpot=False, **shArgs)#

Args: [**shArgs : srcObj =so, dirObj =do, extnRatio =er, locName =n, getLoc =gl, extnDist =ed]#

srcObj = node(str) #_ Source Object for direction vector dirObj = node(str) #_ Direction Object for direction vector extnRatio = int | float #_ Ration Value for Direction Extended Position

#_ 0 => at dirObj, 1.0 => at srcObj->dirObj distance away from dirObj #_ -1.0 => at srcObj, -0.5 in the middle of srcObj and dirObj

locName =name(str) #_ Name of returning locator getLoc = True | False #_ Whether to return locator or only position of extn point extnDist = int | Float #_ if extnDist is given, extnRatio is neglected.

#_ plusValue -> distance away from dirObj #_ negValue -> distance from dirObj to towards srcObj

Usage:#

eMath.get_2PosExtn(selected()[0], selected()[1], 0.5)

eMath.get_2PosVect(self, srcObj, destObj, **shArgs)#

[shArgs : srcObj=so, destObj=do]

Purpose:

:: Calculates the vector between two given positions in 3D space. This function computes a vector representing the directional and distance difference between two points in a 3D space. It handles both node objects and list representations of positions.

Parameters:
  • srcObj – (<type str/list>) # Source object or position in 3D space. If a string is provided, it is assumed to be a node from which the position will be extracted.

  • destObj – (<type str/list>) # Destination object or position in 3D space. Similar to srcObj, this can be either a node name or a position list.

Returns:

(<type MVector>) # Returns an MVector object representing the directional vector from srcObj to destObj.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = get_2PosVect(“sourceObject”, “destinationObject”) >>> print(result) # Returns an MVector object representing the directional vector between the two positions.

If shArgs provided
If shArgs not provided
If DestObj is List
If DestObj is Node
If SrcObj is List
If SrcObj is Node
( Start)
/ Check shArgs
/ Update SrcObj
/ Update DestObj
/ Determine Dest Type
/ Set DestPos as List
/ Get DestPos from Node
/ Determine Src Type
/ Set SrcPos as List
/ Get SrcPos from Node
/ Calculate Vector
/ Return MVector
End
Flow Chart Description:

This flowchart illustrates the get_2PosVect function:

  1. Checks if shArgs exist and, if so, updates srcObj and destObj based on shArgs[‘so’] and shArgs[‘do’].

  2. Gets the destination position. If destObj is not a list, it retrieves the position from the specified node using asNode(destObj). If it’s a list, it takes it as-is.

  3. Gets the source position. Similarly, it retrieves the source position from the specified node or list.

  4. Calculates the vector between the two positions in 3D space by finding the differences in X, Y, and Z coordinates.

  5. Returns the calculated vector as an MVector object.

eMath.get_2PosVect_Old(self, srcObj, destObj)#
eMath.get_ClosestGeoLoc(self, loc, mesh, locName='Geo_Loc', giveLoc=True, **shArgs)#

[shArgs : loc=l, mesh=m, locName=n, giveLoc=gl]

Purpose:

:: Finds the closest point on a geometry mesh to a given locator. This function calculates the nearest point on a specified mesh to a locator and can return either the position or a locator at that position. Note: Mesh should be freezed for correct snapping

Parameters:
  • loc – (<type str>) # The locator from which the closest point on the mesh is calculated.

  • mesh – (<type str>) # The mesh object to find the closest point on.

  • locName – (<type str, optional>) # Name for the locator if created. Defaults to ‘Geo_Loc’.

  • giveLoc – (<type bool, optional>) # Determines whether to return the locator itself or its position.

Returns:

# Either a locator or its position on the closest point on the mesh.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = get_ClosestGeoLoc(“locator1”, “mesh1”, locName=”MyGeoLocator”, giveLoc=True) >>> print(result) # Returns the created locator named “MyGeoLocator” positioned at the closest point on the mesh.

If shArgs provided
If shArgs not provided
If GiveLoc
If Not GiveLoc
( Start)
/ Check shArgs
/ Update Loc
/ Update Mesh
/ Update LocName
/ Update GiveLoc
/ Create CPOM Node
/ Get Locator Position
/ Set CPOM Position
/ Connect CPOM to Mesh
/ Get Target Position
/ Create Geo Locator
/ Move Geo Locator
/ Check GiveLoc
/ Return Geo Locator
/ Get Geo Locator Position
/ Delete Geo Locator
/ Return Position
End
Flow Chart Description:

This flowchart illustrates the get_ClosestGeoLoc function:

  1. Checks if shArgs exist and, if so, updates loc, mesh, locName, and giveLoc based on the provided arguments.

  2. Creates a closestPointOnMesh node named closestPoint and gets the position of the locator.

  3. Sets the initial position of closestPoint to the locator’s position.

  4. Connects the closestPoint node to the specified mesh.

  5. Gets the position details from closestPoint.

  6. Creates a locator named Geo_Loc or as specified by locName at the calculated position.

  7. If giveLoc is True, it returns the created locator. Otherwise, it returns the position and deletes the locator.

  8. Cleanup by deleting the closestPoint node if giveLoc is True.

eMath.get_GCLoc(self, baseLoc, baseGeo, giveLoc=True, **shArgs)#

[shArgs : baseLoc=bl, baseGeo=bg, giveLoc=gl]

Purpose:

:: Calculates a geometric central locator between two closest points on a geometry from a base location. This function identifies two closest points on a geometry from a base locator, extends the position, finds another set of closest points, and finally calculates a central position or locator.

Parameters:
  • baseLoc – (<type str>) # The base locator to start the calculation.

  • baseGeo – (<type str>) # The geometry on which closest points are calculated.

  • giveLoc – (<type bool, optional>) # Determines whether to return the locator itself or its position. Defaults to True.

Returns:

# Either a locator or its position, representing the geometric central location.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = get_GCLoc(“baseLocator”, “geometryMesh”, giveLoc=True) >>> print(result) # Returns the central locator positioned between two closest points on the geometry.

If shArgs provided
If shArgs not provided
If GiveLoc
If Not GiveLoc
( Start)
/ Check shArgs
/ Update BaseLoc
/ Update BaseGeo
/ Update GiveLoc
/ Get Closest GeoLoc 1
/ Get 2Pos Extn
/ Get Closest GeoLoc 2
/ Get 2Pos Extn Center
/ Delete Intermediate Locators
/ Check GiveLoc
/ Return Center Loc
/ Get Center Loc Position
/ Delete Center Loc
/ Return Position
End
Flow Chart Description:

This flowchart illustrates the get_GCLoc function:

  1. Checks if shArgs exist and, if so, updates baseLoc, baseGeo, and giveLoc based on the provided arguments.

  2. Calculates the first closest geometric locator using get_ClosestGeoLoc.

  3. Extends the position to find another set of closest points using get_2PosExtn.

  4. Calculates the second closest geometric locator using get_ClosestGeoLoc.

  5. Calculates the central position between the two locators using get_2PosExtn.

  6. Deletes intermediate locators created during the process.

  7. If giveLoc is True, it returns the central locator. Otherwise, it returns the central locator’s position and deletes the locator.

  8. Cleanup by deleting intermediate locators if giveLoc is True.

eMath.get_GeoCentricLoc(self, baseLoc, baseGeo, giveLoc=True, **shArgs)#

[shArgs : baseLoc=bl, baseGeo=bg, giveLoc=gl]

Purpose:

:: Calculates a geocentric locator or position based on a given base location and geometry. This function computes a geocentric locator or position, considering the closest points on a geometry to a base location and additional geometric calculations based on joints and normal vectors.

Parameters:
  • baseLoc – (<type str>) # The base locator or joint from which the calculation starts.

  • baseGeo – (<type str>) # The geometry used for calculating closest points and extensions.

  • giveLoc – (<type bool, optional>) # Determines whether to return a locator or just the position. Defaults to True.

Returns:

# Either a locator or a position, representing the geocentric location relative to the baseLoc and baseGeo. eMath.get_GeoCentricLoc(selected()[0], ‘baseGeo’)

Usage:

```python >>> # Example usage: >>> result = get_GeoCentricLoc(“baseLocator”, “geometryMesh”, giveLoc=True) >>> print(result) # Returns the geocentric locator or position based on the base locator and geometry.

If shArgs provided
If shArgs not provided
If BaseLoc is Joint
If BaseLoc is Not Joint
If GiveLoc
If Not GiveLoc
( Start)
/ Check shArgs
/ Update BaseLoc
/ Update BaseGeo
/ Update GiveLoc
/ Convert BaseLoc to PyNode
/ Get Closest GeoLoc 1
/ Get 2Pos Extn 1
/ Get Closest GeoLoc 2
/ Get 2Pos Extn Center
/ Check BaseLoc Type
/ Process Joint Type
/ Process Non-Joint Type
/ Get Norm Loc
/ Get Closest GeoLoc Norm 1
/ Get 2Pos Extn Norm
/ Get Closest GeoLoc Norm 2
/ Calculate Final Center Loc
/ Delete Intermediate Locators (Joint)
/ Final Center Loc (Joint)
/ Delete Intermediate Locators (Non-Joint)
/ Final Center Loc (Non-Joint)
/ Check GiveLoc
/ Return Center Loc
/ Get Center Loc Position
/ Delete Center Loc
/ Return Position
End
Flow Chart Description:

This flowchart illustrates the get_GeoCentricLoc function:

  1. Checks if shArgs exist and, if so, updates baseLoc, baseGeo, and giveLoc based on the provided arguments.

  2. Converts baseLoc to a PyNode object.

  3. Calculates the first closest geometric locator using get_ClosestGeoLoc.

  4. Extends the position to find another set of closest points using get_2PosExtn.

  5. Calculates the second closest geometric locator using get_ClosestGeoLoc.

  6. Calculates the central position based on whether baseLoc is a joint or not.

  7. If baseLoc is a joint, additional calculations involving normals and joints

eMath.get_NewDirLoc(self, oldSt, oldEnd, newSt, newEnd, giveLoc=True, **shArgs)#

[shArgs : os=oldSt, oe=oldEnd, ns=newSt, ne=newEnd, gl=giveLoc]

Purpose:

:: Calculates a new direction locator based on the difference in distance between two pairs of points.

Parameters:
  • oldSt<asNode/position> #Starting point of the old direction.

  • oldEnd<asNode/position> #Ending point of the old direction.

  • newSt<asNode/position> #Starting point of the new direction.

  • newEnd<asNode/position> #Ending point of the new direction.

  • giveLoc<bool, optional> #If True, returns a locator at the new position. Default is True.

Returns:

<asNode/position> #New position or locator based on the calculated direction and distance difference.

If shArgs provided
If shArgs not provided
If GiveLoc
If Not GiveLoc
( Start)
/ Check shArgs
/ Update OldSt
/ Update OldEnd
/ Update NewSt
/ Update NewEnd
/ Update GiveLoc
/ Calculate Old Distance
/ Calculate New Distance
/ Compute Difference Percentage
/ Calculate New Position
/ Check GiveLoc
/ Return New Locator
/ Return New Position
End
Flow Chart Description:

This flowchart illustrates the get_NewDirLoc function:

  1. Checks if shArgs exist and, if so, updates oldSt, oldEnd, newSt, newEnd, and giveLoc based on the provided arguments.

  2. Calculates the old distance between oldSt and oldEnd.

  3. Calculates the new distance between newSt and newEnd.

  4. Computes the difference percentage between old and new distances.

  5. Calculates the new position based on the difference percentage and whether to return a locator.

  6. Returns either the new locator or the new position.

eMath.get_NormLoc(self, obj_Piv, obj_Vec1, obj_Vec2, locName='Norm_Loc', giveLoc=True, **shArgs)#

[shArgs : obj_Piv=op, obj_Vec1=ov1, obj_Vec2=ov2, locName=n, giveLoc=gl]

Purpose:

:: Calculates the normal locator position based on two vector positions from a pivot object. This function generates a locator at the normal vector position relative to two directional vectors originating from a pivot object.

Parameters:
  • <str> (obj_Vec2) – #The pivot object from which the vectors originate.

  • <str> – #The first directional vector object.

  • <str> – #The second directional vector object.

  • optional) (giveLoc (bool,) – #Name for the created locator. Defaults to ‘Norm_Loc’.

  • optional) – #Determines whether to return the locator itself or its position. Defaults to True.

Returns:

#Returns either the locator or its position based on the ‘giveLoc’ parameter.

If shArgs provided
If shArgs not provided
If GiveLoc
If Not GiveLoc
( Start)
/ Check shArgs
/ Update Obj_Piv
/ Update Obj_Vec1
/ Update Obj_Vec2
/ Update LocName
/ Update GiveLoc
/ Get Vector 1
/ Get Vector 2
/ Calculate Normal Vector
/ Create Norm Loc
/ Create Joints
/ Snap End Joint to Norm Loc
/ Snap Start Joint to Obj_Piv
/ Snap Norm Loc to End Joint
/ Delete Start Joint
/ Check GiveLoc
/ Return Norm Loc
/ Get Norm Loc Position
/ Delete Norm Loc
/ Return Position
End
Flow Chart Description:

This flowchart illustrates the get_NormLoc function:

  1. Checks if shArgs exist and, if so, updates obj_Piv, obj_Vec1, obj_Vec2, locName, and giveLoc based on the provided arguments.

  2. Calculates the normal vector based on two directional vectors originating from obj_Piv.

  3. Creates a locator at the calculated normal vector position.

  4. Creates joints and snaps them to the locator and objects.

  5. Deletes the temporary joints.

  6. Returns either the locator or its position based on the giveLoc parameter.

eMath.mapRange(self, inputVal, minIN, maxIN, minOUT, maxOUT, **shArgs)#

[shArgs : inputVal=iv, minIN=minI, maxIN=maxI, minOUT=minO, maxOUT=maxO]

Purpose:

:: Remaps a value from one range to another range, optionally supporting inverted output ranges. This function takes an input value within a specified input range and maps it to a new value within a specified output range. It also handles cases where the output range is inverted. Now Supports inverted / reverse out put range where maxOUT is less than minOUT

Parameters:
  • inputVal – (<type float>): # The value to be remapped.

  • minIN – (<type float>): # The minimum of the input range.

  • maxIN – (<type float>): # The maximum of the input range.

  • minOUT – (<type float>): # The minimum of the output range.

  • maxOUT – (<type float>): # The maximum of the output range.

Returns:

(<type float>): # The remapped value within the output range.

Code Examples:

```python >>> # Usage examples can be added here if needed >>> result = mapRange(0.5, 0.0, 1.0, 0.0, 100.0) >>> print(result) # Returns the remapped value within the specified output range.

If shArgs provided
If shArgs not provided
If MaxOUT > MinOUT
If MaxOUT <= MinOUT
If Input Range Not Zero
If Input Range Zero
( Start)
/ Check shArgs
/ Update InputVal
/ Update MinIN
/ Update MaxIN
/ Update MinOUT
/ Update MaxOUT
/ Check Output Range
/ Calculate OutRange
/ Calculate Inverted OutRange
/ Check Input Range
/ Scale Value
/ Scale Value (Zero Input Range)
/ Calculate Output Value
/ Clamp Output Value
/ Return Mapped Value
End
Flow Chart Description:

This flowchart illustrates the mapRange function:

  1. Checks if shArgs exist, and if so, updates the function parameters based on the provided arguments.

  2. Calculates the output range based on whether maxOUT is greater than minOUT.

  3. Checks the input range.

  4. Scales the input value within the input range.

  5. Calculates the output value based on the scaled input value and output range.

  6. Clamps the output value to ensure it falls within the specified output range.

  7. Returns the mapped value.

eMath.old_mapRange(self, inputVal, minIN, maxIN, minOUT, maxOUT)#
eMath.orientTo(self, jointList, target, **shArgs)#

[shArgs : jointList=jl, target=tg]

Purpose:

:: Matches the orientation of a list of joints to a target transform. This function aligns the orientation of each joint in a given list to match that of a specified target transform.

Parameters:
  • (list) (jointList) – # A list of joints to orient.

  • (str) (target) – # The target transform to match the joint orientations to.

Returns:

# None. The function modifies the joint orientations directly.

Code Examples:

>>> # Usage examples can be added here if needed
>>> jointList = ["joint1", "joint2", "joint3"]
>>> target = "target_transform"
>>> orientTo(jointList, target)
# Aligns the orientation of the specified joints to match the target transform.
If shArgs provided
If shArgs not provided
If More Joints
If No More Joints
( Start)
/ Check shArgs
/ Update Joint List
/ Update Target
/ Process Joint List
/ Loop Through Joints
/ Unparent Children
/ Get Parent Matrix
/ Get Target Matrix
/ Calculate Orient Matrix
/ Extract Joint Orient
/ Reset Joint Rotation
/ Set Joint Orient
/ Reparent Children
/ End Loop
/ Select Joint List
End
Flow Chart Description:

This flowchart illustrates the orientTo function:

  1. Checks if shArgs exist, and if so, updates the function parameters based on the provided arguments.

  2. Loops through the list of joints.

  3. Unparents children of the current joint.

  4. Gets the parent joint matrix.

  5. Gets the target matrix.

  6. Calculates the orient matrix.

  7. Extracts joint orient values.

  8. Resets joint rotation and orientation.

  9. Reparents children to the current joint.

  10. Repeats the process for the next joint or ends the loop.

  11. Selects the joint list.

  12. Ends the process.