Binary angular measurement

Last updated

Binary angular measurement (BAM) [1] (and the binary angular measurement system, BAMS [2] ) is a measure of angles using binary numbers and fixed-point arithmetic, in which a full turn is represented by the value 1. The unit of angular measure used in those methods may be called binary radian (brad) or binary degree.

Contents

These representation of angles are often used in numerical control and digital signal processing applications, such as robotics, navigation, [3] computer games, [4] and digital sensors, [5] taking advantage of the implicit modular reduction achieved by truncating binary numbers. It may also be used as the fractional part of a fixed-point number counting the number of full rotations of e.g. a vehicle's wheels or a leadscrew.

Representation

Unsigned fraction of turn

In this system, an angle is represented by an n-bit unsigned binary number in the sequence 0, ..., 2n−1 that is interpreted as a multiple of 1/2n of a full turn; that is, 360/2n degrees or 2π/2n radians. The number can also be interpreted as a fraction of a full turn between 0 (inclusive) and 1 (exclusive) represented in binary fixed-point format with a scaling factor of 1/2n. Multiplying that fraction by 360° or 2π gives the angle in degrees in the range 0 to 360, or in radians, in the range 0 to 2π, respectively.

For example, with n = 8, the binary integers (00000000)2 (fraction 0.00), (01000000)2 (0.25), (10000000)2 (0.50), and (11000000)2 (0.75) represent the angular measures 0°, 90°, 180°, and 270°, respectively.

The main advantage of this system is that the addition or subtraction of the integer numeric values with the n-bit arithmetic used in most computers produces results that are consistent with the geometry of angles. Namely, the integer result of the operation is automatically reduced modulo 2n, matching the fact that angles that differ by an integer number of full turns are equivalent. Thus one does not need to explicitly test or handle the wrap-around, as one must do when using other representations (such as number of degrees or radians in floating-point). [6]

Signed fraction of turn

Signed binary angle measurement. Black is traditional degrees representation, green is a BAM as a decimal number and red is hexadecimal 32-bit BAM. In this figure the 32-bit binary integers are interpreted as signed binary fixed-point values with scaling factor 2 , representing fractions between -1.0 (inclusive) and +1.0 (exclusive). Binary angles.svg
Signed binary angle measurement. Black is traditional degrees representation, green is a BAM as a decimal number and red is hexadecimal 32-bit BAM. In this figure the 32-bit binary integers are interpreted as signed binary fixed-point values with scaling factor 2 , representing fractions between −1.0 (inclusive) and +1.0 (exclusive).

Alternatively, the same n bits can also be interpreted as a signed integer in the range −2n−1, ..., 2n−1−1 in the two's complement convention. They can also be interpreted as a fraction of a full turn between −0.5 (inclusive) and +0.5 (exclusive) in signed fixed-point format, with the same scaling factor; or a fraction of half-turn between −1.0 (inclusive) and +1.0 (exclusive) with scaling factor 1/2n−1.

Either way, these numbers can then be interpreted as angles between −180° (inclusive) and +180° (exclusive), with −0.25 meaning −90° and +0.25 meaning +90°. The result of adding or subtracting the numerical values will have the same sign as the result of adding or subtracting angles, once reduced to this range. This interpretation eliminates the need to reduce angles to the range [−π, +π] when computing trigonometric functions.

Example

In the orbital data broadcast by the Global Positioning System, angles are encoded using binary angular measurement. In particular, each satellite broadcasts an ephemeris containing its six Keplerian orbital elements. Four of these are angles, which are encoded as 32-bit binary angles. In the lower-precision almanac data, 24-bit binary angles are used.

See also

Related Research Articles

<span class="mw-page-title-main">Angle</span> Figure formed by two rays meeting at a common point

In Euclidean geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. Angles formed by two rays are also known as plane angles as they lie in the plane that contains the rays. Angles are also formed by the intersection of two planes; these are called dihedral angles. Two intersecting curves may also define an angle, which is the angle of the rays lying tangent to the respective curves at their point of intersection.

<span class="mw-page-title-main">Minute and second of arc</span> Units for measuring angles

A minute of arc, arcminute (arcmin), arc minute, or minute arc, denoted by the symbol , is a unit of angular measurement equal to 1/60 of one degree. Since one degree is 1/360 of a turn, or complete rotation, one arcminute is 1/21600 of a turn. The nautical mile (nmi) was originally defined as the arc length of a minute of latitude on a spherical Earth, so the actual Earth circumference is very near 21600 nmi. A minute of arc is π/10800 of a radian.

<span class="mw-page-title-main">Radian</span> SI derived unit of angle

The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. It is defined such that one radian is the angle subtended at the centre of a circle by an arc that is equal in length to the radius. The unit was formerly an SI supplementary unit and is currently a dimensionless SI derived unit, defined in the SI as 1 rad = 1 and expressed in terms of the SI base unit metre (m) as rad = m/m. Angles without explicitly specified units are generally assumed to be measured in radians, especially in mathematical writing.

A computer number format is the internal representation of numeric values in digital device hardware and software, such as in programmable computers and calculators. Numerical values are stored as groupings of bits, such as bytes and words. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the encoding used by the computer's instruction set generally requires conversion for external use, such as for printing and display. Different types of processors may have different internal representations of numerical values and different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

Double-precision floating-point format is a floating-point number format, usually occupying 64 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

<span class="mw-page-title-main">Angular frequency</span> Rate of change of angle

In physics, angular frequency, also called angular speed and angular rate, is a scalar measure of the angle rate or the temporal rate of change of the phase argument of a sinusoidal waveform or sine function . Angular frequency is the magnitude of the pseudovector quantity angular velocity.

<span class="mw-page-title-main">Gradian</span> Unit of measurement of an angle, equal to 1/400th of a circle

In trigonometry, the gradian – also known as the gon, grad, or grade – is a unit of measurement of an angle, defined as one-hundredth of the right angle; in other words, 100 gradians is equal to 90 degrees. It is equivalent to 1/400 of a turn, 9/10 of a degree, or π/200 of a radian. Measuring angles in gradians is said to employ the centesimal system of angular measurement, initiated as part of metrication and decimalisation efforts.

In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operations and directly supported by the processor. Most bitwise operations are presented as two-operand instructions where the result replaces one of the input operands.

Two's complement is the most common method of representing signed integers on computers, and more generally, fixed point binary values. Two's complement uses the binary digit with the greatest value as the sign to indicate whether the binary number is positive or negative; when the most significant bit is 1 the number is signed as negative and when the most significant bit is 0 the number is signed as positive. As a result, non-negative numbers are represented as themselves: 6 is 0110, zero is 0000, and -6 is 1010. Note that while the number of binary bits is fixed throughout a computation it is otherwise arbitrary.

<span class="mw-page-title-main">Power of two</span> Two raised to an integer power

A power of two is a number of the form 2n where n is an integer, that is, the result of exponentiation with number two as the base and integer n as the exponent.

In computing, fixed-point is a method of representing fractional (non-integer) numbers by storing a fixed number of digits of their fractional part. Dollar amounts, for example, are often stored with exactly two fractional digits, representing the cents. More generally, the term may refer to representing fractional values as integer multiples of some fixed small unit, e.g. a fractional amount of hours as an integer multiple of ten-minute intervals. Fixed-point number representation is often contrasted to the more complicated and computationally demanding floating-point representation.

<span class="mw-page-title-main">Rotational frequency</span> Number of rotations per unit time

Rotational frequency, also known as rotational speed or rate of rotation, is the frequency of rotation of an object around an axis. Its SI unit is the reciprocal seconds (s−1); other common units of measurement include the hertz (Hz), cycles per second (cps), and revolutions per minute (rpm).

<span class="mw-page-title-main">Turn (angle)</span> Unit of plane angle where a full circle equals 1

The turn is a unit of plane angle measurement equal to the angular measure subtended by a complete circle at its center. It is equal to 2π radians, 360 degrees or 400 gradians. As an angular unit, one turn also corresponds to one cycle or to one revolution. Common related units of frequency are cycles per second (cps) and revolutions per minute (rpm). The angular unit of the turn is useful in connection with, among other things, electromagnetic coils, rotating objects, and the winding number of curves.

<span class="mw-page-title-main">Degree (angle)</span> Unit of plane angle where a full circle equals 360°

A degree, usually denoted by °, is a measurement of a plane angle in which one full rotation is 360 degrees.

In computing, signedness is a property of data types representing numbers in computer programs. A numeric variable is signed if it can represent both positive and negative numbers, and unsigned if it can only represent non-negative numbers.

<span class="mw-page-title-main">Milliradian</span> Angular measurement, thousandth of a radian

A milliradian is an SI derived unit for angular measurement which is defined as a thousandth of a radian (0.001 radian). Milliradians are used in adjustment of firearm sights by adjusting the angle of the sight compared to the barrel. Milliradians are also used for comparing shot groupings, or to compare the difficulty of hitting different sized shooting targets at different distances. When using a scope with both mrad adjustment and a reticle with mrad markings, the shooter can use the reticle as a ruler to count the number of mrads a shot was off-target, which directly translates to the sight adjustment needed to hit the target with a follow-up shot. Optics with mrad markings in the reticle can also be used to make a range estimation of a known size target, or vice versa, to determine a target size if the distance is known, a practice called "milling".

Many protocols and algorithms require the serialization or enumeration of related entities. For example, a communication protocol must know whether some packet comes "before" or "after" some other packet. The IETF RFC 1982 attempts to define "serial number arithmetic" for the purposes of manipulating and comparing these sequence numbers. In short, when the absolute serial number value decreases by more than half of the maximum value, it is considered to be "after" the former, whereas other decreases are considered to be "before".

The Q notation is a way to specify the parameters of a binary fixed point number format. For example, in Q notation, the number format denoted by Q8.8 means that the fixed point numbers in this format have 8 bits for the integer part and 8 bits for the fraction part.

<span class="mw-page-title-main">Sine and cosine</span> Fundamental trigonometric functions

In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is opposite that angle to the length of the longest side of the triangle, and the cosine is the ratio of the length of the adjacent leg to that of the hypotenuse. For an angle , the sine and cosine functions are denoted as and .

Single-precision floating-point format is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

References

  1. "Binary angular measurement". Archived from the original on 2009-12-21.
  2. "Binary Angular Measurement System". acronyms.thefreedictionary.
  3. LaPlante, Phillip A. (2004). "Chapter 7.5.3, Binary Angular Measure". Real-Time Systems Design and Analysis. ISBN   0-471-22855-9.
  4. Sanglard, Fabien (2010-01-13). "Doom 1993 code review - Section "Walls"". fabiensanglard.net.
  5. "Hitachi HM55B Compass Module (#29123)" (PDF). www.hobbyengineering.com. Parallax Digital Compass Sensor (#29123). Parallax, Inc. May 2005. Archived from the original (PDF) on 2011-07-11 via www.parallax.com.
  6. Hargreaves, Shawn [in Polish]. "Angles, integers, and modulo arithmetic". blogs.msdn.com. Archived from the original on 2019-06-30. Retrieved 2019-08-05.