ssapy_toolkit.vectors

Vector utilities and small helpers for geometry and plotting.

Functions

angle_between_vectors(vector1, vector2)

Return the angle between two vectors in radians.

einsum_norm(a[, indices])

extend_vector(vector, distance)

Extend a vector by a given distance along its direction.

getAngle(a, b, c)

Calculate the angle between vectors a, b, and c, where b is the vertex.

norm(arr)

normSq(arr)

normed(arr)

Normalise an array of vectors along the last axis.

perpendicular_vectors(v)

Returns two vectors that are perpendicular to v and each other.

points_on_circle(r, v, rad[, num_points])

rotate_points_3d(points[, axis, theta])

Rotate a set of 3D points about a 3D axis by an angle theta in radians.

rotate_vector(v_unit, theta, phi[, save_path])

rotation_matrix_from_vectors(vec1, vec2)

Find the rotation matrix that aligns vec1 to vec2 :param vec1: A 3d "source" vector :param vec2: A 3d "destination" vector :return mat: A transform matrix (3x3) which when applied to vec1, aligns it with vec2.

unit_vector(vector)

Returns the unit vector of the vector.

ssapy_toolkit.vectors.angle_between_vectors(vector1, vector2)[source]

Return the angle between two vectors in radians.

ssapy_toolkit.vectors.einsum_norm(a, indices='ij,ji->i')[source]
ssapy_toolkit.vectors.extend_vector(vector: ndarray, distance: float) ndarray[source]

Extend a vector by a given distance along its direction.

ssapy_toolkit.vectors.getAngle(a: ndarray, b: ndarray, c: ndarray) ndarray[source]

Calculate the angle between vectors a, b, and c, where b is the vertex.

Parameters: a, b, c (np.ndarray): Input vectors.

Returns: np.ndarray: The angle between the vectors in radians.

Author: Travis Yeager (yeager7@llnl.gov)

ssapy_toolkit.vectors.norm(arr)[source]
ssapy_toolkit.vectors.normSq(arr)[source]
ssapy_toolkit.vectors.normed(arr)[source]

Normalise an array of vectors along the last axis.

ssapy_toolkit.vectors.perpendicular_vectors(v)[source]

Returns two vectors that are perpendicular to v and each other.

ssapy_toolkit.vectors.points_on_circle(r, v, rad, num_points=4)[source]
ssapy_toolkit.vectors.rotate_points_3d(points, axis=array([0, 0, 1]), theta=-1.5707963267948966)[source]

Rotate a set of 3D points about a 3D axis by an angle theta in radians.

Args:

points (np.ndarray): The set of 3D points to rotate, as an Nx3 array. axis (np.ndarray): The 3D axis to rotate about, as a length-3 array. Default is the z-axis. theta (float): The angle to rotate by, in radians. Default is pi/2.

Returns:

np.ndarray: The rotated set of 3D points, as an Nx3 array.

ssapy_toolkit.vectors.rotate_vector(v_unit, theta, phi, save_path=False)[source]
ssapy_toolkit.vectors.rotation_matrix_from_vectors(vec1, vec2)[source]

Find the rotation matrix that aligns vec1 to vec2 :param vec1: A 3d “source” vector :param vec2: A 3d “destination” vector :return mat: A transform matrix (3x3) which when applied to vec1, aligns it with vec2.

ssapy_toolkit.vectors.unit_vector(vector)[source]

Returns the unit vector of the vector.