Skip to content

Trigonometry🍋

angle_between_points(p1, p2, dip_convention=DipDownward.NEGATIVE) 🍋

Compute angle between two points.

Parameters:

Name Type Description Default
p1 np.ndarray

Point in 2 or 3 dimension.

required
p2 np.ndarray

Point in 2 or 3 dimension.

required
dip_convention DipDownward

Convention of downward dip angle sign.

DipDownward.NEGATIVE

Returns:

Type Description
Tuple[float, float]

Angles in a given Metric convention.

angle_between_vectors(v1, v2) 🍋

Compute the angle between two vectors using the dot product.

Parameters:

Name Type Description Default
v1 np.ndarray

first cartesian vector.

required
v2 np.ndarray

second cartesian vector.

required

Returns:

Type Description
float

Angle between two vectors in radians.

normalize(a, center) 🍋

(Adapted from Apach Commons normalizeAngle, MathUtils sources) Normalize an angle in a 2pi; wide interval around a center value.

This method has three main uses:

  • normalize an angle between 0 and 2pi: a = normalize(a, np.pi)
  • normalize an angle between -pi and +pi: a = normalize(a, 0.0)
  • compute the angle between two defining angular positions: angle = normalize(end, start) - start

Parameters:

Name Type Description Default
a float

angle to be normalized (in radians).

required
center float

center value in radians.

required

Returns:

Type Description
float

normalized angle in radians.

Example

import geolime as geo
import numpy as np
geo.normalize(np.pi / 2, 2 * np.pi)
Output
7.853981633974483

Info

Due to numerical accuracy and since pi cannot be represented exactly, the result interval is closed, it cannot be half-closed as would be more satisfactory in a purely mathematical view.

rot_x(gamma, deg=True, clockwise=False) 🍋

Rotation against the X axis.

Parameters:

Name Type Description Default
gamma float

Rotation angle.

required
deg bool

True if theta is in degrees.

True
clockwise bool

if True clockwise, if False counter-clockwise rotation.

False

Returns:

Type Description
np.ndarray

Rotation matrix.

rot_y(beta, deg=True, clockwise=False) 🍋

Rotation against the Y axis.

Parameters:

Name Type Description Default
beta float

Rotation angle.

required
deg bool

True if theta is in degrees.

True
clockwise bool

if True clockwise, if False counter-clockwise rotation.

False

Returns:

Type Description
np.ndarray

Rotation matrix.

rot_z(alpha, deg=True, clockwise=False) 🍋

Rotation against the Z axis.

Parameters:

Name Type Description Default
alpha float

Rotation angle.

required
deg bool

True if theta is in degrees.

True
clockwise bool

if True clockwise, if False counter-clockwise rotation.

False

Returns:

Type Description
np.ndarray

Rotation matrix.

rot_zxz(angles, deg=True, clockwise=[False, False, False]) 🍋

Example of a convention.

Parameters:

Name Type Description Default
angles List[float]

Description of parameter angles.

required
deg bool

Description of parameter deg.

True
clockwise List[bool]

Clockwise if set to True, counter-clockwise otherwise.

[False, False, False]

Returns:

Type Description
np.ndarray

A rotation matrix.