As mentioned above, the serbinski triangle keeps splitting a triangle into three similar triangles. The figure shown in this section is to constantly split two triangles with the same waist and blind angle.
Core code:
static void SplitTriangle(const Vector3& v1, const Vector3& v2, const Vector3& v3, Yreal angle, Vector3* pVertices){ Vector3 dir12 = v1 - v2; Yreal len12 = D3DXVec3Length(&dir12); //Vector3 dir13 = v1 - v3; //Yreal len13 = D3DXVec3Length(&dir13); Vector3 dir23 = v2 - v3; Yreal len23 = D3DXVec3Length(&dir23); dir23 /= len23; Yreal len = len12*0.5f/cosf(angle); pVertices[0] = v2 - dir23*len; pVertices[1] = v1; pVertices[2] = v2; pVertices[3] = v3 + dir23*len; pVertices[4] = v3; pVertices[5] = v1;}
Software:
Since the triangle is an empty triangle, you can set its bottom angle.
When the bottom angle is 45 degrees and the right triangle is an isosceles triangle, the following grid shape is generated:
When its base angle is 30 degrees, its image will be transformed into a Koch curve. For details, see: Koch snowflake
Software: http://files.cnblogs.com/WhyEngine/Fractal.7z
split triangle