Package: angle-headings
Angle HeadingsA lightweight Python class for representing and performing calculations with angles.This is a small class meant to simplify common operations with angle measures. The convention used for the arithmetic and comparison operations is meant to capture the idea that we are primarily interested in the smallest angle between two measures, regardless of the numbers, themselves. In particular this includes the following conventions:Angles that differ by an integer number of revolutions are considered equivalent.Output angle values are limited in size to±1/2full revolution. For example, radian angle measures are restricted to the interval(-π,π], while degree angle measures are restricted to(-180,180].Angle comparisons are based on the smallest angle between the two input angles, and on whether the first angle is closer to being clockwise or counterclockwise from the first. By convention we say thatA > Bif the smallest angle betweenAandBplacesAcounterclockwise relative toB, andA < Bif the smallest angle betweenAandBplacesAclockwise relative toB.Radian, degree, and gradian measure (or any arbitrary subdivision of the circle) are all supported. Methods perform calculations and return results using the measure of their own angle object, converting other angles or floats when necessary.Installation and UsageThis package can be downloaded fromPyPIusing the following console command:$ pip install angle-headingsIt can then be imported into a Python program as theangle_headingspackage.Since this package defines only a single class, it is recommended to usefromangle_headingsimportAngleto avoid the need for theangle_headingsprefix.Theangle_headings.AngleClassThe following is a brief description of selected attributes, custom methods, and overloaded methods for theangle_headings.Angleclass.Attributesmeasure (float)-- Current measure of the angle, always normalized to±1/2full revolutions.mod (float)-- Measure of a complete revolution (e.g.2πfor radian measure,360for degree measure).unit (str)-- Name of the  unit of measure.Methods__init__([measure[, mod]])--angle_headings.Angleclass constructor. Accepts the following keyword arguments:measure (float) [0.0]-- Initial angle measure.mod (int, float, or str) ["radians"]-- Specifies measure unit. A numerical argument is treated as the measure of a full revolution, while a string argument is taken as the name of a standard unit (radians, degrees, or gradians).convert(mod)-- Returns the angle's measure converted to a different unit.reldiff(other)-- Returns a relative difference between this and another angles' measures, normalized so that 0 represents equality and 1 represents diametrically opposed angles. This is meant to be used as an alternative to direct equality comparisons due to thefloatmeasures.float-Valued Operatorsabs(A)-- Returns the absolute value of an angle's measure.int(A)-- Returns an angle's measure, cast as an integer.float(A)-- Returns an angle's measure, cast as a float.round(A)-- Returns an angle's measure, rounded to the nearest integer.angle_headings.Angle-Valued OperatorsUnary Operators+A-- Returns an exact copy of theangle_headings.Angleobject.-A-- Returns a copy of theangle_headings.Angleobject with its measure negated.Overloaded Binary OperatorsEach of the following operators accepts either anotherangle_headings.Angleobject or afloatas its second argument. If given anotherangle_headings.Angle, the secondangle_headings.Angleis converted to the firstangle_headings.Angle's unit before the operation is performed. If given afloat, the number is used directly.A + B-- Returns anangle_headings.Angleobject with the sum of two angles' measures.A - B-- Returns anangle_headings.Angleobject with the difference between two angles' measures.Scalar OperatorsA * b-- Returns anangle_headings.Angleobject with its measure multiplied by a scalar.A / b-- Returns anangle_headings.Angleobject with its measure divided by a scalar.A // b-- Returns anangle_headings.Angleobject with its measure floor divided by a scalar.A ** b-- Returns anangle_headings.Angleobject with its measure raised to a scalar power.Overloaded Boolean OperatorsEach of the following operators accepts either anotherangle_headings.Angleobject or afloatas its second argument. If given anotherangle_headings.Angle, the secondangle_headings.Angleis converted to the firstangle_headings.Angle's unit before the operation is performed. If given afloat, the number is used directly.Equality ComparisonsDue to the fact that each angle's measure is stored as afloat, it is not recommended to directly test measure equality, and to instead make use of theAngle.reldiff()method.A == B-- Tests for equality of two measures (after unit conversion and normalization).A != B-- Tests for inequality of two measures.Order ComparisonsThe following comparisons are based on the smallest angle between two given measures.A > B-- ReturnsTrueif and only if the smallest angle betweenAandBplacesAcounterclockwise relative toB.A >= B-- ReturnsTrueif and only ifA > BorA == B.A < B-- ReturnsTrueif and only if the smallest angle betweenAandBplacesAclockwise relative toB.A <= B-- ReturnsTrueif and only ifA < BorA == B.