pub struct Bearing<In> { /* private fields */ }Expand description
A direction (conceptually represented as a unit vector) in the CoordinateSystem In.
A Bearing has an azimuth and elevation, whose meanings differ for different kinds of
coordinate systems (although there are conventions). The meaning of azimuth and
elevation for a given coordinate system is defined by its implementation of BearingDefined.
For example, a bearing azimuth in an FRD system is relative to the forward direction of the
system, while in both NED and ENU (somewhat counter-intuitively) it is relative to North. In
general, azimuth tends to align with yaw and elevation with pitch (as defined by Tait-Bryan
angles).
See also horizontal coordinate systems.
To construct a bearing, you can either use a builder via Bearing::builder or provide a
Components to Bearing::build. The following are equivalent:
use sguaba::{Bearing, system};
use uom::si::f64::Angle;
use uom::si::angle::degree;
system!(struct PlaneFrd using FRD);
Bearing::<PlaneFrd>::builder()
// clockwise from forward
.azimuth(Angle::new::<degree>(20.))
// upwards from straight-ahead
.elevation(Angle::new::<degree>(10.))
.expect("elevation is in [-90º, 90º]")
.build();use sguaba::{Bearing, system, builder::bearing::Components};
use uom::si::f64::Angle;
use uom::si::angle::degree;
system!(struct PlaneFrd using FRD);
Bearing::<PlaneFrd>::build(Components {
// clockwise from forward
azimuth: Angle::new::<degree>(20.),
// upwards from straight-ahead
elevation: Angle::new::<degree>(10.),
}).expect("elevation is in [-90º, 90º]");Implementations§
Source§impl<In> Bearing<In>
impl<In> Bearing<In>
Sourcepub fn build(_: Components) -> Option<Self>
pub fn build(_: Components) -> Option<Self>
Constructs a bearing towards the given azimuth and elevation in the CoordinateSystem
In.
The elevation must be in [-90°,90°] % 360°. If it is not, this function returns None.
Sourcepub fn builder() -> Builder<In, MissingAzimuth, MissingElevation>
pub fn builder() -> Builder<In, MissingAzimuth, MissingElevation>
Provides a constructor for a bearing in the CoordinateSystem In.
Sourcepub fn to_builder(self) -> Builder<In, HasAzimuth, HasElevation>
pub fn to_builder(self) -> Builder<In, HasAzimuth, HasElevation>
Turns a Bearing back into a builder so that its components can be modified.
Sourcepub fn new(
azimuth: impl Into<Angle>,
elevation: impl Into<Angle>,
) -> Option<Self>
👎Deprecated: prefer Bearing::build or Bearing::builder to avoid risk of argument order confusion
pub fn new( azimuth: impl Into<Angle>, elevation: impl Into<Angle>, ) -> Option<Self>
Bearing::build or Bearing::builder to avoid risk of argument order confusionConstructs a bearing towards the given azimuth and elevation in the CoordinateSystem
In.
Prefer Bearing::build or Bearing::builder to avoid risk of argument order
confusion. This function will be removed in a future version of Sguaba in favor of those.
The elevation must be in [-90°,90°] % 360°. If it is not, this function returns None.
Sourcepub fn azimuth(&self) -> Angle
pub fn azimuth(&self) -> Angle
Returns the azimuthal angle of this bearing.
The definition of the azimuthal angle depends on the implementation of BearingDefined
for In.
There is no guarantee on the numeric range of the azimuthal angle.
Sourcepub fn elevation(&self) -> Angle
pub fn elevation(&self) -> Angle
Returns the elevation angle of this bearing.
The definition of the azimuthal angle depends on the implementation of BearingDefined
for In.
The returned value is always in [-90°, 90°] ± N × 360°.
Sourcepub fn to_unit_vector(&self) -> Vector<In>where
In: BearingDefined,
pub fn to_unit_vector(&self) -> Vector<In>where
In: BearingDefined,
Returns a unit vector pointing away from origin at this bearing.
Sourcepub fn zero() -> Self
pub fn zero() -> Self
Constructs a bearing in coordinate system In with azimuth and elevation set to 0.
The definition of the azimuthal angle depends on the implementation of BearingDefined
for In.
Trait Implementations§
Source§impl<In> AbsDiffEq for Bearing<In>
Available on crate features approx only.
impl<In> AbsDiffEq for Bearing<In>
approx only.Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.Source§impl<'de, In> Deserialize<'de> for Bearing<In>
impl<'de, In> Deserialize<'de> for Bearing<In>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<From, To> Mul<Bearing<To>> for RigidBodyTransform<From, To>where
From: BearingDefined,
To: BearingDefined,
impl<From, To> Mul<Bearing<To>> for RigidBodyTransform<From, To>where
From: BearingDefined,
To: BearingDefined,
Source§impl<From, To> Mul<Bearing<To>> for Rotation<From, To>where
From: BearingDefined,
To: BearingDefined,
impl<From, To> Mul<Bearing<To>> for Rotation<From, To>where
From: BearingDefined,
To: BearingDefined,
Source§impl<From, To> Mul<RigidBodyTransform<From, To>> for Bearing<From>where
From: BearingDefined,
To: BearingDefined,
impl<From, To> Mul<RigidBodyTransform<From, To>> for Bearing<From>where
From: BearingDefined,
To: BearingDefined,
Source§impl<From, To> Mul<Rotation<From, To>> for Bearing<From>where
From: BearingDefined,
To: BearingDefined,
impl<From, To> Mul<Rotation<From, To>> for Bearing<From>where
From: BearingDefined,
To: BearingDefined,
Source§impl<In> RelativeEq for Bearing<In>
Available on crate features approx only.
impl<In> RelativeEq for Bearing<In>
approx only.Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq.impl<In> Copy for Bearing<In>
Auto Trait Implementations§
impl<In> Freeze for Bearing<In>
impl<In> RefUnwindSafe for Bearing<In>where
In: RefUnwindSafe,
impl<In> Send for Bearing<In>where
In: Send,
impl<In> Sync for Bearing<In>where
In: Sync,
impl<In> Unpin for Bearing<In>where
In: Unpin,
impl<In> UnwindSafe for Bearing<In>where
In: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.