diff --git a/src/vec.rs b/src/vec.rs index 6980a7f..1eb5ecb 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -24,12 +24,12 @@ trait Vector { pure fn add_v(&&other: self) -> self; pure fn sub_v(&&other: self) -> self; + pure fn dot(&&other: self) -> T; + pure fn exact_eq(&&other:self) -> bool; pure fn fuzzy_eq(&&other:self) -> bool; pure fn eq(&&other:self) -> bool; - pure fn dot(&&other: self) -> T; - pure fn magnitude2() -> T; pure fn magnitude() -> T; pure fn normalize() -> self; @@ -157,6 +157,12 @@ impl vec2: Vector { self[1] - other[1]) } + #[inline(always)] + pure fn dot(&&other: vec2) -> float { + self[0] * other[0] + + self[1] * other[1] + } + #[inline(always)] pure fn exact_eq(&&other:vec2) -> bool { self[0] == other[0] && @@ -174,12 +180,6 @@ impl vec2: Vector { self.fuzzy_eq(other) } - #[inline(always)] - pure fn dot(&&other: vec2) -> float { - self[0] * other[0] + - self[1] * other[1] - } - #[inline(always)] pure fn magnitude2() -> float { self[0] * self[0] + @@ -310,6 +310,13 @@ impl vec3: Vector { self[2] - other[2]) } + #[inline(always)] + pure fn dot(&&other: vec3) -> float { + self[0] * other[0] + + self[1] * other[1] + + self[2] * other[2] + } + #[inline(always)] pure fn exact_eq(&&other:vec3) -> bool { self[0] == other[0] && @@ -329,13 +336,6 @@ impl vec3: Vector { self.fuzzy_eq(other) } - #[inline(always)] - pure fn dot(&&other: vec3) -> float { - self[0] * other[0] + - self[1] * other[1] + - self[2] * other[2] - } - #[inline(always)] pure fn magnitude2() -> float { self[0] * self[0] + @@ -467,6 +467,14 @@ impl vec4: Vector { self[3] - other[3]) } + #[inline(always)] + pure fn dot(&&other:vec4) -> float { + self[0] * other[0] + + self[1] * other[1] + + self[2] * other[2] + + self[3] * other[3] + } + #[inline(always)] pure fn exact_eq(&&other:vec4) -> bool { self[0] == other[0] && @@ -488,14 +496,6 @@ impl vec4: Vector { self.fuzzy_eq(other) } - #[inline(always)] - pure fn dot(&&other:vec4) -> float { - self[0] * other[0] + - self[1] * other[1] + - self[2] * other[2] + - self[3] * other[3] - } - #[inline(always)] pure fn magnitude2() -> float { self[0] * self[0] +