Permalink
Browse files

Merge pull request #27 from Circular-Studios/master

Yaml needed opCmp
  • Loading branch information...
Dav1dde committed Feb 21, 2014
2 parents ad3bba9 + 674c7c0 commit 9919d5bae601c1399deb660e2b87f3bb77475102
Showing with 24 additions and 0 deletions.
  1. +24 −0 gl3n/linalg.d
View
@@ -567,6 +567,18 @@ struct Vector(type, int dimension_) {
assert(almost_equal(v4.normalized, vec4(1.0f/sqrt(84.0f), 3.0f/sqrt(84.0f), 5.0f/sqrt(84.0f), 7.0f/sqrt(84.0f))));
}
+ const int opCmp(ref const Vector vec) const {
+ foreach(i, a; vector) {
+ if(a < vec.vector[ i ])
+ return -1;
+ else if(a > vec.vector[ i ])
+ return 1;
+ }
+
+ // Vectors are the same
+ return 0;
+ }
+
const bool opEquals(T)(const T vec) if(!isArray!T && T.dimension == dimension) {
return vector == vec.vector;
}
@@ -2405,6 +2417,18 @@ struct Quaternion(type) {
assert((q2 * v1).vector == [-2.0f, 36.0f, 38.0f]);
}
+ const int opCmp(ref const Quaternion qua) const {
+ foreach(i, a; quaternion) {
+ if(a < qua.quaternion[ i ])
+ return -1;
+ else if(a > qua.quaternion[ i ])
+ return 1;
+ }
+
+ // Quaternions are the same
+ return 0;
+ }
+
bool opEquals(const Quaternion qu) const {
return quaternion == qu.quaternion;
}

0 comments on commit 9919d5b

Please sign in to comment.