1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub mod vector2d;
pub mod vector3d;
use std::result;
#[derive(Debug)]
pub enum VectorError {
NonThreeDimensionalVector,
NonExistingTransformError,
}
type Result<T> = result::Result<T, VectorError>;
pub trait Vector {
type Data;
fn from(values: &[Self::Data]) -> Self;
fn component_product(self, other: Self) -> Self;
fn dot_product(self, other: Self) -> Self::Data;
fn cross_product(self, other: Self) -> Result<Self>
where
Self: Sized;
fn scale(&self, scale: Self::Data) -> Self;
fn norm(self) -> Self::Data;
fn normalise(self) -> Self;
}