mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-08 17:27:20 +00:00
Implement more math conversions
This commit is contained in:
parent
8eab780835
commit
b147bb8780
@ -106,6 +106,18 @@ impl<const D: usize> From<nalgebra::Point<f64, D>> for Point<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<const D: usize> From<Point<D>> for [f32; D] {
|
||||
fn from(point: Point<D>) -> Self {
|
||||
point.0.map(|scalar| scalar.into_f32())
|
||||
}
|
||||
}
|
||||
|
||||
impl<const D: usize> From<Point<D>> for [f64; D] {
|
||||
fn from(point: Point<D>) -> Self {
|
||||
point.0.map(|scalar| scalar.into_f64())
|
||||
}
|
||||
}
|
||||
|
||||
impl<const D: usize> ops::Neg for Point<D> {
|
||||
type Output = Self;
|
||||
|
||||
|
@ -62,6 +62,11 @@ impl Scalar {
|
||||
Self::from_f64(scalar as f64)
|
||||
}
|
||||
|
||||
/// Convert the scalar into an `f32`
|
||||
pub fn into_f32(self) -> f32 {
|
||||
self.0 as f32
|
||||
}
|
||||
|
||||
/// Convert the scalar into a `f64`
|
||||
pub fn into_f64(self) -> f64 {
|
||||
self.0
|
||||
|
@ -121,6 +121,12 @@ impl<const D: usize> From<nalgebra::SVector<f64, D>> for Vector<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<const D: usize> From<Vector<D>> for [f32; D] {
|
||||
fn from(vector: Vector<D>) -> Self {
|
||||
vector.0.map(|scalar| scalar.into_f32())
|
||||
}
|
||||
}
|
||||
|
||||
impl<const D: usize> ops::Add<Self> for Vector<D> {
|
||||
type Output = Self;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user