- The package “legos” is no longer available, but you can find it as “brickos” so you install it with

$ sudo apt-get install brickos

- The makefile /usr/lib/brickos/Makefile.common used by the building process did not work for me out of the box. I had to comment out a couple of lines to make it work:

#ensureConfigured:

# @if [ ! -f $(BRICKOS_ROOT)/.configured.flg ]; then \

- The c++ examples from /usr/share/doc/brickos/examples/demo/c++/ did not build, but removing the temperatureSensor.C file fixed the problem.

Hope this helps!

]]>Let’s start by defining a triangle as a set of three points \(a,b,c\) and a plane as a point \(q\) and a normal vector \(\hat{n}\). To answer the first question – how to determine if a triangle intersects a plane – we can simplify by figuring out how to determine if a segment intersects a plane.

With a segment defined by two points \(s_1, s_2\) and a plane defined as before (a point \(q\) and a normal vector \(\hat{n}\)), test if both points lie in different sides of the plane. Take each segment point and subtract the plane point $$\vec{v_1} = s_1 – q, \vec{v_2} = s_2 – q$$ and then compute the dot product with the plane normal $$d_1 = \hat{n} \cdot \vec{v_1}, d_2 = \hat{n} \cdot \vec{v_2}$$. If the signs of both dot products are different, then the segment intersects the plane.

Run the test with the three segments that build the triangle. Some edge cases to consider: what if one segment lies in the plane? what if all three segments lie in the plane?

Once you know that a segment intersects a plane, computing the intersection point is easy. Take the two dot products computed earlier \(d_1,d_2\) and the intersection point \(i\) can be computed as follows: $$ t=d_1/(d_2 – d_1) $$ and $$ i = s_1 + t(s_2 – s_1) $$

Now, to form a triangle (or two triangles) from one side of the intersection (usually the side \(\hat{n}\) points to, the “positive” side) you need to test for intersection in a clockwise or counter clockwise (again, depending on \(\hat{n}\) direction and the coordinate system handedness) and keep track of which point of the segment under test is on the “positive” side (the dot product is greater than zero) and add it to the list of “visible” points and add the intersection point to that list as well. You should end up with three or four points in the list of “visible” points. From there, you can build one or two triangles.

]]>