Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Yaml needed opCmp

  • Loading branch information...
commit f09f4913f335ee0ef83e6043ec3814b97c57bb88 1 parent ad3bba9
@zeDoctor zeDoctor authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 gl3n/linalg.d
View
24 gl3n/linalg.d
@@ -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!(type, dimension_) 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!(type) qua) const {
+ foreach( i, a; quaternion ) {
+ if( a < qua.quaternion[ i ] )
+ return -1;
+ else if( a > qua.quaternion[ i ] )
+ return 1;
+ }
+
+ // Vectors are the same
+ return 0;
+ }
+
bool opEquals(const Quaternion qu) const {
return quaternion == qu.quaternion;
}
Please sign in to comment.
Something went wrong with that request. Please try again.