public static void Offset(Point3d[] pts, double offsetX, double offsetY, double offsetZ) { for (int i = 0; i < pts.Length; i++) { pts[i].Offset(offsetX, offsetY, offsetZ); } }
public static PointF[] Project(Point3d[] pts, double d /* project distance: from eye to screen*/) { PointF[] pt2ds = new PointF[pts.Length]; for (int i = 0; i < pts.Length; i++) { pt2ds[i] = pts[i].GetProjectedPoint(d); } return pt2ds; }
public static Point3d[] Copy(Point3d[] pts) { Point3d[] copy = new Point3d[pts.Length]; for (int i = 0; i < pts.Length; i++) { copy[i] = pts[i].Copy(); } return copy; }
// -1 // V'=q*V*q , public void Rotate(Point3d pt) { this.Normalise(); Quaternion q1 = this.Copy(); q1.Conjugate(); Quaternion qNode = new Quaternion(0, pt.X, pt.Y, pt.Z); qNode = this * qNode * q1; pt.X = qNode.X; pt.Y = qNode.Y; pt.Z = qNode.Z; }
public static bool isForeFace(Point3d pt1, Point3d pt2, Point3d pt3) // pts on a plane { Vector3d v1 = new Vector3d(pt2, pt1); Vector3d v2 = new Vector3d(pt2, pt3); Vector3d v = v1.CrossProduct(v2); return v.DotProduct(new Vector3d(0, 0, 1)) < 0; }
public Vector3d(Point3d startPoint, Point3d endPoint) { X = endPoint.X - startPoint.X; Y = endPoint.Y - startPoint.Y; Z = endPoint.Z - startPoint.Z; }
public Vector3d(Point3d pt) { X = pt.X; Y = pt.Y; Z = pt.Z; }
public static bool isBackFace(Point3d pt1, Point3d pt2, Point3d pt3) { Vector3d v1 = new Vector3d(pt2, pt1); Vector3d v2 = new Vector3d(pt2, pt3); Vector3d v = v1.CrossProduct(v2); return v.DotProduct(new Vector3d(0, 0, 1)) > 0; }
public void Rotate(Point3d[] nodes) { this.Normalise(); Quaternion q1 = this.Copy(); q1.Conjugate(); for (int i = 0; i < nodes.Length; i++) { Quaternion qNode = new Quaternion(0, nodes[i].X, nodes[i].Y, nodes[i].Z); qNode = this * qNode * q1; nodes[i].X = qNode.X; nodes[i].Y = qNode.Y; nodes[i].Z = qNode.Z; } }