Wierzchołki trójkątów w sześciokącie
: 16 mar 2024, o 14:12
Witam. Piszę program komputerowy, który wyświetla mapę składającą się z sześciokątów. Chciałbym móc podzielić każdy sześciokąt na elementy składowe ażeby na nich operować. Potrzebuję obliczyć współrzędne v5, v6 ( dla każdego z trójkątów ).
Kod: Zaznacz cały
float outerRadius = 10.0f;
float innerRadius = outerRadius * 0.866025404f;
float n = 0.8f; // ratio
float hexVertices[ ] =
{
0.0f, outerRadius,
innerRadius, outerRadius * 0.5f,
innerRadius, - outerRadius * 0.5f,
0.0f, - outerRadius,
- innerRadius, - outerRadius * 0.5f,
- innerRadius, outerRadius * 0.5f,
0.0f, outerRadius
};
// ... --- ... //
for(int direction=0; direction<6; direction++)
{
v1x = hexVertices[2*direction] * n;
v1z = hexVertices[2*direction+1] * n;
v2x = hexVertices[2*(direction+1)] * n;
v2z = hexVertices[2*(direction+1)+1] * n;
v3x = hexVertices[2*direction];
v3z = hexVertices[2*direction+1];
v4x = hexVertices[2*(direction+1)];
v4z = hexVertices[2*(direction+1)+1];
float d = (1.0f - n) * outerRadius / 2.0f; // distance betweem |v3 v5| or |v4 v6|
// v5x = v1x ...
// v5z = v1z ...
// v6x = v2x ...
// v6z = v2z ...
}