4.1.1.9.1.10. pyfem.util.transformations module
- getRotationMatrix(el_coords: ndarray) ndarray[source]
Compute the 2D rotation matrix for an element.
Calculates the rotation matrix that transforms from global coordinates to element coordinates based on the element’s orientation in 2D space.
- Parameters:
el_coords – Element node coordinates as (2, 2) array where rows are nodes
- Returns:
2x2 rotation matrix for coordinate transformation
- Raises:
NotImplementedError – If element coordinates are not 2D (shape[1] != 2)
- vectorToElementCoordinates(a: ndarray, el_coords: ndarray) ndarray[source]
Transform a vector from global to element coordinates.
Rotates a vector (or block of vectors) from the global coordinate system to the element coordinate system. Handles vectors with multiple components.
- Parameters:
a – Vector in global coordinates with shape (n,) where n is divisible by 2
el_coords – Element node coordinates as (2, 2) array
- Returns:
Vector in element coordinates with same shape as input
- Raises:
RuntimeError – If vector length is not divisible by rotation matrix size
- matrixToElementCoordinates(a: ndarray, el_coords: ndarray) ndarray[source]
Transform a matrix from global to element coordinates.
Rotates a square matrix (or block matrix) from the global coordinate system to the element coordinate system using: a_bar = R @ a @ R^T
- Parameters:
a – Square matrix in global coordinates with shape (m, m) where m is divisible by 2
el_coords – Element node coordinates as (2, 2) array
- Returns:
Matrix in element coordinates with same shape as input
- Raises:
RuntimeError – If matrix dimensions are not divisible by rotation matrix size
- vectorToGlobalCoordinates(a_bar: ndarray, el_coords: ndarray) ndarray[source]
Transform a vector from element to global coordinates.
Rotates a vector (or block of vectors) from the element coordinate system back to the global coordinate system. Inverse of vectorToElementCoordinates.
- Parameters:
a_bar – Vector in element coordinates with shape (n,) where n is divisible by 2
el_coords – Element node coordinates as (2, 2) array
- Returns:
Vector in global coordinates with same shape as input
- Raises:
RuntimeError – If vector length is not divisible by rotation matrix size
- matrixToGlobalCoordinates(a_bar: ndarray, el_coords: ndarray) ndarray[source]
Transform a matrix from element to global coordinates.
Rotates a square matrix (or block matrix) from the element coordinate system back to the global coordinate system using: a = R^T @ a_bar @ R Inverse of matrixToElementCoordinates.
- Parameters:
a_bar – Square matrix in element coordinates with shape (m, m) where m is divisible by 2
el_coords – Element node coordinates as (2, 2) array
- Returns:
Matrix in global coordinates with same shape as input
- Raises:
RuntimeError – If matrix dimensions are not divisible by rotation matrix size
- toElementCoordinates(a: ndarray, el_coords: ndarray) ndarray[source]
Transform array (vector or matrix) from global to element coordinates.
Dispatcher function that automatically detects input type (1D vector or 2D matrix) and applies the appropriate transformation. Rotates from global to element coordinate system.
- Parameters:
a – Input vector (shape (n,)) or matrix (shape (m, m)) in global coordinates
el_coords – Element node coordinates as (2, 2) array
- Returns:
Transformed array in element coordinates with same shape as input
- Raises:
NotImplementedError – If input is not a 1D or 2D ndarray
RuntimeError – If array dimensions are incompatible with rotation matrix
- toGlobalCoordinates(a: ndarray, el_coords: ndarray) ndarray[source]
Transform array (vector or matrix) from element to global coordinates.
Dispatcher function that automatically detects input type (1D vector or 2D matrix) and applies the appropriate transformation. Rotates from element to global coordinate system. Inverse of toElementCoordinates.
- Parameters:
a – Input vector (shape (n,)) or matrix (shape (m, m)) in element coordinates
el_coords – Element node coordinates as (2, 2) array
- Returns:
Transformed array in global coordinates with same shape as input
- Raises:
NotImplementedError – If input is not a 1D or 2D ndarray
RuntimeError – If array dimensions are incompatible with rotation matrix