Jump to content

Angle difference between two bearings: Difference between revisions

Added XBS
(Added AutoHotkey)
(Added XBS)
Line 3,549:
1174.8380510598 and -154146.66490125 -> -161.503
60175.773067955 and 42213.071923544 -> 37.2989
</pre>
 
=={{header|XBS}}==
<lang xbs>settype Bearing = {Angle:number}
class Bearing {
construct:function = func(self:Bearing|object,Angle:number=0){
self:Angle=(((Angle%360)+540)%360)-180
}
ToString:function = func(self:Bearing):string{
send tostring(math.nround(self.Angle,4))+"°";
}
__sub:function = func(self:Bearing,b2:Bearing):Bearing{
send new Bearing(self.Angle-b2.Angle);
}
}
 
const BearingAngles:[[number]] = [
[20,45],
[-45,45],
[-85,90],
[-95,90],
[-45,125],
[-45,145],
[29.4803,-88.6381],
[-78.3251,-159.036],
[-70099.74233810938,29840.67437876723],
[-165313.6666297357,33693.9894517456],
[1174.8380510598456,-154146.66490124757],
[60175.77306795546,42213.07192354373],
]
 
foreach(v of BearingAngles){
set b1:Bearing=new Bearing(v[0]);
set b2:Bearing=new Bearing(v[1]);
log(b2::ToString()+" - "+b1::ToString()+" = "+(b2-b1)::ToString());
}</lang>
{{out}}
<pre>
45° - 20° = 25°
45° - -45° = 90°
90° - -85° = 175°
90° - -95° = -175°
125° - -45° = 170°
145° - -45° = -170°
-88.6381° - 29.4803° = -118.1184°
-159.036° - -78.3251° = -80.7109°
-39.3256° - 100.2577° = -139.5833°
-146.0105° - -73.6666° = -72.3439°
-66.6649° - 94.8381° = -161.503°
93.0719° - 55.7731° = 37.2989°
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.