private void RotateLine() { double X1 = (double)numericUpDown14.Value; double Y1 = (double)numericUpDown15.Value; double Z1 = (double)numericUpDown16.Value; double X2 = (double)numericUpDown17.Value; double Y2 = (double)numericUpDown18.Value; double Z2 = (double)numericUpDown19.Value; XYZLine l = new XYZLine(new XYZPoint(X1, Y1, Z1), new XYZPoint(X2, Y2, Z2)); double ang = (double)numericUpDown20.Value / 180 * Math.PI; cur_primitive.Apply(Transform.RotateLine(l, ang)); }
public void Draw(Graphics g, Transform projection, int width, int height) { if (Points.Count == 1) { Points[0].Draw(g, projection, width, height); } else { for (int i = 0; i < Points.Count - 1; ++i) { var line = new XYZLine(Points[i], Points[i + 1]); line.Draw(g, projection, width, height); } (new XYZLine(Points[Points.Count - 1], Points[0])).Draw(g, projection, width, height); } }
public static Transform RotateLine(XYZLine line, double angle) { double cos = Math.Cos(angle); double sin = Math.Sin(angle); double l = Math.Sign(line.B.X - line.A.X); double m = Math.Sign(line.B.Y - line.A.Y); double n = Math.Sign(line.B.Z - line.A.Z); double length = Math.Sqrt(l * l + m * m + n * n); l /= length; m /= length; n /= length; return(new Transform( new double[, ] { { l *l + cos *(1 - l * l), l * (1 - cos) * m + n * sin, l * (1 - cos) * n - m * sin, 0 }, { l *(1 - cos) * m - n * sin, m * m + cos * (1 - m * m), m * (1 - cos) * n + l * sin, 0 }, { l *(1 - cos) * n + m * sin, m * (1 - cos) * n - l * sin, n * n + cos * (1 - n * n), 0 }, { 0, 0, 0, 1 } })); }