Frame#

class pyCGM2.Model.frame.Frame#

Represents a coordinate system at a specific time, including rotation matrix and translation vectors.

__init__()#

Methods

__init__()

addNode(nodeLabel, position[, positionType, ...])

Appends a Node to the Frame.

constructFromAnglesAxis(angleAxisValues)

Constructs the frame from angle-axis values.

constructFromQuaternion(quaternionValues)

Constructs the frame from quaternion values.

copyNode(nodeLabel, nodeToCopy)

Copies the values of one node to another, either creating a new node or updating an existing one.

eraseNodes()

Erases all nodes from the frame.

getAngleAxis()

Returns the angle-axis representation of the frame's rotation.

getGlobalPosition(nodeLabel)

Returns the global position of a node.

getNodeIndex(nodeLabel)

Retrieves the index of a node in the frame based on its label.

getNodeLabels([display])

Returns the labels of all nodes in the frame.

getNode_byIndex(index)

Returns a Node by its index.

getNode_byLabel(label)

Returns a Node by its label.

getNodes()

Retrieves all Node instances from the frame.

getQuaternion()

Returns the quaternion representation of the frame's rotation.

getRotation()

Returns the rotation matrix of the frame.

getTranslation()

Returns the translation vector of the frame.

isNodeExist(nodeLabel)

Checks if a node exists in the frame based on its label.

setAxes(x, y, z)

Sets the axes of the frame.

setRotation(R)

Sets the rotation matrix for the frame.

setTranslation(t)

Sets the translation vector for the frame.

update(R, t)

Updates both the rotation matrix and translation vector of the frame.

updateAxisFromRotation(R)

Updates the axes of the frame based on a new rotation matrix.

updateNode(nodeLabel, localArray, globalArray)

Updates a node's local and global position and description.

addNode(nodeLabel: str, position: ndarray, positionType: str = 'Global', desc: str = '') None#

Appends a Node to the Frame.

Parameters:
  • nodeLabel (str) – The label of the node.

  • position (np.ndarray) – The position of the node.

  • positionType (str, optional) – Specifies if the position is global or local. Defaults to “Global”.

  • desc (str, optional) – Description of the node.

constructFromAnglesAxis(angleAxisValues: ndarray) None#

Constructs the frame from angle-axis values.

Parameters:

angleAxisValues (np.ndarray) – An array representing the angle-axis values.

constructFromQuaternion(quaternionValues: ndarray) None#

Constructs the frame from quaternion values.

Parameters:

quaternionValues (np.ndarray) – An array representing the quaternion values.

copyNode(nodeLabel: str, nodeToCopy: str) None#

Copies the values of one node to another, either creating a new node or updating an existing one.

Parameters:
  • nodeLabel (str) – The label of the node where the values are to be copied.

  • nodeToCopy (str) – The label of the node from which to copy the values.

eraseNodes() None#

Erases all nodes from the frame.

getAngleAxis() ndarray#

Returns the angle-axis representation of the frame’s rotation.

Returns:

np.ndarray – The angle-axis representation.

getGlobalPosition(nodeLabel: str) ndarray#

Returns the global position of a node.

Parameters:

nodeLabel (str) – The label of the node.

Returns:

np.ndarray – The global position of the node.

getNodeIndex(nodeLabel: str) int#

Retrieves the index of a node in the frame based on its label.

Parameters:

nodeLabel (str) – The label of the node.

Returns:

int – The index of the node in the frame’s node list.

getNodeLabels(display: bool = True) List[str]#

Returns the labels of all nodes in the frame.

Parameters:

display (bool, optional) – If True, prints the node labels. Defaults to True.

Returns:

List[str] – A list of node labels.

getNode_byIndex(index: int) Node#

Returns a Node by its index.

Parameters:

index (int) – The index of the node in the frame’s node collection.

Returns:

Node – The Node instance at the specified index.

getNode_byLabel(label: str) Node#

Returns a Node by its label.

Parameters:

label (str) – The label of the node.

Returns:

Node – The Node instance with the specified label.

getNodes()#

Retrieves all Node instances from the frame.

Returns:

List[Node] – A list of Node instance

getQuaternion() ndarray#

Returns the quaternion representation of the frame’s rotation.

Returns:

np.ndarray – The quaternion representation.

getRotation() ndarray#

Returns the rotation matrix of the frame.

Returns:

np.ndarray – The rotation matrix.

getTranslation() ndarray#

Returns the translation vector of the frame.

Returns:

np.ndarray – The translation vector.

isNodeExist(nodeLabel: str) bool#

Checks if a node exists in the frame based on its label.

Parameters:

nodeLabel (str) – The label of the node to check.

Returns:

bool – True if the node exists, False otherwise.

setAxes(x: ndarray, y: ndarray, z: ndarray) None#

Sets the axes of the frame.

Parameters:
  • x (np.ndarray) – The x-axis of the frame.

  • y (np.ndarray) – The y-axis of the frame.

  • z (np.ndarray) – The z-axis of the frame.

setRotation(R: ndarray) None#

Sets the rotation matrix for the frame.

Parameters:

R (np.ndarray) – A 3x3 rotation matrix.

setTranslation(t: ndarray) None#

Sets the translation vector for the frame.

Parameters:

t (np.ndarray) – A translation vector.

update(R: ndarray, t: ndarray) None#

Updates both the rotation matrix and translation vector of the frame.

Parameters:
  • R (np.ndarray) – A 3x3 rotation matrix.

  • t (np.ndarray) – A translation vector.

updateAxisFromRotation(R: ndarray) None#

Updates the axes of the frame based on a new rotation matrix.

Parameters:

R (np.ndarray) – A 3x3 rotation matrix.

updateNode(nodeLabel: str, localArray: ndarray, globalArray: ndarray, desc: str = '') None#

Updates a node’s local and global position and description.

Parameters:
  • nodeLabel (str) – The label of the node to update.

  • localArray (np.ndarray) – The local position of the node.

  • globalArray (np.ndarray) – The global position of the node.

  • desc (str, optional) – The description of the node. Defaults to an empty string.