mblend/__init__.py
def poly_blend_3(m1: Motion, m2: Motion, tnow: float, h: float) -> PolynomialMotion:
    """Returns a third-degree polynomial function that blends two motions.

    Args:
        m1: First motion
        m2: Second motion
        tnow: Start of blend
        h: Horizon of blend

    Returns:
        mblend: Polynomial motion blending m1 and m2 in segment [tnow, tnow+h].
    """
    if h <= 0.0:
        raise ValueError("Horizon has to be > 0.0")

    A = np.zeros((4, 4))
    b = np.zeros(4)

    # Position at start (tnow) should match m1
    # Note, the offset (shift) of blended motion will be tnow
    A[0, 0] = 0
    A[0, 1] = 0
    A[0, 2] = 0
    A[0, 3] = 1
    b[0] = m1.at(tnow)

    # Position at end of horizon should match m2
    A[1, 0] = h ** 3
    A[1, 1] = h ** 2
    A[1, 2] = h
    A[1, 3] = 1
    b[1] = m2.at(tnow + h)

    # Velocity at start should match m1
    A[2, 0] = 0
    A[2, 1] = 0
    A[2, 2] = 1
    A[2, 3] = 0
    b[2] = m1.d_at(tnow)

    # Velocity at end should match m2
    A[3, 0] = 3 * h ** 2
    A[3, 1] = 2 * h
    A[3, 2] = 1
    A[3, 3] = 0
    b[3] = m2.d_at(tnow + h)

    coeffs = np.linalg.solve(A, b)  # TODO: handle singularities
    return PolynomialMotion(tnow, coeffs)
Returns a third-degree polynomial function that blends two motions.

    Args:
        m1: First motion
        m2: Second motion
        tnow: Start of blend
        h: Horizon of blend

    Returns:
        mblend: Polynomial motion blending m1 and m2 in segment [tnow, tnow+h].
    
Returns a third-degree polynomial function that blends two motions.
Returns a third - degree polynomial function that blends two motions .
def poly_blend_3(m1: Motion, m2: Motion, tnow: float, h: float) -> PolynomialMotion:
    if h <= 0.0:
        raise ValueError("Horizon has to be > 0.0")
    A = np.zeros((4, 4))
    b = np.zeros(4)
    A[0, 0] = 0
    A[0, 1] = 0
    A[0, 2] = 0
    A[0, 3] = 1
    b[0] = m1.at(tnow)
    A[1, 0] = h ** 3
    A[1, 1] = h ** 2
    A[1, 2] = h
    A[1, 3] = 1
    b[1] = m2.at(tnow + h)
    A[2, 0] = 0
    A[2, 1] = 0
    A[2, 2] = 1
    A[2, 3] = 0
    b[2] = m1.d_at(tnow)
    A[3, 0] = 3 * h ** 2
    A[3, 1] = 2 * h
    A[3, 2] = 1
    A[3, 3] = 0
    b[3] = m2.d_at(tnow + h)
    coeffs = np.linalg.solve(A, b)  
    return PolynomialMotion(tnow, coeffs)
def poly_blend_3 ( m1 : Motion , m2 : Motion , tnow : float , h : float ) -> PolynomialMotion : if h <= 0.0 : raise ValueError ( "Horizon has to be > 0.0" ) A = np . zeros ( ( 4 , 4 ) ) b = np . zeros ( 4 ) A [ 0 , 0 ] = 0 A [ 0 , 1 ] = 0 A [ 0 , 2 ] = 0 A [ 0 , 3 ] = 1 b [ 0 ] = m1 . at ( tnow ) A [ 1 , 0 ] = h ** 3 A [ 1 , 1 ] = h ** 2 A [ 1 , 2 ] = h A [ 1 , 3 ] = 1 b [ 1 ] = m2 . at ( tnow + h ) A [ 2 , 0 ] = 0 A [ 2 , 1 ] = 0 A [ 2 , 2 ] = 1 A [ 2 , 3 ] = 0 b [ 2 ] = m1 . d_at ( tnow ) A [ 3 , 0 ] = 3 * h ** 2 A [ 3 , 1 ] = 2 * h A [ 3 , 2 ] = 1 A [ 3 , 3 ] = 0 b [ 3 ] = m2 . d_at ( tnow + h ) coeffs = np . linalg . solve ( A , b ) return PolynomialMotion ( tnow , coeffs )
Returns a third-degree polynomial function that blends two motions.
Returns a third - degree polynomial function that blends two motions .
"""Returns a third-degree polynomial function that blends two motions.

    Args:
        m1: First motion
        m2: Second motion
        tnow: Start of blend
        h: Horizon of blend

    Returns:
        mblend: Polynomial motion blending m1 and m2 in segment [tnow, tnow+h].
    """ # Position at start (tnow) should match m1 # Note, the offset (shift) of blended motion will be tnow # Position at end of horizon should match m2 # Velocity at start should match m1 # Velocity at end should match m2 # TODO: handle singularities
Polynomial motion blending m1 and m2 in segment [tnow, tnow+h].
Polynomial motion blending m1 and m2 in segment [ tnow tnow + h ] .
mblend
m1
Motion
None
m2
Motion
None
tnow
float
Start of blend
Start of blend
h
float
Horizon of blend
Horizon of blend