Reflected vector is inverted

Started by mesh, February 26, 2013, 09:51:57 PM

Previous topic - Next topic

mesh

I think SimpleVector.reflect returns a vector which is -1* the correct reflection. Example:

SimpleVector v = new SimpleVector(1.0f, 2.0f, 3.0f);
SimpleVector normal = new SimpleVector(0, -1.0f, 0);
SimpleVector vr = v.reflect(normal);
   
Log.i("reflect", "v="+v+" normal="+normal+" vr="+vr);


Result is: v=(1.0,2.0,3.0) normal=(0.0,-1.0,0.0) vr=(-1.0,2.0,-3.0)

I expect the reflection to be (1, -2, 3). Same result regardless of whether the normal vector points toward or away from the input vector.

EgonOlsen

I think you are right. Operands in the last subtraction seem to be reversed. This version fixes this: http://www.jpct.net/download/beta/jpct_ae.jar