Package dics :: Module rotator :: Class angle
[hide private]
[frames] | no frames]

Class angle
source code

Class for storing angles. Internally stores an angle as a float in radians and provides methods for setting and retrieving the angle in a variety of units, both via floats or various string formats.

Instance Methods [hide private]
  __init__(self, value=0.0, units=False)
Standard initialiser, takes up to two arguments.
  __eq__(self, other)
  __ne__(self, other)
  __ge__(self, other)
  __gt__(self, other)
  __le__(self, other)
  __lt__(self, other)
  __add__(self, other)
  __radd__(self, other)
  __iadd__(self, other)
  __sub__(self, other)
  __rsub__(self, other)
  __isub__(self, other)
  __mul__(self, other)
  __rmul__(self, other)
  __imul__(self, other)
  __div__(self, other)
  __idiv__(self, other)
  __truediv__(self, other)
  __itruediv__(self, other)
  __neg__(self)
  __pos__(self)
  __abs__(self)
  __repr__(self)
  __str__(self)
  getAngle(self, units='r')
Returns the value of the angle as a float in the specified units, 'r' - radians, 'd' - degrees or 'h' - hours.
  setAngle(self, value=0.0, units='r')
Sets the angle.
  getString(self, units='d', ndp=3)
Returns a string representation of the angle in sexagesimal or 'time' formats.
  setString(self, angleString, units='d', startPos=1)
Sets the angle from a string representation.
  normPi(self)
Normalises the angle into the range +/-Pi.
  norm2Pi(self)
Normalises the angle into the range 0-2Pi.

Method Details [hide private]

__init__(self, value=0.0, units=False)
(Constructor)

source code 
Standard initialiser, takes up to two arguments. The first argument (which defaults to zero) is the angle to store, the second argument (which defaults to 'r') indicates the units used, 'r' for radians, 'd' for degrees and 'h' for hours. The angle may be in any numeric type acceptable to the builtin function float(). Alternatively, if value is itself an angle object, this becomes a C++ style 'copy constructor' and units is ignored. Thirdly, value may be a string representation of an angle, in which case it will be parsed by angle.setString(). For string values only units of 'd' or 'h' are acceptable, and units will default to 'd'.

__eq__(self, other)
(Equality operator)

source code 

__ne__(self, other)

source code 

__ge__(self, other)
(Greater-than-or-equals operator)

source code 

__gt__(self, other)
(Greater-than operator)

source code 

__le__(self, other)
(Less-than-or-equals operator)

source code 

__lt__(self, other)
(Less-than operator)

source code 

__add__(self, other)
(Addition operator)

source code 

__radd__(self, other)
(Right-side addition operator)

source code 

__iadd__(self, other)

source code 

__sub__(self, other)
(Subtraction operator)

source code 

__rsub__(self, other)

source code 

__isub__(self, other)

source code 

__mul__(self, other)

source code 

__rmul__(self, other)

source code 

__imul__(self, other)

source code 

__div__(self, other)

source code 

__idiv__(self, other)

source code 

__truediv__(self, other)

source code 

__itruediv__(self, other)

source code 

__neg__(self)

source code 

__pos__(self)

source code 

__abs__(self)

source code 

__repr__(self)
(Representation operator)

source code 

__str__(self)
(Informal representation operator)

source code 

getAngle(self, units='r')

source code 
Returns the value of the angle as a float in the specified units, 'r' - radians, 'd' - degrees or 'h' - hours.

setAngle(self, value=0.0, units='r')

source code 
Sets the angle. Takes up to two arguments. The first argument (which defaults to zero) is the angle to store, the second argument (which defaults to 'r') indicates the units used, 'r' for radians, 'd' for degrees and 'h' for hours. The angle may be in any form acceptable to the builtin function float(). Alternatively, if value is itself an angle object, this makes the angles equal and the units argument is ignored.

getString(self, units='d', ndp=3)

source code 

Returns a string representation of the angle in sexagesimal or 'time' formats. The optional first parameter units can be 'd', 'h' or 't' for degrees, hours (sexagesimal) or hours (time format), default is 'd'. The optional second parameter, 'ndp', specified the number of decimal places in the seconds field, default 3.

For decimal string representations getAngle() can be used together with standard string formatting commands.

setString(self, angleString, units='d', startPos=1)

source code 

Sets the angle from a string representation. The first argument contains a free format string representing the angle as either a decimal or sexagesimal number (or a combination of the two) and the second is a character specifying the units used ('d' for degrees, 'h' for hours). Uses slaDafin from the slalib module to parse the string. An optional third argument specifies where in the string to start parsing (in a 1 based, not zero based, count).

Returns the position in the string at which encoding finished.

normPi(self)

source code 
Normalises the angle into the range +/-Pi.

norm2Pi(self)

source code 
Normalises the angle into the range 0-2Pi.