Re: stuck on opDiv / opBinary

2015-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/30/15 3:45 PM, Spacen Jasset wrote: On Sunday, 30 August 2015 at 18:12:40 UTC, BBasile wrote: On Sunday, 30 August 2015 at 17:02:58 UTC, Spacen Jasset wrote: [...] try --- Vector3 opBinary(string op)(Vector3 rhs) { static if (op =="/"){} else static assert(0, op ~ " not implemen

Re: stuck on opDiv / opBinary

2015-08-30 Thread Spacen Jasset via Digitalmars-d-learn
On Sunday, 30 August 2015 at 20:09:25 UTC, Timon Gehr wrote: On 08/30/2015 07:02 PM, Spacen Jasset wrote: [...] import std.math: sqrt; import std.algorithm: map,sum,canFind; struct Vector3{ float[3] xyz; void normalise(){ this/=magnitude(); } float magnitude(){ return sqrt(xyz[].

Re: stuck on opDiv / opBinary

2015-08-30 Thread Timon Gehr via Digitalmars-d-learn
On 08/30/2015 07:02 PM, 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 d

Re: stuck on opDiv / opBinary

2015-08-30 Thread Spacen Jasset via Digitalmars-d-learn
On Sunday, 30 August 2015 at 18:12:40 UTC, BBasile wrote: On Sunday, 30 August 2015 at 17:02:58 UTC, Spacen Jasset wrote: [...] try --- Vector3 opBinary(string op)(Vector3 rhs) { static if (op =="/"){} else static assert(0, op ~ " not implemented"); } --- you used the char litteral d

Re: stuck on opDiv / opBinary

2015-08-30 Thread BBasile via Digitalmars-d-learn
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 p

Re: stuck on opDiv / opBinary

2015-08-30 Thread John Colvin via Digitalmars-d-learn
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 p

stuck on opDiv / opBinary

2015-08-30 Thread Spacen Jasset via Digitalmars-d-learn
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 norma