Аффинные преобразования в пространстве. Простейшие аффинные преобразования в пространстве: перенос, сдвиг, поворот, масштабирование, страница 5

{

g.DrawLine(setka, 0, XY.Y, pnlYOZ.Size.Width, XY.Y);

if (count != 0)

g.DrawString(count.ToString(), txt, Brushes.Black, centerYOZ.X - 1.5f * txt.Size, XY.Y);

}

//рисование координатных осей

g.DrawLine(OXY, 0, centerYOZ.Y, pnlYOZ.Size.Width, centerYOZ.Y);

g.DrawLine(OXY, centerYOZ.X, 0, centerYOZ.X, pnlYOZ.Size.Height);

g.DrawString("0", txt, Brushes.Black, centerYOZ.X - txt.Size, centerYOZ.Y);

cx = local_y;

cy = local_z;

relX = cx / stepX;

relY = cy / stepY;

XY.X = centerYOZ.X + relX;

XY.Y = centerYOZ.Y - relY;

g.FillEllipse(Brushes.Green, XY.X - 10, XY.Y - 10, 20, 20);

for (int i = 0; i < 8; i++) //преобразование точек плоскости в экранные

{

cx = old_points[1, i];

cy = old_points[2, i];

relX = cx / stepX;

relY = cy / stepY;

XY.X = relX + centerYOZ.X;

XY.Y = centerYOZ.Y - relY;

old_scr_points[i].X = XY.X;

old_scr_points[i].Y = XY.Y;

}

g.DrawLine(figur1, old_scr_points[0], old_scr_points[3]); //рисование фигуры

g.DrawLine(figur1, old_scr_points[0], old_scr_points[1]);

g.DrawLine(figur1, old_scr_points[1], old_scr_points[2]);

g.DrawLine(figur1, old_scr_points[2], old_scr_points[3]);

g.DrawLine(figur1, old_scr_points[0], old_scr_points[4]);

g.DrawLine(figur1, old_scr_points[1], old_scr_points[5]);

g.DrawLine(figur1, old_scr_points[2], old_scr_points[6]);

g.DrawLine(figur1, old_scr_points[3], old_scr_points[7]);

g.DrawLine(figur1, old_scr_points[4], old_scr_points[5]);

g.DrawLine(figur1, old_scr_points[5], old_scr_points[6]);

g.DrawLine(figur1, old_scr_points[4], old_scr_points[7]);

g.DrawLine(figur1, old_scr_points[7], old_scr_points[6]);

for (int i = 0; i < 8; i++) //преобразование точек плоскости в экранные

{

cx = points[1, i];

cy = points[2, i];

relX = cx / stepX;

relY = cy / stepY;

XY.X = relX + centerYOZ.X;

XY.Y = centerYOZ.Y - relY;

scr_points[i].X = XY.X;

scr_points[i].Y = XY.Y;

}

g.DrawLine(figur, scr_points[0], scr_points[3]); //рисование фигуры

g.DrawLine(figur, scr_points[0], scr_points[1]);

g.DrawLine(figur, scr_points[1], scr_points[2]);

g.DrawLine(figur, scr_points[2], scr_points[3]);

g.DrawLine(figur, scr_points[0], scr_points[4]);

g.DrawLine(figur, scr_points[1], scr_points[5]);

g.DrawLine(figur, scr_points[2], scr_points[6]);

g.DrawLine(figur, scr_points[3], scr_points[7]);

g.DrawLine(figur, scr_points[4], scr_points[5]);

g.DrawLine(figur, scr_points[5], scr_points[6]);

g.DrawLine(figur, scr_points[4], scr_points[7]);

g.DrawLine(figur, scr_points[7], scr_points[6]);

}

private void frmFlatCurve_Paint(object sender, PaintEventArgs e)

{

Graphics g = e.Graphics;

Pen p = new Pen(Color.Black,3);

Font txt = new Font("Arial", 14, FontStyle.Bold);

g.DrawLine(p, 20 + pnlXOZ.Size.Width, 0, 20 + pnlXOZ.Width, this.Size.Height-70);

g.DrawLine(p, 0, 20 + pnlXOZ.Size.Height, this.Size.Width - 100, 20 + pnlXOZ.Size.Height);

g.DrawString("Z", txt, Brushes.Black, 20 + pnlXOZ.Size.Width + 5, 5);

g.DrawString("X", txt, Brushes.Black, 5, 20 + pnlXOZ.Size.Height);

g.DrawString("Y", txt, Brushes.Black, this.Size.Width-100, 20 + pnlXOZ.Size.Height);

g.DrawString("Y", txt, Brushes.Black, 20 + pnlXOZ.Size.Width, this.Size.Height - 70);

}

void koords_print()

{

int i;

txtOutput.Clear();

for (i = 0; i < vertex_count; i++)

{

txtOutput.Text += "Вершина " + (i + 1).ToString() + ":\n";

txtOutput.Text += "X = " + points[0, i].ToString() + "      " + "Y = " + points[1, i].ToString() + "      " + "Z = " + points[2, i].ToString() + "\n\n";

}

}

private void btnStartPerenos_Click(object sender, EventArgs e)

{

float xx, yy, zz;

try

{

xx = float.Parse(txtPeren_X.Text);

yy = float.Parse(txtPeren_Y.Text);

zz = float.Parse(txtPeren_Z.Text);

}

catch