jPCT-AE - a 3d engine for Android > Bugs

Reflected vector is inverted

(1/1)

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

--- Code: --- 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);
--- End code ---

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

Navigation

[0] Message Index

Go to full version