Define objects with a few attributes necessary for pattern matching.

SetAttributes[lineVector, {Flat, Orderless}] SetAttributes[lin, {Flat, Orderless, OneIdentity}] SetAttributes[tri, {Flat, Orderless}]

Define List of lines with intersection points defined on them.

lines = lineVector[lin[p0, p1], lin[p0, p10, p5, p8], lin[p0, p2, p4, p6], lin[p0, p3, p7, p9], lin[p1, p10, p6, p9], lin[p1, p2, p3, p5], lin[p1, p4, p7, p8]] ;

Find lines which intersect with two other lines, which in turn intersect with each other. The intersection points are the vertices of a triangle. This is rather slow, since it matches more than it needs to, and thus creates duplicate triangle elements, which are removed with Union.

ReplaceList[lines, lineVector[lin[a_, b_, ___], lin[b_, c_, ___], lin[a_, c_, ___], ___] -> tri[a, b, c]] // Union % // Length

{tri[p0, p1, p10], tri[p0, p1, p2], tri[p0, p1, p3], tri[p0, p1, p4], tri[p0, p1, p5], tri[p0, p1, p6], tri[p0, p1, p7], tri[p0, p1, p8], tri[p0, p1, p9], tri[p0, p10, p6], tri[p0, p10, p9], tri[p0, p2, p3], tri[p0, p2, p5], tri[p0, p3, p5], tri[p0, p4, p7], tri[p0, p4, p8], tri[p0, p6, p9], tri[p0, p7, p8], tri[p1, p10, p5], tri[p1, p10, p8], tri[p1, p2, p4], tri[p1, p2, p6], tri[p1, p3, p7], tri[p1, p3, p9], tri[p1, p4, p6], tri[p1, p5, p8], tri[p1, p7, p9]}


Converted by Mathematica  (January 20, 2005)