use geometry_coords::CoordinateScalar;
use geometry_cs::Cartesian;
use geometry_tag::PointTag;
use geometry_trait::{Geometry, Point, PointMut};
use nalgebra::{Point2, Point3, Scalar};
#[repr(transparent)]
pub struct NaPoint2<T: Scalar>(pub Point2<T>);
impl<T: Scalar> NaPoint2<T> {
#[inline]
#[must_use]
pub const fn new(inner: Point2<T>) -> Self {
Self(inner)
}
#[inline]
#[must_use]
pub fn into_inner(self) -> Point2<T> {
self.0
}
}
impl<T: CoordinateScalar + Scalar> Geometry for NaPoint2<T> {
type Kind = PointTag;
type Point = Self;
}
impl<T: CoordinateScalar + Scalar> Point for NaPoint2<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 NaPoint2<T> {
#[inline]
fn set<const D: usize>(&mut self, value: T) {
self.0[D] = value;
}
}
#[repr(transparent)]
pub struct NaPoint3<T: Scalar>(pub Point3<T>);
impl<T: Scalar> NaPoint3<T> {
#[inline]
#[must_use]
pub const fn new(inner: Point3<T>) -> Self {
Self(inner)
}
#[inline]
#[must_use]
pub fn into_inner(self) -> Point3<T> {
self.0
}
}
impl<T: CoordinateScalar + Scalar> Geometry for NaPoint3<T> {
type Kind = PointTag;
type Point = Self;
}
impl<T: CoordinateScalar + Scalar> Point for NaPoint3<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 NaPoint3<T> {
#[inline]
fn set<const D: usize>(&mut self, value: T) {
self.0[D] = value;
}
}