mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-28 18:15:53 +00:00
Add Vector::from_component
This commit is contained in:
parent
843967f39c
commit
9cc0764a1a
@ -17,6 +17,13 @@ pub struct Vector<const D: usize> {
|
||||
}
|
||||
|
||||
impl<const D: usize> Vector<D> {
|
||||
/// Create a vector whose components are all equal
|
||||
pub fn from_component(scalar: impl Into<Scalar>) -> Self {
|
||||
Self {
|
||||
components: [scalar.into(); D],
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert the vector into an nalgebra vector
|
||||
pub fn to_na(self) -> nalgebra::SVector<f64, D> {
|
||||
self.components.map(Scalar::into_f64).into()
|
||||
|
Loading…
Reference in New Issue
Block a user