Skip to content

Commit ffe0b7d

Browse files
authored
Small improvements (#74)
I noticed that this repository uses multiple symbols to signify degree signs in its code, documentation, and outputs: * A few places used `U+00B0` ° DEGREE SIGN, which is the correct symbol. * In many other places, `U+00BA` º MASCULINE ORDINAL INDICATOR was in use, which is visually similar, but semantically wrong and lead to some screen readers pronouncing angles weirdly. This change replaces the ordinal indicators with degree signs. Apologies, if this is too pedantic.
1 parent a4bc103 commit ffe0b7d

File tree

10 files changed

+40
-42
lines changed

10 files changed

+40
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7474

7575
### Changed
7676

77-
- Uphold bearing azimuth guarantee for 90º elevation in ENU
77+
- Uphold bearing azimuth guarantee for 90° elevation in ENU
7878
([#34](https://github.com/helsing-ai/sguaba/pull/34)).
7979

8080
## [0.9.4]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ how far North, East, and Down (towards Earth's core) they are relative
6565
to the observer. [FRD], meanwhile, is a "body frame", and just describes
6666
positions relative to the observer's concept of Forward (eg, the
6767
direction pointing in the same direction as the nose of a plane), Right
68-
(eg, the direction 90º to the right when viewing along Forward), and
68+
(eg, the direction 90° to the right when viewing along Forward), and
6969
Down (eg, down through the belly of the plane). Converting between [FRD]
7070
and [NED] usually requires knowing the orientation of the observer
7171
relative to North, East, and Down, and converting between [NED] and
@@ -107,15 +107,15 @@ let observation = Coordinate::<PlaneFrd>::from_bearing(
107107
.azimuth(Angle::new::<degree>(20.))
108108
// upwards from straight-ahead
109109
.elevation(Angle::new::<degree>(10.))
110-
.expect("elevation is in [-90º, 90º]")
110+
.expect("elevation is in [-90°, 90°]")
111111
.build(),
112112
Length::new::<meter>(400.), // at this range
113113
);
114114

115115
// where the plane was at the time (eg, from GPS):
116116
let wgs84 = Wgs84::builder()
117117
.latitude(Angle::new::<degree>(12.))
118-
.expect("latitude is in [-90º, 90º]")
118+
.expect("latitude is in [-90°, 90°]")
119119
.longitude(Angle::new::<degree>(30.))
120120
.altitude(Length::new::<meter>(1000.))
121121
.build();

examples/pilot-as-engineer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ fn main() {
2424
.azimuth(Angle::new::<degree>(20.))
2525
// upwards from straight-ahead
2626
.elevation(Angle::new::<degree>(10.))
27-
.expect("elevation is in [-90º, 90º]")
27+
.expect("elevation is in [-90°, 90°]")
2828
.build(),
2929
Length::new::<meter>(400.), // at this range
3030
);
3131

3232
// where the plane was at the time (eg, from GPS):
3333
let wgs84 = Wgs84::builder()
3434
.latitude(Angle::new::<degree>(12.))
35-
.expect("latitude is in [-90º, 90º]")
35+
.expect("latitude is in [-90°, 90°]")
3636
.longitude(Angle::new::<degree>(30.))
3737
.altitude(Length::new::<meter>(1000.))
3838
.build();

examples/pilot-as-mathematician.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ fn main() {
2828
.azimuth(Angle::new::<degree>(20.))
2929
// upwards from straight-ahead
3030
.elevation(Angle::new::<degree>(10.))
31-
.expect("elevation is in [-90º, 90º]")
31+
.expect("elevation is in [-90°, 90°]")
3232
.build(),
3333
Length::new::<meter>(400.), // at this range
3434
);
3535

3636
// where the plane was at the time (eg, from GPS):
3737
let wgs84 = Wgs84::builder()
3838
.latitude(Angle::new::<degree>(12.))
39-
.expect("latitude is in [-90º, 90º]")
39+
.expect("latitude is in [-90°, 90°]")
4040
.longitude(Angle::new::<degree>(30.))
4141
.altitude(Length::new::<meter>(1000.))
4242
.build();

examples/target-aquisition-and-confirmation.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ fn main() {
2929
let plane_bearing: Bearing<PlaneNed> = Bearing::builder()
3030
.azimuth(Angle::new::<degree>(204.74)) // clockwise from North
3131
.elevation(Angle::new::<degree>(0.)) // level with the horizon
32-
.expect("elevation is in [-90º, 90º]")
32+
.expect("elevation is in [-90°, 90°]")
3333
.build();
3434

3535
// Values from the pilot's range finder, manually picked to align with the actual target position (see bottom).
3636
let target_range = Length::new::<meter>(14824.);
3737
let target_bearing: Bearing<PlaneFrd> = Bearing::builder()
3838
.azimuth(Angle::new::<degree>(10.)) // clockwise from forward
3939
.elevation(Angle::new::<degree>(5.342)) // above nose
40-
.expect("elevation is in [-90º, 90º]")
40+
.expect("elevation is in [-90°, 90°]")
4141
.build();
4242

4343
// Value from the ground control's known location
4444
let ground_control_wgs84 = Wgs84::builder()
4545
.latitude(Angle::new::<degree>(33.6954))
46-
.expect("latitude is in [-90º, 90º]")
46+
.expect("latitude is in [-90°, 90°]")
4747
.longitude(Angle::new::<degree>(-78.8802))
4848
.altitude(Length::new::<meter>(3.))
4949
.build();
@@ -54,7 +54,7 @@ fn main() {
5454
Bearing::builder()
5555
.azimuth(Angle::new::<degree>(84.574)) // clockwise from North
5656
.elevation(Angle::new::<degree>(52.582)) // above the horizon
57-
.expect("elevation is in [-90º, 90º]")
57+
.expect("elevation is in [-90°, 90°]")
5858
.build(),
5959
Length::new::<meter>(22236.3), // distance to plane
6060
);
@@ -139,15 +139,15 @@ fn main() {
139139
// Sanity checking example against expected coordinates and manually calculated values
140140
let expected_plane_wgs84 = Wgs84::builder()
141141
.latitude(Angle::new::<degree>(33.7068))
142-
.expect("latitude is in [-90º, 90º]")
142+
.expect("latitude is in [-90°, 90°]")
143143
.longitude(Angle::new::<degree>(-78.7355))
144144
.altitude(Length::new::<meter>(17678.))
145145
.build();
146146
let expected_plane_ecef = Coordinate::<Ecef>::from_wgs84(&expected_plane_wgs84);
147147

148148
let expected_target_wgs84 = Wgs84::builder()
149149
.latitude(Angle::new::<degree>(33.597744245441966))
150-
.expect("latitude is in [-90º, 90º]")
150+
.expect("latitude is in [-90°, 90°]")
151151
.longitude(Angle::new::<degree>(-78.82584635802755))
152152
.altitude(Length::new::<meter>(19075.36499))
153153
.build();
@@ -158,7 +158,7 @@ fn main() {
158158
let expected_ground_bearing_to_target = Bearing::<GroundEnu>::builder()
159159
.azimuth(Angle::new::<degree>(155.02306))
160160
.elevation(Angle::new::<degree>(57.84293))
161-
.expect("elevation is in [-90º, 90º]")
161+
.expect("elevation is in [-90°, 90°]")
162162
.build();
163163

164164
println!(

src/directions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use uom::ConstZero;
4545
/// .azimuth(Angle::new::<degree>(20.))
4646
/// // upwards from straight-ahead
4747
/// .elevation(Angle::new::<degree>(10.))
48-
/// .expect("elevation is in [-90º, 90º]")
48+
/// .expect("elevation is in [-90°, 90°]")
4949
/// .build();
5050
/// ```
5151
///
@@ -61,7 +61,7 @@ use uom::ConstZero;
6161
/// azimuth: Angle::new::<degree>(20.),
6262
/// // upwards from straight-ahead
6363
/// elevation: Angle::new::<degree>(10.),
64-
/// }).expect("elevation is in [-90º, 90º]");
64+
/// }).expect("elevation is in [-90°, 90°]");
6565
/// ```
6666
///
6767
/// [bearing]: https://en.wikipedia.org/wiki/Bearing_%28navigation%29
@@ -506,10 +506,10 @@ mod tests {
506506

507507
// Test with radians at boundaries
508508
use std::f64::consts::FRAC_PI_2;
509-
let bearing7 = bearing!(azimuth = rad(0.0), elevation = rad(1.5707963267948966); in Frd);
509+
let bearing7 = bearing!(azimuth = rad(0.0), elevation = rad(FRAC_PI_2); in Frd);
510510
assert_relative_eq!(bearing7.elevation().get::<radian>(), FRAC_PI_2);
511511

512-
let bearing8 = bearing!(azimuth = rad(0.0), elevation = rad(-1.5707963267948966); in Frd);
512+
let bearing8 = bearing!(azimuth = rad(0.0), elevation = rad(-FRAC_PI_2); in Frd);
513513
assert_relative_eq!(bearing8.elevation().get::<radian>(), -FRAC_PI_2);
514514
}
515515

src/geodetic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,14 @@ mod tests {
814814
// Test with radians at boundaries
815815
use std::f64::consts::FRAC_PI_2;
816816
let location7 = wgs84!(
817-
latitude = rad(1.5707963267948966),
817+
latitude = rad(FRAC_PI_2),
818818
longitude = rad(0.0),
819819
altitude = m(0.0)
820820
);
821821
assert_relative_eq!(location7.latitude().get::<radian>(), FRAC_PI_2);
822822

823823
let location8 = wgs84!(
824-
latitude = rad(-1.5707963267948966),
824+
latitude = rad(-FRAC_PI_2),
825825
longitude = rad(0.0),
826826
altitude = m(0.0)
827827
);
@@ -975,7 +975,7 @@ mod tests {
975975

976976
#[test]
977977
#[should_panic(expected = "conversion from ECEF to WGS84 outside altitude range")]
978-
fn wgs_ecef_conversion_fails_for_ecef_origin() -> () {
978+
fn wgs_ecef_conversion_fails_for_ecef_origin() {
979979
let _should_panic = Coordinate::<Ecef>::origin().to_wgs84();
980980
}
981981

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
//! or East, North, and Up (for ENU) they are relative to the observer. [FRD], meanwhile, is a
4646
//! "body frame", and just describes positions relative to the observer's concept of Forward (eg,
4747
//! the direction pointing in the same direction as the nose of a plane), Right (eg, the direction
48-
//! 90º to the right when viewing along Forward), and Down (eg, down through the belly of the
48+
//! 90° to the right when viewing along Forward), and Down (eg, down through the belly of the
4949
//! plane). Converting between [FRD] and [NED] or [ENU] usually requires knowing the orientation of
5050
//! the observer relative to North, East, and Down/Up, and converting between [NED]/[ENU] and
5151
//! [ECEF] (or [WGS84]) requires also knowing the position of the observer in Earth-bound
@@ -87,7 +87,7 @@
8787
//! Perhaps surprisingly, this is _also_ the case for non-local frames like ECEF and WGS84. Due to
8888
//! plate tectonics, a spot measured relative to a point on earth's _surface_ technically "moves"
8989
//! over time. Consider, for example, the Eiffel tower, which is located at
90-
//! 48.85851298170608ºN, 2.2944746521697468ºE (according to Google Maps at least). Since the
90+
//! 48.85851298170608°N, 2.2944746521697468°E (according to Google Maps at least). Since the
9191
//! Eurasian plate drifts over time, if you measured its location a millennium from now, it would
9292
//! technically be at a different place relative to, say, the Statue of Liberty. So, how does that
9393
//! affect its latitude and longitude? The answer is that "it depends". There isn't really just

src/math.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,9 +1577,7 @@ mod tests {
15771577
use crate::math::{RigidBodyTransform, Rotation};
15781578
use crate::util::BoundedAngle;
15791579
use crate::vectors::Vector;
1580-
use crate::{coordinate, Point3};
1581-
use crate::{system, Bearing};
1582-
use crate::{vector, Vector3};
1580+
use crate::{coordinate, vector, Bearing, Point3, Vector3};
15831581
use approx::assert_abs_diff_eq;
15841582
use approx::assert_relative_eq;
15851583
use rstest::rstest;

src/vectors.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ where
791791
///
792792
/// Since vectors do not include roll information, the desired roll must be passed in. It's
793793
/// worth reading the documentation on [`Orientation`] for a reminder about the meaning of roll
794-
/// here. Very briefly, it is intrinsic, and roll means the object's positive Z axis is
794+
/// here. Very briefly, it is intrinsic, and roll means the object's positive Z axis is
795795
/// aligned with `In`'s positive Z axis.
796796
///
797797
/// Returns `None` if the vector has zero length, as the yaw is then ill-defined.
@@ -800,7 +800,7 @@ where
800800
#[must_use]
801801
pub fn orientation_at_origin(&self, roll: impl Into<Angle>) -> Option<Orientation<In>> {
802802
// The vector is effectively an axis-angle representation of the Tait-Bryan orientation
803-
// we're after (with the angle of rotation being ). But, when angle is , the axis-angle
803+
// we're after (with the angle of rotation being ). But, when angle is , the axis-angle
804804
// representation ends up being a noop from what I can tell. Instead, we compute this from
805805
// first principles. Note that we cast to the raw length, but that's okay since we only
806806
// care about the relative magnitudes for these as we're computing angles.
@@ -814,14 +814,14 @@ where
814814
}
815815

816816
// Per `Orientation::from_tait_bryan_angles`, yaw is rotation about the Z axis with an
817-
// object at yaw facing along the positive X axis. Thus, it is rotation on the XY plane
817+
// object at yaw facing along the positive X axis. Thus, it is rotation on the XY plane
818818
// (and uses only the x and y coordinates). Positive yaw is counter-clockwise rotation
819819
// about Z (ie, towards +Y from +X), and thus we want the sin of the angle between X and Y
820820
// with no sign flipping.
821821
//
822822
// Also note that atan2 guarantees that it returns 0 if both components are 0.
823823
let yaw = y.atan2(x);
824-
// Pitch is the rotation about the Y axis, with pitch being aligned with the yaw axis
824+
// Pitch is the rotation about the Y axis, with pitch being aligned with the yaw axis
825825
// (since we're using intrinsic rotations). Per the right-hand rule, positive pitch
826826
// rotates from +X toward -Z, so we negate z to get the correct sign.
827827
let pitch = (-z).atan2((x.powi(P2::new()) + y.powi(P2::new())).sqrt());
@@ -1445,7 +1445,7 @@ mod tests {
14451445

14461446
#[test]
14471447
fn orientation_at_origin_positive_x_axis() {
1448-
// Vector pointing along +X should have yaw=, pitch=
1448+
// Vector pointing along +X should have yaw=, pitch=
14491449
let v = vector!(x = m(1.0), y = m(0.0), z = m(0.0); in TestXyz);
14501450
let orientation = v
14511451
.orientation_at_origin(Angle::ZERO)
@@ -1459,7 +1459,7 @@ mod tests {
14591459

14601460
#[test]
14611461
fn orientation_at_origin_positive_y_axis() {
1462-
// Vector pointing along +Y should have yaw=90º, pitch=
1462+
// Vector pointing along +Y should have yaw=90°, pitch=
14631463
let v = vector!(x = m(0.0), y = m(1.0), z = m(0.0); in TestXyz);
14641464
let orientation = v
14651465
.orientation_at_origin(Angle::ZERO)
@@ -1473,7 +1473,7 @@ mod tests {
14731473

14741474
#[test]
14751475
fn orientation_at_origin_positive_z_axis() {
1476-
// Vector pointing along +Z should have yaw= (arbitrary), pitch=-90º
1476+
// Vector pointing along +Z should have yaw= (arbitrary), pitch=-90°
14771477
let v = vector!(x = m(0.0), y = m(0.0), z = m(1.0); in TestXyz);
14781478
let orientation = v
14791479
.orientation_at_origin(Angle::ZERO)
@@ -1487,22 +1487,22 @@ mod tests {
14871487

14881488
#[test]
14891489
fn orientation_at_origin_negative_x_axis() {
1490-
// Vector pointing along -X should have yaw=180º or -180º, pitch=
1490+
// Vector pointing along -X should have yaw=180° or -180°, pitch=
14911491
let v = vector!(x = m(-1.0), y = m(0.0), z = m(0.0); in TestXyz);
14921492
let orientation = v
14931493
.orientation_at_origin(Angle::ZERO)
14941494
.expect("non-zero vector");
14951495
let (yaw, pitch, roll) = orientation.to_tait_bryan_angles();
14961496

1497-
// atan2(0, -1) = 180º or -180º depending on convention
1497+
// atan2(0, -1) = 180° or -180° depending on convention
14981498
assert_abs_diff_eq!(yaw.get::<degree>().abs(), 180.0, epsilon = 1e-10);
14991499
assert_abs_diff_eq!(pitch.get::<degree>(), 0.0, epsilon = 1e-10);
15001500
assert_abs_diff_eq!(roll.get::<degree>(), 0.0, epsilon = 1e-10);
15011501
}
15021502

15031503
#[test]
15041504
fn orientation_at_origin_45_degree_xy_plane() {
1505-
// Vector at 45º in XY plane should have yaw=45º, pitch=
1505+
// Vector at 45° in XY plane should have yaw=45°, pitch=
15061506
let v = vector!(x = m(1.0), y = m(1.0), z = m(0.0); in TestXyz);
15071507
let orientation = v
15081508
.orientation_at_origin(Angle::ZERO)
@@ -1516,7 +1516,7 @@ mod tests {
15161516

15171517
#[test]
15181518
fn orientation_at_origin_45_degree_xz_plane() {
1519-
// Vector at 45º in XZ plane should have yaw=, pitch=-45º
1519+
// Vector at 45° in XZ plane should have yaw=, pitch=-45°
15201520
let v = vector!(x = m(1.0), y = m(0.0), z = m(1.0); in TestXyz);
15211521
let orientation = v
15221522
.orientation_at_origin(Angle::ZERO)
@@ -1531,8 +1531,8 @@ mod tests {
15311531
#[test]
15321532
fn orientation_at_origin_general_3d_vector() {
15331533
// Vector at (3, 4, 5) - verify the full computation
1534-
// Expected yaw = atan2(4, 3) ≈ 53.13º
1535-
// Expected pitch = atan2(-5, sqrt(3² + 4²)) = atan2(-5, 5) = -45º
1534+
// Expected yaw = atan2(4, 3) ≈ 53.13°
1535+
// Expected pitch = atan2(-5, sqrt(3² + 4²)) = atan2(-5, 5) = -45°
15361536
let v = vector!(x = m(3.0), y = m(4.0), z = m(5.0); in TestXyz);
15371537
let orientation = v
15381538
.orientation_at_origin(Angle::ZERO)
@@ -1561,7 +1561,7 @@ mod tests {
15611561
// - positive yaw is from-north-towards-east
15621562
// - positive pitch is towards -Z (as always), so "up"
15631563
//
1564-
// so a 45º-nose-up east vector should have yaw=90º and pitch=45º
1564+
// so a 45°-nose-up east vector should have yaw=90° and pitch=45°
15651565
let v = vector!(n = m(0.0), e = m(1.0), d = m(-1.0); in TestNed);
15661566
let orientation = v
15671567
.orientation_at_origin(Angle::ZERO)
@@ -1582,7 +1582,7 @@ mod tests {
15821582
// - positive yaw is from-east-towards-north
15831583
// - positive pitch is towards -Z (as always), so "down"
15841584
//
1585-
// so a 45º-nose-up north vector should have yaw=90º and pitch=-45º
1585+
// so a 45°-nose-up north vector should have yaw=90° and pitch=-45°
15861586
let v = vector!(e = m(0.0), n = m(1.0), u = m(1.0); in TestEnu);
15871587
let orientation = v
15881588
.orientation_at_origin(Angle::ZERO)

0 commit comments

Comments
 (0)