Angle

class Angle(value=0.0, units=None)[source]

Bases: object

The Angle class implements a concept of an angle in radians.

This version adapted from the c++ and java implementation originally authored by Allen Farris

Attributes Summary

ARCSECOND

AllowedUnits

DEGREE

HOUR

RADIAN

arcsecondToRad

degToRad

hourToRad

radToArcsecond

radToDeg

radToHour

Methods Summary

acos()

Return the arc cosine of this angle, in the range of 0.0 through <i>pi</i>.

add(a1, a2)

Return a new Angle that is the sum of the specified angles, a1 + a2.

almostEquals(otherAngle, toleranceAngle)

Returns True if and only if otherAngle and toleranceAngle are both Angles and if the distance (absolute value of the difference) between this Angle and otherAngle is less than the absolute value of toleranceAngle.

asin()

Return the arc sine of this angle, in the range of -<i>pi</i>/2 through <i>pi</i>/2.

atan()

Return the arc tangent of this angle, in the range of -<i>pi</i>/2 through <i>pi</i>/2.

compareTo(otherAngle)

Compare this Angle to the specified otherAngle, which must be an Angle.

cos()

Return the trigonometric cosine of this angle.

divide(a, factor)

Return a new Angle that is a specified angle divided by a specified factor, a / factor.

equals(otherAngle)

Returns True if and only if the specified other angle has a value that is equal to this angle.

from1DBin(eis)

Read a list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

from2DBin(eis)

Read a 2D list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

from3Dbin(eis)

Read a 3D list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

fromBin(eis)

Read the binary representation of an Angle, in radians, from an EndianInput instance and use the read value to set an Angle.

get([units])

Return the value of this angle in the specified units.

getInstance(stringList)

Retrieve a value from a list of strings and convert that to an Angle.

isZero()

Return True if and only if this angle is zero (0.0).

listTo1DBin(angleList, eos)

Write a 1D list of Angle to the EndianOutput

listTo2DBin(angleList, eos)

Write a 2D list of Angle to the EndianOutput

listTo3DBin(angleList, eos)

Write a 3D list of Angle to the EndianOutput

listToBin(angleList, eos)

Write a list of Angle to the EndianOutput.

multiply(a, factor)

Return a new Angle that is the product of a specified angle and some specified factor, a * factor.

set(value[, units])

Set the value of this angle to the specified value in the specified units.

sin()

Return the trigonometric sine of this angle.

subtract(a1, a2)

Return a new Angle that is the difference of the specified angles, a1 - a2.

tan()

Return the trigonometric tangent of this angle.

toBin(eos)

Write this Angle out, in radians, to a EndianOutput.

unit()

Return the canonical unit associated with this Angle, radian.

values(items)

return a list of floats containing the value of the list of Angle objects passed in the items argument.

Attributes Documentation

ARCSECOND = 'arcsec'
AllowedUnits = ['rad', 'deg', 'hr', 'arcsec']
DEGREE = 'deg'
HOUR = 'hr'
RADIAN = 'rad'
arcsecondToRad = 4.84813681109536e-06
degToRad = 0.017453292519943295
hourToRad = 0.2617993877991494
radToArcsecond = 206264.80624709636
radToDeg = 57.29577951308232
radToHour = 3.819718634205488

Methods Documentation

acos()[source]

Return the arc cosine of this angle, in the range of 0.0 through <i>pi</i>.

static add(a1, a2)[source]

Return a new Angle that is the sum of the specified angles, a1 + a2. a1 The first Angle of the pair. a2 The second Angle of the pair. return A new Angle that is the sum of the specified angles, a1 + a2.

almostEquals(otherAngle, toleranceAngle)[source]

Returns True if and only if otherAngle and toleranceAngle are both Angles and if the distance (absolute value of the difference) between this Angle and otherAngle is less than the absolute value of toleranceAngle.

asin()[source]

Return the arc sine of this angle, in the range of -<i>pi</i>/2 through <i>pi</i>/2.

atan()[source]

Return the arc tangent of this angle, in the range of -<i>pi</i>/2 through <i>pi</i>/2.

compareTo(otherAngle)[source]

Compare this Angle to the specified otherAngle, which must be an Angle. Returning -1, 0, or +1 if this Angle is less than, equal to, or greater than the other Angle.

cos()[source]

Return the trigonometric cosine of this angle.

static divide(a, factor)[source]

Return a new Angle that is a specified angle divided by a specified factor, a / factor. a The base angle factor The factor that is used to divide the value. return A new Angle that is the quotient of a specified angle and some specified factor, a / factor.

equals(otherAngle)[source]

Returns True if and only if the specified other angle has a value that is equal to this angle.

static from1DBin(eis)[source]

Read a list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

static from2DBin(eis)[source]

Read a 2D list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

static from3Dbin(eis)[source]

Read a 3D list of binary Angle values, in radians, from an EndianInput instance and return the resulting list.

static fromBin(eis)[source]

Read the binary representation of an Angle, in radians, from an EndianInput instance and use the read value to set an Angle.

return an Angle

get(units=None)[source]

Return the value of this angle in the specified units. When units is None (the default) the returned units are RADIAN. Recognized units are None (RADIAN), RADIAN, DEGREE, HOUR, and ARCSECOND.

static getInstance(stringList)[source]

Retrieve a value from a list of strings and convert that to an Angle.

This is used when parsing Angle lists from an XML representation to eventually construct a list of Angle instances. The strings are float representations of the angle in radians.

Returns a tuple of (Angle, stringList) where Angle is the new Angle created by this call and stringList is the remaining, unused, part of stringList after removing the first element.

isZero()[source]

Return True if and only if this angle is zero (0.0).

static listTo1DBin(angleList, eos)[source]

Write a 1D list of Angle to the EndianOutput

static listTo2DBin(angleList, eos)[source]

Write a 2D list of Angle to the EndianOutput

static listTo3DBin(angleList, eos)[source]

Write a 3D list of Angle to the EndianOutput

static listToBin(angleList, eos)[source]

Write a list of Angle to the EndianOutput. The list may have 1, 2 or 3 dimensions.

static multiply(a, factor)[source]

Return a new Angle that is the product of a specified angle and some specified factor, a * factor. a The base angle factor The factor that is used to multiply the value. return A new Angle that is the product of a specified angle and some specified factor, a * factor.

set(value, units=None)[source]

Set the value of this angle to the specified value in the specified units. Any value is valid so long as it can be converted into a float using float(value) (including a parseable string). The units default to RADIAN. Recognized units are RADIAN, DEGREE, HOUR, and ARCSECOND.

sin()[source]

Return the trigonometric sine of this angle.

static subtract(a1, a2)[source]

Return a new Angle that is the difference of the specified angles, a1 - a2. a1 The first Angle of the pair. a2 The second Angle of the pair. return A new Angle that is the difference of the specified angles, a1 - a2.

tan()[source]

Return the trigonometric tangent of this angle.

toBin(eos)[source]

Write this Angle out, in radians, to a EndianOutput.

static unit()[source]

Return the canonical unit associated with this Angle, radian. The unit associated with this Angle, always returns RADIAN.

static values(items)[source]

return a list of floats containing the value of the list of Angle objects passed in the items argument. items may also be a list of lists (2D array) of Angle objects. If the first item is a list then this method assumes that items is a list of list and the return value is a list of lists of floats. The list of lists case is done by calling this method recursively and so should work for higher levels of lists of lists. That use case is not tested.