public Point3[,] SphereCoordinates() { Point3[,] pts = new Point3[30, 20]; var m = new Matrix3 (); var mt = Matrix3.Translate3 (xc, yc, zc); for (int i = 0; i < pts.GetLength(0); i++) { for (int j = 0; j < pts.GetLength(1); j++) { pts[i, j] = m.Spherical(r, i * 180 / (pts.GetLength(0) - 1), j * 360 / (pts.GetLength(1) - 1)); pts[i, j].Transform(mt); } } return pts; }
public Point3 Spherical(float r, float theta, float phi) { var pt = new Point3 (); var snt = (float)Math.Sin (theta * Math.PI / 180); var cnt = (float)Math.Cos (theta * Math.PI / 180); var snp = (float)Math.Sin (phi * Math.PI / 180); var cnp = (float)Math.Cos (phi * Math.PI / 180); pt.X = r * snt * cnp; pt.Y = r * cnt; pt.Z = -r * snt * snp; pt.W = 1; return pt; }
public Point3 Cylindrical(float r, float theta, float y) { var pt = new Point3 (); var sn = (float)Math.Sin (theta * Math.PI / 180); var cn = (float)Math.Cos (theta * Math.PI / 180); pt.X = r * cn; pt.Y = y; pt.Z = -r * sn; pt.W = 1; return pt; }