Thursday, July 29, 2010

C# 3D -- Sphere Primitive





hehe just testing a jackstone with a simple physics engine... c# is getting cooler now at its .NET4.0 framework... i am very impressed with the WPF too bad it's not supported with Mono yet, and i guess will never be...

right, it doesn't have it's 3D primitive, but reviewing your calculus here's a snapshot...

void populatePoints(MeshGeometry3D mesh, int r, double dTheta, double dRho)
{
//populate points
//add code for iTheta= MaxTheta
// and iRho= MaxRho
for (double iTheta = STARTTHETA; iTheta < ENDTHETA; iTheta += dTheta) {
double rSinTheta = r * Math.Sin(iTheta);
double z = r * Math.Cos(iTheta);
for (double iRho = STARTRHO; iRho < ENDRHO; iRho += dRho) {
double x = rSinTheta * Math.Cos(iRho);
double y = rSinTheta * Math.Sin(iRho);
Point3D point = new Point3D(x, y, z);
mesh.Positions.Add(point);
}
}
}