mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-06 08:17:23 +00:00
Make access to point coordinates more convenient
This commit is contained in:
parent
fee466e3e5
commit
1e33846f93
@ -1,6 +1,9 @@
|
|||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
use super::{Scalar, Vector};
|
use super::{
|
||||||
|
coordinates::{Uv, Xyz, T},
|
||||||
|
Scalar, Vector,
|
||||||
|
};
|
||||||
|
|
||||||
/// An n-dimensional point
|
/// An n-dimensional point
|
||||||
///
|
///
|
||||||
@ -91,6 +94,48 @@ impl Point<3> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ops::Deref for Point<1> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
self.coords.deref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::Deref for Point<2> {
|
||||||
|
type Target = Uv;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
self.coords.deref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::Deref for Point<3> {
|
||||||
|
type Target = Xyz;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
self.coords.deref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for Point<1> {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
self.coords.deref_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for Point<2> {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
self.coords.deref_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for Point<3> {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
self.coords.deref_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<const D: usize> From<[Scalar; D]> for Point<D> {
|
impl<const D: usize> From<[Scalar; D]> for Point<D> {
|
||||||
fn from(array: [Scalar; D]) -> Self {
|
fn from(array: [Scalar; D]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user