// transform input point pt1, (rotate "aX, aZ" and move to "center") public static void Transform(Mesh3D model, Point3D center, double aX, double aZ) { double angleX = 3.1415926f * aX / 180; double angleZ = 3.1415926f * aZ / 180; int nVertNo = model.GetVertexNo(); for (int i = 0; i < nVertNo; i++) { Point3D pt1 = model.GetPoint(i); // rotate from z-axis double x2 = pt1.X * Math.Cos(angleZ) + pt1.Z * Math.Sin(angleZ); double y2 = pt1.Y; double z2 = -pt1.X * Math.Sin(angleZ) + pt1.Z * Math.Cos(angleZ); double x3 = center.X + x2 * Math.Cos(angleX) - y2 * Math.Sin(angleX); double y3 = center.Y + x2 * Math.Sin(angleX) + y2 * Math.Cos(angleX); double z3 = center.Z + z2; model.SetPoint(i, x3, y3, z3); } }
public static void Transform(Mesh3D model, Point3D center, Double aX, Double aZ) { var angleX = 3.1415926 * aX * DegInverse; var angleZ = 3.1415926 * aZ * DegInverse; var nVertNo = model.GetVertexNo(); for (var i = 0; i < nVertNo; i++) { var pt1 = model.GetPoint(i); // rotate from z-axis var x2 = pt1.X * Math.Cos(angleZ) + pt1.Z * Math.Sin(angleZ); var y2 = pt1.Y; var z2 = -pt1.X * Math.Sin(angleZ) + pt1.Z * Math.Cos(angleZ); var x3 = center.X + x2 * Math.Cos(angleX) - y2 * Math.Sin(angleX); var y3 = center.Y + x2 * Math.Sin(angleX) + y2 * Math.Cos(angleX); var z3 = center.Z + z2; model.SetPoint(i, x3, y3, z3); } }