public void drawArm(int xdim, int ydim, Graphics gr) { int i; double[][] pos1, pos2; double[][] rect1XYZ = new double[4][]; double[][] rect2XYZ = new double[4][]; for (i = 0; i < 4; i++) { rect1XYZ[i] = new double[3]; rect2XYZ[i] = new double[3]; } for (i = 0; i < linknum; i++) { if (i < linknum - 1) { pos1 = linkPosition(i); pos2 = linkPosition(i + 1); rect1XYZ[0][0] = pos1[0][0]; rect1XYZ[0][1] = pos1[1][0]; rect1XYZ[0][2] = pos1[2][0]; rect1XYZ[1][0] = pos1[0][0] + 2; rect1XYZ[1][1] = pos1[1][0]; rect1XYZ[1][2] = pos1[2][0]; rect1XYZ[2][0] = pos1[0][0] + 2; rect1XYZ[2][1] = pos1[1][0] + 2; rect1XYZ[2][2] = pos1[2][0]; rect1XYZ[3][0] = pos1[0][0]; rect1XYZ[3][1] = pos1[1][0] + 2; rect1XYZ[3][2] = pos1[2][0]; // ------------------------ rect2XYZ[0][0] = pos2[0][0]; rect2XYZ[0][1] = pos2[1][0]; rect2XYZ[0][2] = pos2[2][0]; rect2XYZ[1][0] = pos2[0][0] + 2; rect2XYZ[1][1] = pos2[1][0]; rect2XYZ[1][2] = pos2[2][0]; rect2XYZ[2][0] = pos2[0][0] + 2; rect2XYZ[2][1] = pos2[1][0] + 2; rect2XYZ[2][2] = pos2[2][0]; rect2XYZ[3][0] = pos2[0][0]; rect2XYZ[3][1] = pos2[1][0] + 2; rect2XYZ[3][2] = pos2[2][0]; Bar3D bar = new Bar3D(rect1XYZ, rect2XYZ); bar.drawRect3D(xdim, ydim, gr); } } }
private void button2_Click(object sender, EventArgs e) { double[][] rect1 = new double[4][]; double[][] rect2 = new double[4][]; int i; for (i = 0; i < 4; i++) { rect2[i] = new double[3]; rect1[i] = new double[3]; } rect1[0][0] = 0; rect1[0][1] = 0; rect1[0][2] = 10; rect1[1][0] = 10; rect1[1][1] = 0; rect1[1][2] = 10; rect1[2][0] = 10; rect1[2][1] = 3; rect1[2][2] = 10; rect1[3][0] = 0; rect1[3][1] = 3; rect1[3][2] = 10; rect2[0][0] = 0; rect2[0][1] = 0; rect2[0][2] = 20; rect2[1][0] = 10; rect2[1][1] = 0; rect2[1][2] = 20; rect2[2][0] = 10; rect2[2][1] = 3; rect2[2][2] = 20; rect2[3][0] = 0; rect2[3][1] = 3; rect2[3][2] = 20; Graphics g = panel1.CreateGraphics(); int panelx = panel1.Width; int panely = panel1.Height; Bar3D bar = new Bar3D(rect1, rect2); bar.drawRect3D(panelx, panely, g); }