mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-09 04:18:28 +00:00
Add Vector<3>::cross
This commit is contained in:
parent
828326441e
commit
9152c23b92
@ -9,6 +9,22 @@ pub struct Vector<const D: usize> {
|
||||
pub components: [Scalar; D],
|
||||
}
|
||||
|
||||
impl Vector<3> {
|
||||
#[allow(unused)] // code to use it is being worked on
|
||||
pub fn cross(self, other: Self) -> Self {
|
||||
let [ax, ay, az] = self.components;
|
||||
let [bx, by, bz] = other.components;
|
||||
|
||||
Self {
|
||||
components: [
|
||||
ay * bz - az * by,
|
||||
az * bx - ax * bz,
|
||||
ax * by - ay * bx,
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, const D: usize> From<[S; D]> for Vector<D>
|
||||
where
|
||||
S: Into<Scalar>,
|
||||
|
Loading…
Reference in New Issue
Block a user