In the Part 3, we discussed an actual implementation of a face-ellipsoid intersection algorithm. However, this algorithm has two drawbacks:
- More floating point operations are needed than absolutely necessary.
- The algorithm misses some particles depending of their position and shape.
In this article we will see an alternative (and easier) way of identifying if a particle intersects a face.
Point inside triangle in barycentric coordinates
Notice that each face of the container can be divided into two triangles. A simpler check of intersection is to find whether the projection of the center of the ellipsoid on to a face lies inside either triangle. We can use barycentric coordinates on a triangle to find if a point is inside the triangle. In these coordinates, a point in a triangle is given by
where are parameters and are the coordinates of the three vertices. The parameters have the properties that and .
Using the second property, we can write
If we define
we can write the coordinates of a point in barycentric coordinates as
To find , we take dot products of the above equation with to get
and solve for to get
A point lies inside the triangle if
If we use the above approach to compute face ellipsoid intersections, particles intersecting faces of the domain are identified correctly (Figure 2). In this particular case, we have shrunk the domain by an amount equal to twice the shortest particle radius. We can see the effect of that choice in Figure 2 where a blue particle is visible at the bottom of the domain because it is just outside the shrunk box.
If you have questions/comments/corrections, please contact banerjee at parresianz dot com dot zen (without the dot zen).
📅 24.11.2017 📁 DEM