The serbinski triangle (Sierpinski triangle) is a kind of fractal. It was proposed by Polish mathematician shelbinski in 1915. It is a typical self-similar set. Some materials refer to it as sherbinski's grave.
The generation process is as follows:
- Take a solid triangle. (Most use equilateral triangles)
- Divide the line along the three sides into four small triangles.
- Remove the small triangle in the middle.
- Repeat 1 for the remaining three small triangles.
Core code:
static void SierpinskiTriangle(const Vector3& v1, const Vector3& v2, const Vector3& v3, Vector3* pVertices){ Vector3 v12 = (v1 + v2)*0.5f; Vector3 v13 = (v1 + v3)*0.5f; Vector3 v23 = (v2 + v3)*0.5f; pVertices[0] = v1; pVertices[1] = v12; pVertices[2] = v13; pVertices[3] = v2; pVertices[4] = v23; pVertices[5] = v12; pVertices[6] = v3; pVertices[7] = v13; pVertices[8] = v23;}
Software: http://files.cnblogs.com/WhyEngine/Fractal.7z
Fractal of the Sierpinski triangle