Bearing

Struct Bearing 

Source
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>

Source

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.

Source

pub fn builder() -> Builder<In, MissingAzimuth, MissingElevation>

Provides a constructor for a bearing in the CoordinateSystem In.

Source

pub fn to_builder(self) -> Builder<In, HasAzimuth, HasElevation>

Turns a Bearing back into a builder so that its components can be modified.

Source

pub 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

Constructs 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.

Source

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.

Source

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°.

Source

pub fn to_unit_vector(&self) -> Vector<In>
where In: BearingDefined,

Returns a unit vector pointing away from origin at this bearing.

Source

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.
Source§

type Epsilon = <f64 as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<In> Clone for Bearing<In>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<In: Debug> Debug for Bearing<In>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<In> Default for Bearing<In>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, In> Deserialize<'de> for Bearing<In>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<In> Display for Bearing<In>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<From, To> Mul<Bearing<To>> for RigidBodyTransform<From, To>
where From: BearingDefined, To: BearingDefined,

Source§

type Output = Bearing<From>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Bearing<To>) -> Self::Output

Performs the * operation. Read more
Source§

impl<From, To> Mul<Bearing<To>> for Rotation<From, To>
where From: BearingDefined, To: BearingDefined,

Source§

type Output = Bearing<From>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Bearing<To>) -> Self::Output

Performs the * operation. Read more
Source§

impl<From, To> Mul<RigidBodyTransform<From, To>> for Bearing<From>
where From: BearingDefined, To: BearingDefined,

Source§

type Output = Bearing<To>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: RigidBodyTransform<From, To>) -> Self::Output

Performs the * operation. Read more
Source§

impl<From, To> Mul<Rotation<From, To>> for Bearing<From>
where From: BearingDefined, To: BearingDefined,

Source§

type Output = Bearing<To>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rotation<From, To>) -> Self::Output

Performs the * operation. Read more
Source§

impl<In> PartialEq for Bearing<In>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<In> RelativeEq for Bearing<In>

Available on crate features approx only.
Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl<In> Serialize for Bearing<In>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<System> EquivalentTo<System> for System

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,