Daarong, what you’re encountering is expected. When you optimize code for “speed” (or number of operations/instructions) as was done above, you frequently give up on robustness. I noted this with the comment “Also, if implemented as derived, the resulting code is not the greatest example of floating-point robustness […]” If robustness is your goal, you will have better results not performing any of the for-speed optimizations that I outlined in the article.

]]>For example if you make a test scheme that uses a 2d area 700×700 and randomly place triangle points in it, iterate through every pixel, each time “moving a circle” to that position, and if it intersects, draw black, otherwise draw white… when the triangle gets small enough you end up with same really crazy patterns.

This happened to me first in 3 dimensions in JavaScript… then I did the 2D test described above in C#. Both cases had the same instability.

As I said – any recommendations? I’m bypassing this instability by just replacing tiny triangles with appropriately sized tiny spheres, then doing sphere-sphere intersection. So I’m asking this not for myself, but more as a discussion provoking thing.

Thanks for this resource!!

]]>First of all let me praise you for this excellent book that is yours “Real-time collision detection”. I write to you in order to ask about a small clarification of something I found odd in a couple of your codes. On page 189, you give a code for detecting the interception between a line and a quadrilateral, which I assume to be in two-dimensional space. However, at some point, there is a line with a crossproduct yielding a new vector:

Vector m = Cross(pc, pq);

As far as I know, the cross-product of two 2D vectors returns a scalar value – or a 3D vector in case we add the zeros to the other two dimensions and use that scalar as the third dimension. I found it confusing: how should one proceed in that regard, since in that code line the object “m” seems to be a 2D vector? Notice that I am not the only soul lost in that: http://stackoverflow.com/questions/2333292/cross-product-of-2-2d-vectors

Many thanks for your time.

Best regards,

Andy E. Astro

]]>i just read thru chapter 5 and found the idea of grouping triangles into more

complex stripes “expanding” and very useful to speed up of ray/triangle intersections.

is there also an optimized quad/line intersection available for double-sided quads ? a

simple halfspace test at the front will not work here to seperate the tris. ]]>

ricardoquesada, you can e.g. normalize the floats so they are in the same exponent range with the same sign, at which point only the fraction bits of the floats need to be considered (of which there are 23 bits plus one implicit bit which is always 1). Pick the top N bits of the fraction bits, and store those in your key.

]]>I have a question regarding the depth key.

I have all the depth values in floats, and I want to use those values in the key.

What is the best way to encode floats into ‘bits’ (or integer) so that I can use it as part of the key ?

Thanks!

]]>