Repository navigation
feat: add angular separation, reciprocal bearing, coordinate bearing_to, and generalized vector/point rotations - #129
Open
vamshidharre wants to merge 1 commit into
Conversation
…to, and generalized vector/point rotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces essential spatial math primitives for relative targeting, angular separation, and generalized rotations across
Bearing,Vector, andCoordinate:Relative Targeting / Look Angles (
Coordinate::bearing_to):Coordinate::bearing_to(&self, other: &Self) -> Option<Bearing<In>>for directly computing the line-of-sight bearing between two coordinates inBearingDefinedsystems.Nonewhen points are identical (where azimuth is ill-defined).Generalized Vector Rotations (
Vector::rotate):Vector::rotatefromrotation_axis: &Selftorotation_axis: &Vector<In, AxisTime>, enabling rotations ofVelocityVectororAccelerationVectoraround aLengthVector(e.g. an aircraft pitch/yaw/roll axis or shaft) without unit-type mismatch compiler errors.Vector::rotate_around_bearing(&self, axis: Bearing<In>, angle: Angle) -> Selffor direct rotations around a line-of-sight direction.Coordinate Rotations:
Coordinate::rotate_around_axis(&self, axis, angle) -> Selffor rotating a point around an axis passing through the origin.Coordinate::rotate_around_point(&self, center, axis, angle) -> Selffor rotating a point around an axis passing through an arbitrary center point.Coordinate::rotate_around_bearingandCoordinate::rotate_around_point_bearing.Angular Separation (
angle_between):Vector::angle_between<OtherTime>(&self, other: &Vector<In, OtherTime>) -> Angle: computes the angle between two vectors acrossFloatMath::atan2(cross.norm(), dot)(numerically stable down to subnormals, immune toacosprecision degradation nearVector::angle_to_bearing(&self, bearing: Bearing<In>) -> Angle.Bearing::angle_between(&self, other: &Self) -> Anglefor computing the great-circle angular separation between two lines of sight.Reciprocal Directions & Scaling (
Bearing):Bearing::opposite(&self) -> Selfandimpl Neg for Bearing<In>, returning the exact antipodal direction on the sphere.Mulimplementations betweenBearing<In>and physical quantities (Length,Velocity,Acceleration), allowing natural expressions likebearing * speed -> VelocityVectorandbearing * range -> LengthVector.Motivation
In sensor tracking, radar/vision targeting, and aerospace multi-body kinematics, calculating the relative bearing to a target, rotating velocity vectors around body-fixed axes, and finding the angular separation between lines of sight are fundamental operations. Previously in
sguaba:Vector::rotaterequired the rotation axis to share the exact sameTimeunit as the rotated vector.Verification
All checks pass cleanly:
cargo test --all-targets: 249 passed, 0 failed.cargo test --doc: 51 doctests passed.cargo clippy --all-features: 0 warnings.cargo check --no-default-features --features libm: 0 warnings (#![no_std]verified).cargo fmt -- --check: verified clean formatting.