Binary scaling: Difference between revisions

Content deleted Content added
Undid revision 1006704183 by SoyokoAnis (talk). there is a sign bit, left of the binary point ...
{{anchor|BAM}}Binary angles: uniform use of units
Line 64:
[[Image:Binary angles.svg|360px|thumb|Binary scaling (B0) representation of angles. <span style="color:black">Black</span> is traditional degrees representation, <span style="color:green">green</span> is BAM as a decimal number and <span style="color:red">red</span> is [[hexadecimal]] 32&nbsp;bit representation of the BAM.]]
 
Binary angles are mapped using B0, with 0 as 0 degrees, 0.5 as 90° (or <math>\tfrac{1}{2}\pi</math>), −1.0 or 0.9999999 as 180° (or {{math|π}} rad), and −0.5 as 270° (or <math>\tfrac{3}{2}\pi</math>). When these binary angles are added using normal [[two's complement]] mathematics, the rotation of the angles is correct, even when crossing the sign boundary; this conveniently does away with checks for angles ≥ 360° when handling ordinary angles<ref name="Hargreaves_2010"/> (data that allow angles with more than one rotation must use some other encoding).
 
The terms '''binary angular measurement''' ('''BAM''')<ref name="ship"/> and '''binary angular measurement system''' ('''BAMS''')<ref name="BAMS"/> as well as '''brads''' ('''binary radians''' or '''binary degree''') refer to implementations of binary angles. They find use in robotics, navigation,<ref name="LaPlante_2004"/> computer games,<ref name="Sanglard_1993"/> and digital sensors.<ref name="Parallax_2005"/>
 
No matter what bit-pattern is stored in a binary angle, when it is multiplied by 180° (or {{math|π}} rad) using standard signed [[fixed-point arithmetic]], the result is always a valid angle in the range of −180&nbsp;[[degree (angle)|degree]]s ({{math|−π}}&nbsp;[[radian]]s) to +180&nbsp;degrees ({{math|+π}}&nbsp;radians).
In some cases, it is convenient to use unsigned multiplication (rather than signed multiplication) on a binary angle, which gives the correct angle in the range of 0 to +360&nbsp;degrees ({{math|+2π}}&nbsp;radians or +1 [[turn (geometry)|turn]]).
Compared to storing angles in a binary angle format, storing angles in any other format inevitably results in some bit patterns giving "angles" outside that range, requiring extra steps to [[trigonometric functions#Computation|range-reduce]] the value to the desired range, or results in some bit patterns that are not valid angles at all ([[NaN]]), or both.