0
我想在C#中的球殼中排列點。我有代碼來安排一組點(我正在進行有限元分析),球體模式的半徑爲double earthRadius
。我不知道如何做一個球殼like the type pictured here相同。想法?如何繪製球殼?
for (double x = -earthRadius; x < earthRadius; x += pointIncrement) //taken from http://stackoverflow.com/questions/8671385/sphere-drawing-in-java and slightly altered to make more efficient
{
for (double y = -earthRadius; y < earthRadius; y += pointIncrement)
{
for (double z = -earthRadius; z < earthRadius; z += pointIncrement)
{
if ((x * x) + (y * y) + (z * z) <= earthRadius * earthRadius)
{
earth.AddPoint(new Vector(x, y, z), 0);
totalPoints++;
}
}
}
}
我建議你循環[球形座標](https://en.wikipedia.org/wiki/Spherical_coordinate_system)來查找你的觀點。之後,將它們轉換爲笛卡爾座標。 – gdir