Skip to content

general_math

acos

acos(value: float) -> float

Fix float approximations like 1.0000000000002, which acos does not like.

Parameters:

Name Type Description Default
value float

The input value.

required

Returns:

Type Description
float

The arc cosine of the input value.

Source code in opensquirrel/utils/general_math.py
def acos(value: float) -> float:
    """Fix float approximations like 1.0000000000002, which acos does not like.

    Args:
        value (float): The input value.

    Returns:
        The arc cosine of the input value.

    """
    value = max(min(value, 1.0), -1.0)
    return math.acos(value)

are_axes_consecutive

are_axes_consecutive(
    axis_a_index: int, axis_b_index: int
) -> bool

Check if axis 'a' immediately precedes axis 'b' (in a circular fashion [x, y, z, x...]).

Parameters:

Name Type Description Default
axis_a_index int

The index of axis 'a'.

required
axis_b_index int

The index of axis 'b'.

required

Returns:

Type Description
bool

True if axis 'a' immediately precedes axis 'b', otherwise False.

Source code in opensquirrel/utils/general_math.py
def are_axes_consecutive(axis_a_index: int, axis_b_index: int) -> bool:
    """Check if axis 'a' immediately precedes axis 'b' (in a circular fashion [x, y, z, x...]).

    Args:
        axis_a_index (int): The index of axis 'a'.
        axis_b_index (int): The index of axis 'b'.

    Returns:
        True if axis 'a' immediately precedes axis 'b', otherwise False.

    """
    return axis_a_index - axis_b_index in (-1, 2)