Skip to main content

NaVector2

Struct NaVector2 

Source
#[repr(transparent)]
pub struct NaVector2<T: Scalar>(pub Vector2<T>);
Expand description

Shape-only adapter for nalgebra::Vector2<T>.

#[repr(transparent)] so &NaVector2<T> is layout-compatible with &nalgebra::Vector2<T>. Pins Cs = Cartesian, DIM = 2.

§Examples

use geometry_adapt_nalgebra::NaVector2;
use geometry_algorithm::distance;
use nalgebra::Vector2;

let a = NaVector2::new(Vector2::new(0.0_f64, 0.0));
let b = NaVector2::new(Vector2::new(3.0_f64, 4.0));
assert_eq!(distance(&a, &b), 5.0);

Tuple Fields§

§0: Vector2<T>

Implementations§

Source§

impl<T: Scalar> NaVector2<T>

Source

pub const fn new(inner: Vector2<T>) -> Self

Wrap a nalgebra::Vector2 so the geometry concepts apply to it.

Source

pub fn into_inner(self) -> Vector2<T>

Unwrap, returning the nalgebra::Vector2.

Trait Implementations§

Source§

impl<T: CoordinateScalar + Scalar> Geometry for NaVector2<T>

Source§

type Kind = PointTag

One of the *Tag types from geometry_tag. Read more
Source§

type Point = NaVector2<T>

The point type this geometry is built from. For a value modelling Point, this is Self. Read more
Source§

impl<T: CoordinateScalar + Scalar> Point for NaVector2<T>

Source§

const DIM: usize = 2

The number of dimensions. Read more
Source§

type Scalar = T

The scalar coordinate type. Read more
Source§

type Cs = Cartesian

The coordinate system this point lives in. Read more
Source§

fn get<const D: usize>(&self) -> T

Read coordinate D. Read more
Source§

impl<T: CoordinateScalar + Scalar> PointMut for NaVector2<T>

Source§

fn set<const D: usize>(&mut self, value: T)

Write coordinate D. Read more

Auto Trait Implementations§

§

impl<T> Freeze for NaVector2<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for NaVector2<T>
where T: RefUnwindSafe,

§

impl<T> Send for NaVector2<T>
where T: Send,

§

impl<T> Sync for NaVector2<T>
where T: Sync,

§

impl<T> Unpin for NaVector2<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for NaVector2<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for NaVector2<T>
where T: 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> 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<T> SameAs<T> for T

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