pyransac3d/aux_functions.py
def rodrigues_rot(P, n0, n1):
    """
    Rotate a set of point between two normal vectors using Rodrigues' formula.

    :param P: Set of points `np.array (N,3)`.
    :param n0: Orign vector `np.array (1,3)`.
    :param n1: Destiny vector `np.array (1,3)`.

    :returns: Set of points P, but rotated `np.array (N, 3)`

    ---
    """

    # If P is only 1d array (coords of single point), fix it to be matrix
    P = np.asarray(P)
    if P.ndim == 1:
        P = P[np.newaxis, :]

    # Get vector of rotation k and angle theta
    n0 = n0 / np.linalg.norm(n0)
    n1 = n1 / np.linalg.norm(n1)
    k = np.cross(n0, n1)
    P_rot = np.zeros((len(P), 3))
    if np.linalg.norm(k) != 0:
        k = k / np.linalg.norm(k)
        theta = np.arccos(np.dot(n0, n1))

        # Compute rotated points
        for i in range(len(P)):
            P_rot[i] = (
                P[i] * np.cos(theta) + np.cross(k, P[i]) * np.sin(theta) + k * np.dot(k, P[i]) * (1 - np.cos(theta))
            )
    else:
        P_rot = P
    return P_rot

    Rotate a set of point between two normal vectors using Rodrigues' formula.

    :param P: Set of points `np.array (N,3)`.
    :param n0: Orign vector `np.array (1,3)`.
    :param n1: Destiny vector `np.array (1,3)`.

    :returns: Set of points P, but rotated `np.array (N, 3)`

    ---
    
Rotate a set of point between two normal vectors using Rodrigues' formula.
Rotate a set of point between two normal vectors using Rodrigues ' formula .
def rodrigues_rot(P, n0, n1):
    P = np.asarray(P)
    if P.ndim == 1:
        P = P[np.newaxis, :]
    n0 = n0 / np.linalg.norm(n0)
    n1 = n1 / np.linalg.norm(n1)
    k = np.cross(n0, n1)
    P_rot = np.zeros((len(P), 3))
    if np.linalg.norm(k) != 0:
        k = k / np.linalg.norm(k)
        theta = np.arccos(np.dot(n0, n1))
        for i in range(len(P)):
            P_rot[i] = (
                P[i] * np.cos(theta) + np.cross(k, P[i]) * np.sin(theta) + k * np.dot(k, P[i]) * (1 - np.cos(theta))
            )
    else:
        P_rot = P
    return P_rot
def rodrigues_rot ( P , n0 , n1 ) : P = np . asarray ( P ) if P . ndim == 1 : P = P [ np . newaxis , : ] n0 = n0 / np . linalg . norm ( n0 ) n1 = n1 / np . linalg . norm ( n1 ) k = np . cross ( n0 , n1 ) P_rot = np . zeros ( ( len ( P ) , 3 ) ) if np . linalg . norm ( k ) != 0 : k = k / np . linalg . norm ( k ) theta = np . arccos ( np . dot ( n0 , n1 ) ) for i in range ( len ( P ) ) : P_rot [ i ] = ( P [ i ] * np . cos ( theta ) + np . cross ( k , P [ i ] ) * np . sin ( theta ) + k * np . dot ( k , P [ i ] ) * ( 1 - np . cos ( theta ) ) ) else : P_rot = P return P_rot
Rotate a set of point between two normal vectors using Rodrigues' formula.
Rotate a set of point between two normal vectors using Rodrigues ' formula .
"""
    Rotate a set of point between two normal vectors using Rodrigues' formula.

    :param P: Set of points `np.array (N,3)`.
    :param n0: Orign vector `np.array (1,3)`.
    :param n1: Destiny vector `np.array (1,3)`.

    :returns: Set of points P, but rotated `np.array (N, 3)`

    ---
    """ # If P is only 1d array (coords of single point), fix it to be matrix # Get vector of rotation k and angle theta # Compute rotated points
Set of points P, but rotated `np.array (N, 3)`
Set of points P but rotated ` np . array ( N 3 ) `
P
Set of points `np.array (N,3)`.
Set of points ` np . array ( N 3 ) ` .
n0
Orign vector `np.array (1,3)`.
Orign vector ` np . array ( 1 3 ) ` .
n1
Destiny vector `np.array (1,3)`.
Destiny vector ` np . array ( 1 3 ) ` .