element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
NexGen Flight Simuator Flight Simulator 101 or back to college - part 9: Those Pesky Angles.
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: phoenixcomm
  • Date Created: 24 May 2016 9:15 PM Date Created
  • Views 1473 views
  • Likes 5 likes
  • Comments 4 comments
  • knots 2 mph
  • nexgen
  • radians 2 degrees
  • knots 2 degrees
  • degrees 2 nautical miles
  • nautical miles 2 standard mile
  • real time systems design and analysis
  • mathatics
  • software:
  • nautical miles 2 degrees
  • degrees 2 radians
  • radians 2 nautical mile
  • degrees 2 knots
  • flight simulation
  • c programming
  • phillip a. laplante
  • feature_tutorial
  • radian
  • bam
  • degrees
Related
Recommended

Flight Simulator 101 or back to college - part 9: Those Pesky Angles.

phoenixcomm
phoenixcomm
24 May 2016

If you look up Angle in the Wikipedia, it claims that there are four (4) methods of measuring angles: Degrees, Radians, Turns, and Gons. But they are really five (5) and that is BAM or Binary Angular Measurement.

If we get rid of Turns, and Gons. That leaves three (3): Degrees, Radians, BAM. Only Radians and Degrees units of measurement do well with Floating Point math.  But when we use BAMs its BAM32 or BAM16 and they are Fixed Point Math. So I will show you Degrees to Radian back to Degrees and will show you the math behind a BAM (Not Fixed Point).

 

SSR Engineering, Inc. "BAMs are used to represent an angular measure; there are 65,535 BAMs per 360°.  An angle provided in BAMs can be converted to degrees by the following relationship:"
Angle (Degrees) = (360 / 65,535) * Angle (BAMs)

, You can re-write this as follows to make this universal:

where Angle, Bams are variables

where n represents the power of 2

Angle = (360 / 2**(n-1)) * Bams

 

Therefore you can rewrite this into a function:

 

typedef int degrees;

degrees Bams2degrees(  double Bans, int n){

    return (360/ pow(2,(n-1)) * Bams); }

 

This is written in  ANSI C. I have typedef both Degrees and Radians, to make the library more readable.

 

 

typedef double Degrees;

typedef double Radians;

Radians <> Degrees
Knots
Nautical Miles
DMS <> Degrees

// Radians 2 Degrees

Degrees rad2d( Radians rad ) {
  return( rad * 180.0/pi );}

//  Knots 2 Degrees

double kn2d( double knots ) {

return( knots/60 );}

//  Nautical Miles 2 Degrees

Degrees nm2d( double d ){

return( d * pi/180.0 * 60.0 );}

// dms2d should take any struct of type dms_s  and convert to degrees

double dms2d( struct dms_s DMS) {
double d1, m; Degrees d;

Degrees d;
m = DMS.S/60.0;
d1 = (m + DMS.M)/60.0;
d = DMS.D + d1;
return(d);}

// Degrees 2 Radians

Radians d2rad( Degrees d ) {

  return( d * pi/180.0 );}

//  Knots 2 MPH

double kn2mph( double knots ){

return( d2rad( kn2d( knots )));}

//  Degrees 2 Nautical Miles

double d2nm( Degrees d ) {
return( d * 180.0 * 60.0/pi );}

Note that the C Math Library does not have pi defined:

pi = atan2(1,1) *4;

 

struct dms_s {

  Degrees deg;

  char hemisphere;  // This is a hold over from Perl and not used

};

 

 

 

struct location_s {

  char ID[5]; // IDs are 4 letters long + trailing \n"

  struct dms_s NS;

  struct dms_s EW;

  double alt; // Station altitude. in feet

};

 

struct DMS_s {

double D;  // Degrees

double M; // Minutes

double S; // Seconds

} DMS;

//  Nautical Miles 2 Standard Mile 

double nm2sm( double nm ) {

return( nm * 1.151 );}

// d2dms should take a decimal angle and convert it to any struct of type dms_s
void d2dms( Degrees d ){
int s;
//  the +0.5 is to get rid of the rounding errors.
//  there are 3600 seconds in one degree
s = (int)(d*36000000+0.5);
DMS.S = s%600000/10000.0;
s = s/600000.0;
DMS.M = s%60;
s = s/60;
//  the %360 is to make sure that we don't report 360 degrees.
DMS.D = s%360;
return;}

// Radians 2 Nautical Miles

Radians2nm( Radians rad ){

return( rad * 3437.7387 );}

 

I have included the following information for a .h or header file.

 

Description of Functions
Function header file information
Degrees to:
Degrees 2 DMSvoid d2dms( Degrees d );
Degrees 2 Nautical Milesdouble d2nm( Degrees d );
Degrees 2 RadiansRadians d2rad( Degrees d );
DMS 2 Dregees double dms2d( struct dms_s DMS);
Knots to:
Knots 2 Degreesdouble kn2d( double knots );
Knots 2 MPHdouble kn2mph( double knots );
Nautical Miles to:
Nautical Miles 2 DegreesDegrees nm2d( double d );
Nautical Miles 2 Standard Miledouble nm2sm( double nm );
Radians to:
Radians 2 DegreesDegrees rad2d( Radians rad )
Radians 2 Nautical MileRadians2nm( Radians rad );

 

I have included the following description of a BAM. This is what  a BAM16 is.  You can create BAM32 with which you can describe any location on Earth with the size of a postage stamp.

Real Time Systems Design And Analysis

Chapter 7.5.3. - Binary Angular Measure

By Phillip A. LaPlante

Another type of scaled number is based on the property that adding 180o to any
angle is analogous to taking its two’s complement. This technique, called binary angular measurement (BAM) works as follows.
Consider the LSB of an n-bit word to be 2n−1 · 180 degrees with the most significant bit (MSB) = 180 degrees.
The range of any angle θ represented this way is 0 ≤ θ ≤ 360 − 180 · 2(n−1)

degrees. A 16-bit BAM word is shown in Figure 7.6. For more accuracy, BAM can be extended to two more words.

Each n-bit word has a maximum value of:  2n - 2-(n−1) · 180o  = 360o - LSB

with granularity: 2-(n−1) · 180o  = LSB

 

Consider the 16-bit BAM word:  0000 0000 10100 110

Its binary angular measurement is 166 · 180o · 2−15 = 0.9118o.

 

180904522.5..............................180 · 2-14180 · 2-15
Figure 7.6 16 bit Binary Angular Mesurement word [Lapante]

 

BAM can be added and subtracted together and multiplied and divided by constants as if they were unsigned integers, and converted at the last stage to produce floating-point results.

It is easy to show that the overflow condition for BAM numbers presents no problem as the angle simply wraps around to 0.

BAM is frequently used in navigation software, robotic control, and in conjunction with digitizing imaging devices.

  • Sign in to reply
  • D_Hersey
    D_Hersey over 9 years ago

    I did use this scheme once to iterate toward the dihederal angles of a snub dodecahedron.  Worked well.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • D_Hersey
    D_Hersey over 9 years ago

    All depends upon what you are doing.  In my work with tessellations in software, a rational (integer/integer) with whole turns is a wonderful ticket because 1/3+1/3+1/3 = 1.  This binary stuff might be good for some cybernetic situations, though.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Brings back memories of my navigation projects.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 9 years ago

    Very interesting. This is the first time I have heard of BAM.

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube