Interesting blog post I found, with full C++ source code that returns plane-triangle intersections, which is the basis of slicing 3D models in printing. I haven’t had a chance to play with it, but I’m wondering how quick the code produces its output.

http://ravehgonen.wordpress.com/tag/plane-triangle-intersection

# Interesting blog post I found, with full C++ source code that returns plane-triangle intersections,

**ThantiK**(ThantiK) #1

**NathanielStenzel**(Nathaniel Stenzel) #2

The slicing of an individual layer should be significantly faster if the triangles are sorted by the lowest Z position beforehand.

Thanks for the resource. I started a slicer project. I kind of already figured out how to intersect with a triangle, but this blog might have some nice notes on optimizing things.

**Nick_Parker**(Nick Parker) #3

Sorting by z position is an interesting optimization. When I bother to optimize this step (it’s very fast anyway.) I usually bake the centers and Z radiuses of triangles into their representation. Then step one of your collision function is just if abs(center.z-LayerZ)>zRad) return false.

I haven’t actually profiled the different methods though, because other parts of slicing just dwarf this computation wise.

**NathanielStenzel**(Nathaniel Stenzel) #4

@Nick_Parker there is also the idea of splitting triangles on the middle Z point so that the bottom or top is flat on a specific Z height. Storing the X and Y deltas is yet another optimization if you are rendering one layer at a time.