Example #1
0
def involute( radius, phi=None ):
    """Compute involute dimensions given radius
    and optional angle phi.

    :param radius: Radius of circle
    :param phi: optional angle in radians.
    :returns: dictionary with numerous values for the
        involute.

        -   radius, given
        -   diameter, :math:`2 \\times r`
        -   baseline, :math:`\\pi \\times r`
        -   involute circumference

        If Phi is provided

        -   phi, given
        -   C_X, C_Y, location of point C on the involate at angle phi
        -   CO length of the line from origin to C
        -   CE length of the line from circumference to C
        -   OCE the angle at C (on involute) between O and E (on circumference)
        -   COE the angle at O between C (on involute) and E (on circumference)
    """
    args = AttrDict()
    args.radius= radius
    args.diameter = 2*args.radius
    args.baseline = math.pi*args.radius
    args.involute = args.radius*math.pi**2/2

    if phi is not None:
        args.phi= phi
        args.C_X= args.radius*(math.sin(phi)-phi*math.cos(phi))
        args.C_Y= args.radius*(math.cos(phi)-phi*math.sin(phi))
        args.CO= math.sqrt( args.C_X**2 + args.C_Y**2 )
        try:
            args.CE= math.sqrt( args.CO**2 - args.radius**2 )
        except ValueError as e:
            print( "{0} computing sqrt({CO:7.3f}**2-{radius:7.3f}**2)".format(e,**args) )
            args.CE = args.COE = args.OCE = float("NaN")
            return args
        args.OCE = math.atan2( args.radius, args.CE )
        args.COE = math.pi/2-args.OCE

    return args