public void TransformCube(ref Form1.TCube cube, double[,] M) { int index = 0; do { cube.P[index] = this.Generate3Dto2D(cube.P[index], M); checked { ++index; } }while (index <= 7); }
public void DrawCube(Form1.TCube cube, Pen Col) { int index = 0; do { Form1.TPoint V1_One = new TPoint(); this.SetPoint(ref V1_One, cube.P[cube.L[index].p1].x, cube.P[cube.L[index].p1].y, cube.P[cube.L[index].p1].z); V1_One.w = cube.P[cube.L[index].p1].w; Form1.TPoint V1_Two = new TPoint(); this.SetPoint(ref V1_Two, cube.P[cube.L[index].p2].x, cube.P[cube.L[index].p2].y, cube.P[cube.L[index].p2].z); V1_Two.w = cube.P[cube.L[index].p2].w; if (V1_One.w > this.near | V1_Two.w > this.near) { if (V1_Two.w <= this.near) { this.ClipLine(V1_One, ref V1_Two);// clipline saat rotasi x } else { V1_Two.x /= V1_Two.w; V1_Two.y /= V1_Two.w; V1_Two.z /= V1_Two.w; V1_Two.w = 1.0; } if (V1_One.w <= this.near)// clipline abis melewati dalam cube { this.ClipLine(V1_Two, ref V1_One); } else { V1_One.x /= V1_One.w; V1_One.y /= V1_One.w; V1_One.z /= V1_One.w; V1_One.w = 1.0; } if (this.DoClip(ref V1_One, ref V1_Two)) { this.graph.DrawLine(Col, checked ((int)Math.Round(unchecked (V1_One.x * 100.0 + 150.0))), checked ((int)Math.Round(unchecked (V1_One.y * -100.0 + 150.0))), checked ((int)Math.Round(unchecked (V1_Two.x * 100.0 + 150.0))), checked ((int)Math.Round(unchecked (V1_Two.y * -100.0 + 150.0)))); } } checked { ++index; } }while (index <= 11); }