www.jpct.net

jPCT-AE - a 3d engine for Android => Bugs => Topic started by: mesh on February 26, 2013, 09:51:57 pm

Title: Reflected vector is inverted
Post by: mesh on February 26, 2013, 09:51:57 pm
I think SimpleVector.reflect returns a vector which is -1* the correct reflection. Example:
Code: [Select]
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.
Title: Re: Reflected vector is inverted
Post by: EgonOlsen on February 26, 2013, 10:07:21 pm
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 (http://www.jpct.net/download/beta/jpct_ae.jar)