angle
index
/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/mathlib/angle.py

A library class for angles.
 
You can specify either radians or degrees for an angle, and the constructor
calculates the other and saves them both.
 
Trig functions are methods in the angle class; the major inverse trig functions
are Python functions that return angles. Both 1- and 2-argument versions are
included for arctan.
 
>>> arcsin(.866)
angle(rad=1.047147, deg=59d59'49.521")
>>> arctan2(1, 0)
angle(rad=1.570796, deg=90d0'0.000")

 
Classes
       
angle
exceptions.ValueError(exceptions.StandardError)
ConflictingAngle
UninitializedAngle

 
class ConflictingAngle(exceptions.ValueError)
    
Method resolution order:
ConflictingAngle
exceptions.ValueError
exceptions.StandardError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, rad, deg)
__str__(self)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
xThreshhold = 2.3283064365386963e-10

Data and other attributes inherited from exceptions.ValueError:
__new__ = <built-in method __new__ of type object at 0x4e8c00>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class UninitializedAngle(exceptions.ValueError)
    
Method resolution order:
UninitializedAngle
exceptions.ValueError
exceptions.StandardError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.ValueError:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.ValueError:
__new__ = <built-in method __new__ of type object at 0x4e8c00>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class angle
    A class to deal with angles in their various units.
 
The constructor expects either a radian value (rad=x), a decimal degree value
(deg=x), or a degree-minute-second tuple (deg=(d, m, s), but it can have more or
fewer components). If the argument name is missing it defaults to radians,
unless the value is a tuple, when it defaults to degrees.
 
>>> angle(3.14)
angle(rad=3.140000, deg=179d54'31.492")
>>> angle(deg=(23, 56, 4, 6))
angle(rad=0.417735, deg=23d56'4.100")
>>> angle((30,))
angle(rad=0.523599, deg=30d0'0.000")
 
You can add and subtract angles with each other; you can multiply an angle by a
scalar and vice versa; you can divide to angles to get a scalar, and divide an
angle by a scalar to get an angle. You can't divide a scalar by an angle.
 
>>> angle(rad=pi) - angle(deg=90)
angle(rad=1.570796, deg=90d0'0.000")
>>> 1/angle(pi)
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for /: 'int' and 'instance'
 
Each trigonometric function has its own method.
 
  Methods defined here:
SettleConflict(self, deg, rad)
ToDms(self)
__add__(self, other)
__div__(self, other)
__float__(self)
__floordiv__(self, other)
__iadd__(self, other)
__idiv__(self, other)
__ifloordiv__(self, other)
__imod__(self, other)
__imul__(self, other)
__init__(self, rad=None, deg=None)
Initialize an angle with a value in either radians (default) or degrees.
 
You can specify both, but the values must be compatible (to about 10 decimal
places in radians) or you will raise a 'ConflictingAngleValueError. See
SettleConflict() for details. You can also specify neither, but such an instance
will raise an 'Uninitialized' ValueError on any call to getDeg() or getRad().
 
>>> angle(pi/6, 30)
angle(rad=0.523599, deg=29d59'60.000")
>>> angle(1.571, 90)
Traceback (most recent call last):
...
ConflictingAngle: rad = 1.571, deg = 90.0
>>> angle() + angle()
Traceback (most recent call last):
...
UninitializedAngle
__isub__(self, other)
__itruediv__(self, other)
__mod__(self, other)
__mul__(self, other)
__neg__(self)
__pos__(self)
__repr__(self)
__rmul__(self, other)
__sub__(self, other)
__truediv__(self, other)
cos(self)
cot(self)
csc(self)
getDeg(self)
getRad(self)
sec(self)
setDeg(self, deg)
setRad(self, rad)
sin(self)
tan(self)

 
Functions
       
Expand(x, cLevel=2, nBase=60.0)
Expand a number into a base-60 (default) tuple.
 
The first component can be any integer; subsequent ones are base 60.
Parameter cLevel counts the accuracy of the representation: it defaults to
2, which gives degrees, minutes and seconds, but it can be more or less.
Parameter nBase chooses the base.
Reduce(tpn, nBase=60.0)
Reduce a base-60 (default) tuple to a single number.
 
This is the inverse of Expand().
acos(...)
acos(x)
 
Return the arc cosine (measured in radians) of x.
arccos(x)
arcsin(x)
arctan(x)
arctan2(y, x)
asin(...)
asin(x)
 
Return the arc sine (measured in radians) of x.
atan(...)
atan(x)
 
Return the arc tangent (measured in radians) of x.
atan2(...)
atan2(y, x)
 
Return the arc tangent (measured in radians) of y/x.
Unlike atan(y/x), the signs of both x and y are considered.
cos(...)
cos(x)
 
Return the cosine of x (measured in radians).
degrees(...)
degrees(x) -> converts angle x from radians to degrees
ldexp(...)
ldexp(x, i) -> x * (2**i)
modf(...)
modf(x)
 
Return the fractional and integer parts of x.  Both results carry the sign
of x.  The integer part is returned as a real.
radians(...)
radians(x) -> converts angle x from degrees to radians
sin(...)
sin(x)
 
Return the sine of x (measured in radians).
tan(...)
tan(x)
 
Return the tangent of x (measured in radians).

 
Data
        pi = 3.1415926535897931