void draw3D() { g.Clear(Color.Black); int m = min(pictureBox1.Width, pictureBox1.Height); int a1 = trackBar2.Value * 2 / 3, a2 = trackBar2.Value / 3; double k = Convert.ToDouble(textBox1.Text); double l = Convert.ToDouble(textBox1.Text);//множетили //a1 = 180; d3 p1, p2; for (int i = 0; i < a1; i += 10) { for (int j = 0; j < a2; j += 10) { p1 = new d3((m / 2) * Math.Sin(i * 2 * Math.PI / a1) * Math.Sin(j * 2 * Math.PI / a2), (m / 2) * Math.Cos(i * 2 * Math.PI / a1) * Math.Sin(j * 2 * Math.PI / a2), (m / 2) * Math.Cos(j * 2 * Math.PI / a2)); p2 = new d3((m / 2) * Math.Sin(i * 2 * k * Math.PI / a1) * Math.Sin(j * 2 * l * Math.PI / a2), (m / 2) * Math.Cos(i * 2 * k * Math.PI / a1) * Math.Sin(j * 2 * l * Math.PI / a2), (m / 2) * Math.Cos(j * 2 * l * Math.PI / a2)); d3.draw_line(p1, p2, pictureBox1, g); } } pictureBox1.Image = bmp; }
public static void draw_line(d3 point1, d3 point2, PictureBox p, Graphics g) {//отображение прямой на пикчерБоксе point1.x = point1.X * E1.C[0] + point1.Y * E1.C[1] + point1.Z * E1.C[2]; point1.y = point1.X * E2.C[0] + point1.Y * E2.C[1] + point1.Z * E2.C[2]; point2.x = point2.X * E1.C[0] + point2.Y * E1.C[1] + point2.Z * E1.C[2]; point2.y = point2.X * E2.C[0] + point2.Y * E2.C[1] + point2.Z * E2.C[2]; g.DrawLine(Pens.White, (float)point1.x + p.Width / 2, (float)point1.y + p.Height / 2, (float)point2.x + p.Width / 2, (float)point2.y + p.Height / 2); }
public static void draw_point(d3 point, PictureBox p, Graphics g) {//отображение точки на пикчерБоксе point.x = point.X * E1.C[0] + point.Y * E1.C[1] + point.Z * E1.C[2]; point.y = point.X * E2.C[0] + point.Y * E2.C[1] + point.Z * E2.C[2]; g.FillEllipse(Brushes.White, (float)point.x + p.Width / 2, (float)point.y + p.Height / 2, 2, 2); }