This article is within the scope of WikiProject Computer graphics, a collaborative effort to improve the coverage of computer graphics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.Computer graphicsWikipedia:WikiProject Computer graphicsTemplate:WikiProject Computer graphicscomputer graphics
This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.Computer scienceWikipedia:WikiProject Computer scienceTemplate:WikiProject Computer scienceComputer science
The pseudocode section is pretty bad. If you need to pass objects by reference in your code and use preprocessor macros, it's not pseudocode and it's not useful for describing the algorithm to a general audience. — Preceding unsigned comment added by 108.20.56.242 (talk) 16:24, 25 March 2017 (UTC)[reply]
The current C++ implementation (as of September 16, 2017) was taken from Lighthouse3D (a link is provided in the article). I added the calculation of the intersection point because that is usually very useful. I have tested this implementation very thoroughly and can report that it works correctly in all scenarios that I tested. I can also say that it does not report intersections that are beyond point 2 of the provided segment. You can verify this with a simple test scenario where there is a 1 unit cube at the center of the world coordinate system. Note that half of the cube is on the positive z-axis and half on the negative. Same goes for the other two axes. The following ray (segment really) will not report any intersections: P1 = (0, -10, 0) P2 = (0, -0.55, 0). But this one will: P1 = (0, -10, 0) P2 = (0, -0.45, 0). I added this implementation after seeing that someone posted an implementation from Scratapixel.com 3 months ago. I know for a fact from testing that the Scratapixel implementation does not work correctly in some scenarios. One example is when you have both the starting point and the endpoint of a ray inside the bounding box of 3D model and yet not intersecting any triangles. In that case the Scratchapixel implementation will report spurious intersections. After seeing the improperly implemented Scratchapixel version of the algorithm here, I felt compelled to remove it and replace it with one that actually works. -Max — Preceding unsigned comment added by MaxS 33 (talk • contribs) 17:19, 16 September 2017 (UTC)[reply]