On Sunday, 30 August 2015 at 17:02:58 UTC, Spacen Jasset wrote:
I have just added an opDiv to this class, but it doesn't seem
to pick it up.
math/vector.d(30): Error: 'this /= mag' is not a scalar, it is
a Vector3
I can't see why that is, becuase my opMul works in the same
place. Can anyone point out what I have done wrong?
Class Matrix {
void normalise()
{
const float mag = magnitude();
if (mag) {
//this.scalarDivide(mag);
this /= mag; // Not work
this *= 1/mag; // Does work.
}
}
// Vector3 opBinary(string op)(Vector3 rhs) if (op=='/')
Vector3 opDiv(float scalar)
{
Vector3 v = this;
v.scalarDivide(scalar);
return v;
}
}
Don't use opMul or opDiv etc, use opBinary
Could you provide a more complete example? It's hard to identify
what the problem is from this snippet.