Author Topic: Reflected vector is inverted  (Read 1707 times)

Offline mesh

  • byte
  • *
  • Posts: 3
    • View Profile
Reflected vector is inverted
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflected vector is inverted
« Reply #1 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