synthesizer.utils.geometry

A module containing geometry functions.

Example usage:

import numpy as np from geometry import get_rotation_matrix

# Define the vector to rotate vector = np.array([1.0, 0.0, 0.0])

# Define the unit vector to rotate to unit = np.array([0.0, 1.0, 0.0])

# Get the rotation matrix matrix = get_rotation_matrix(vector, unit)

Functions

synthesizer.utils.geometry.get_rotation_matrix(vector, unit=None)[source]

Get the rotation matrix to rotate a vector to another vector.

This uses the Rodrigues’ rotation formula for the re-projection.

Adapted from: https://stackoverflow.com/questions/43507491/imprecision-with-rotation- matrix-to-align-a-vector-to-an-axis

Parameters:
  • vector (array-like, float) – The vector to rotate.

  • unit (array-like, float) – The vector to rotate to.

Returns:

matrix (array-like, float)

The rotation matrix.