OCD - move dot product methods
This commit is contained in:
parent
f5b46e2459
commit
57d8c4809b
1 changed files with 23 additions and 23 deletions
46
src/vec.rs
46
src/vec.rs
|
@ -24,12 +24,12 @@ trait Vector<T:Num Ord FuzzyEq> {
|
||||||
pure fn add_v(&&other: self) -> self;
|
pure fn add_v(&&other: self) -> self;
|
||||||
pure fn sub_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 exact_eq(&&other:self) -> bool;
|
||||||
pure fn fuzzy_eq(&&other:self) -> bool;
|
pure fn fuzzy_eq(&&other:self) -> bool;
|
||||||
pure fn eq(&&other:self) -> bool;
|
pure fn eq(&&other:self) -> bool;
|
||||||
|
|
||||||
pure fn dot(&&other: self) -> T;
|
|
||||||
|
|
||||||
pure fn magnitude2() -> T;
|
pure fn magnitude2() -> T;
|
||||||
pure fn magnitude() -> T;
|
pure fn magnitude() -> T;
|
||||||
pure fn normalize() -> self;
|
pure fn normalize() -> self;
|
||||||
|
@ -157,6 +157,12 @@ impl vec2: Vector<float> {
|
||||||
self[1] - other[1])
|
self[1] - other[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pure fn dot(&&other: vec2) -> float {
|
||||||
|
self[0] * other[0] +
|
||||||
|
self[1] * other[1]
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn exact_eq(&&other:vec2) -> bool {
|
pure fn exact_eq(&&other:vec2) -> bool {
|
||||||
self[0] == other[0] &&
|
self[0] == other[0] &&
|
||||||
|
@ -174,12 +180,6 @@ impl vec2: Vector<float> {
|
||||||
self.fuzzy_eq(other)
|
self.fuzzy_eq(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pure fn dot(&&other: vec2) -> float {
|
|
||||||
self[0] * other[0] +
|
|
||||||
self[1] * other[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn magnitude2() -> float {
|
pure fn magnitude2() -> float {
|
||||||
self[0] * self[0] +
|
self[0] * self[0] +
|
||||||
|
@ -310,6 +310,13 @@ impl vec3: Vector<float> {
|
||||||
self[2] - other[2])
|
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)]
|
#[inline(always)]
|
||||||
pure fn exact_eq(&&other:vec3) -> bool {
|
pure fn exact_eq(&&other:vec3) -> bool {
|
||||||
self[0] == other[0] &&
|
self[0] == other[0] &&
|
||||||
|
@ -329,13 +336,6 @@ impl vec3: Vector<float> {
|
||||||
self.fuzzy_eq(other)
|
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)]
|
#[inline(always)]
|
||||||
pure fn magnitude2() -> float {
|
pure fn magnitude2() -> float {
|
||||||
self[0] * self[0] +
|
self[0] * self[0] +
|
||||||
|
@ -467,6 +467,14 @@ impl vec4: Vector<float> {
|
||||||
self[3] - other[3])
|
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)]
|
#[inline(always)]
|
||||||
pure fn exact_eq(&&other:vec4) -> bool {
|
pure fn exact_eq(&&other:vec4) -> bool {
|
||||||
self[0] == other[0] &&
|
self[0] == other[0] &&
|
||||||
|
@ -488,14 +496,6 @@ impl vec4: Vector<float> {
|
||||||
self.fuzzy_eq(other)
|
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)]
|
#[inline(always)]
|
||||||
pure fn magnitude2() -> float {
|
pure fn magnitude2() -> float {
|
||||||
self[0] * self[0] +
|
self[0] * self[0] +
|
||||||
|
|
Loading…
Reference in a new issue