2

I'm trying to replicate a implementation of integer calculi of ray-triangle intersection and I'm basing my code on the work of Johannes Hanika (https://jo.dreggn.org/home/2007_master.pdf).

But I having a problem that I think it is in the following lines of Hanika's implementation:

long long int u = (long long int)e1p*kq - (long long int)e1q*kp;
long long int v = (long long int)e2q*kp - (long long int)e2p*kq;

I believe these products should have some sort of compensation, something like right shifting by (m - 1), as it has in others sections of the code.

I've made this compensation in my code, and it works only this way.

Someone here has ever implemented this code of his? Or have any guesses for this problem?

Tricky
  • 3,791
  • 3
  • 10
  • 23
Jorgeluis
  • 197
  • 2
  • 7

1 Answers1

1

In the paper on page 30, it states that kp and kq are integer values. When working with fixed point, you only need to normalize when multiplying 2 fixed-point values together.

int kp = O[p] + ((t*omega[p]) >> (m-1)) - pp;
int kq = O[q] + ((t*omega[q]) >> (m-1)) - pq;
long long int u = (long long int)e1p*kq - (long long int)e1q*kp;
long long int v = (long long int)e2q*kp - (long long int)e2p*kq;
Michael Dorgan
  • 12,453
  • 3
  • 31
  • 61
  • 1
    Strictly speaking, only if the exponent of the destination value is not equal to the sum of the exponents of the operands. – John McFarlane Aug 01 '19 at 14:38
  • e1p, e1q, e2p, e2q are fixed point too, as stated in the page 27, inside the struct definition: (int e1q, e2q; // signed fixed point) and (int e1p, e2p; // in (-2^-E, 2^-E)) – Jorgeluis Aug 01 '19 at 18:30