optimus.utils.linalg

Module Contents

Functions

normalize_vector(vector)

Convert a vector into a unit vector.

theta_phi_point(point)

Counter-clockwise angle in xy plane (theta) and altitude towards z (phi).

rotate(locations, source_axis)

Rotates the coordinates of the point sources (locations) which

translate(locations, translation)

Translate an array of location points.

optimus.utils.linalg.normalize_vector(vector)

Convert a vector into a unit vector. For 2D input arrays, the columns will be normalized.

Parameters
vectornumpy.ndarray

An array of size (n,) or (n,m) with the m input vectors of dimension n.

Returns
unit_vectornumpy.ndarray

Array of size (n,) or (n,m) with the m vectors of dimension n scaled to unit Euclidean length.

optimus.utils.linalg.theta_phi_point(point)

Counter-clockwise angle in xy plane (theta) and altitude towards z (phi).

Parameters
pointnumpy.ndarray

Array of size (3,) with the rotation axis.

Returns
thetafloat

The angle on the xy plane measured from the positive x-axis.

phi: float

The angle towards z from the xy plane from the plane upwards.

Examples

>>> point = [0, 1, 0]
>>> theta, phi = theta_phi_point(point) # (pi/2, 0)
>>> print("theta = π/2 = {:.5f}; phi = 0 = {:.1f}".format(theta, phi))
theta = π/2 = 1.57080; phi = 0 = 0.0
>>> point = [0, 1, 1]
>>> theta, phi = theta_phi_point(point) # (pi/2, pi/4)
>>> print("theta = π/2 = {:.5f}; phi = π/4 = {:.5f}".format(theta, phi))
theta = π/2 = 1.57080; phi = π/4 = 0.78540
optimus.utils.linalg.rotate(locations, source_axis)

Rotates the coordinates of the point sources (locations) which approximate the transducer prior to the coordinate transformation. The source axis is a three element vector which defines the direction towards which the source is “pointing” (or the main axis of propagation) after coordinate transformation. The components of the vector are in metres.

Parameters
locationsnumpy.ndarray

Array of size (3,N) with the coordinates of the point sources.

source_axis: numpy.ndarray

Array of size (3,) with the axis of propagation.

Returns
locationsnumpy.ndarray

Array of size (3,N) with the locations rotated by the axis of propagation.

optimus.utils.linalg.translate(locations, translation)

Translate an array of location points.

Parameters
locationsnumpy.ndarray

Array of size (3,N) with the point locations to be translated.

translation: numpy.ndarray

Array of size (3,) with the displacement desired to perform.

Returns
locationsnumpy.ndarray

Array of size (3,N) with the positions translated by the required shift.