2020/13.py
def combine_phased_rotations(a_period, a_phase, b_period, b_phase):
    """
    I don't claim any copyright on this. I copied it from the internet somewhere.

    Combine two phased rotations into a single phased rotation

    Returns: combined_period, combined_phase

    The combined rotation is at its reference point if and only if both a and b
    are at their reference points.
    """
    gcd, s, _ = extended_gcd(a_period, b_period)
    phase_difference = a_phase - b_phase
    pd_mult, pd_remainder = divmod(phase_difference, gcd)
    if pd_remainder:
        raise ValueError("Rotation reference points never synchronize.")

    combined_period = a_period // gcd * b_period
    combined_phase = (a_phase - s * pd_mult * a_period) % combined_period
    return combined_period, combined_phase

    I don't claim any copyright on this. I copied it from the internet somewhere.

    Combine two phased rotations into a single phased rotation

    Returns: combined_period, combined_phase

    The combined rotation is at its reference point if and only if both a and b
    are at their reference points.
    
I don't claim any copyright on this. I copied it from the internet somewhere.
Combine two phased rotations into a single phased rotation



The combined rotation is at its reference point if and only if both a and b
are at their reference points.
I don ' t claim any copyright on this . I copied it from the internet somewhere . Combine two phased rotations into a single phased rotation The combined rotation is at its reference point if and only if both a and b are at their reference points .
def combine_phased_rotations(a_period, a_phase, b_period, b_phase):
    gcd, s, _ = extended_gcd(a_period, b_period)
    phase_difference = a_phase - b_phase
    pd_mult, pd_remainder = divmod(phase_difference, gcd)
    if pd_remainder:
        raise ValueError("Rotation reference points never synchronize.")
    combined_period = a_period // gcd * b_period
    combined_phase = (a_phase - s * pd_mult * a_period) % combined_period
    return combined_period, combined_phase
def combine_phased_rotations ( a_period , a_phase , b_period , b_phase ) : gcd , s , _ = extended_gcd ( a_period , b_period ) phase_difference = a_phase - b_phase pd_mult , pd_remainder = divmod ( phase_difference , gcd ) if pd_remainder : raise ValueError ( "Rotation reference points never synchronize." ) combined_period = a_period // gcd * b_period combined_phase = ( a_phase - s * pd_mult * a_period ) % combined_period return combined_period , combined_phase
I don't claim any copyright on this.
I don ' t claim any copyright on this .
"""
    I don't claim any copyright on this. I copied it from the internet somewhere.

    Combine two phased rotations into a single phased rotation

    Returns: combined_period, combined_phase

    The combined rotation is at its reference point if and only if both a and b
    are at their reference points.
    """
a_period
a_phase
b_period
b_phase