use geometry_coords::CoordinateScalar;
use geometry_cs::Cartesian;
use geometry_tag::PointTag;
use geometry_trait::{Geometry, Point, PointMut};
use nalgebra::{Scalar, Vector2, Vector3};
#[repr(transparent)]
pub struct NaVector2<T: Scalar>(pub Vector2<T>);
impl<T: Scalar> NaVector2<T> {
#[inline]
#[must_use]
pub const fn new(inner: Vector2<T>) -> Self {
Self(inner)
}
#[inline]
#[must_use]
pub fn into_inner(self) -> Vector2<T> {
self.0
}
}
impl<T: CoordinateScalar + Scalar> Geometry for NaVector2<T> {
type Kind = PointTag;
type Point = Self;
}
impl<T: CoordinateScalar + Scalar> Point for NaVector2<T> {
type Scalar = T;
type Cs = Cartesian;
const DIM: usize = 2;
#[inline]
fn get<const D: usize>(&self) -> T {
self.0[D]
}
}
impl<T: CoordinateScalar + Scalar> PointMut for NaVector2<T> {
#[inline]
fn set<const D: usize>(&mut self, value: T) {
self.0[D] = value;
}
}
#[repr(transparent)]
pub struct NaVector3<T: Scalar>(pub Vector3<T>);
impl<T: Scalar> NaVector3<T> {
#[inline]
#[must_use]
pub const fn new(inner: Vector3<T>) -> Self {
Self(inner)
}
#[inline]
#[must_use]
pub fn into_inner(self) -> Vector3<T> {
self.0
}
}
impl<T: CoordinateScalar + Scalar> Geometry for NaVector3<T> {
type Kind = PointTag;
type Point = Self;
}
impl<T: CoordinateScalar + Scalar> Point for NaVector3<T> {
type Scalar = T;
type Cs = Cartesian;
const DIM: usize = 3;
#[inline]
fn get<const D: usize>(&self) -> T {
self.0[D]
}
}
impl<T: CoordinateScalar + Scalar> PointMut for NaVector3<T> {
#[inline]
fn set<const D: usize>(&mut self, value: T) {
self.0[D] = value;
}
}