Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Point[] points = new Point[3] { left, top, right };
- DrawField();DrawCoordinateSystem();
- graph.FillPolygon(Brushes.ForestGreen, points);
- Point[] pointsCopy = (Point[]) points.Clone();
- x = A.x + (A.x - P0.x)
- y = A.y + (A.y - P0.y)
- |B*P0.x + C*P0.y, C|
- |C*P1.x - B*P1.y, -B|
- A.x = --------------------- ,
- -B*B - C*C
- |B, B*P0.x + C*P0.y|
- |C, C*P1.y - B*P1.y|
- A.y = ---------------------
- -B*B - C*C
- B = P2.x - P1.x
- C = P2.y - P1.y
- by = -ax - c
- y = -a/b x - c/b
- Point A = new Point( -width, -(a / b) * -width - c / b );
- Point B = new Point( width, -(a / b) * width - c / b );
- float[,] L = new float[2, 3] {
- { A.X, A.Y, 1 },
- { B.X, B.Y, 1 }
- };
- float[,] X = new float[3, 3] {
- { points[0].X, points[0].Y, 1 },
- { points[1].X, points[1].Y, 1 },
- { points[2].X, points[2].Y, 1 }
- };
- private static float[,] MultiplyMatrix(float[,] a, float[,] b)
- {
- float[,] product = new float[a.GetLength(0), b.GetLength(1)];
- for (int row = 0; row product.GetLength(0); row++)
- for (int col = 0; col product.GetLength(1); col++)
- // Multiply the row of A by the column of B
- for (int inner = 0; inner a.GetLength(1); inner++)
- product[row, col] += a[row, inner] * b[inner, col];
- return product;
- }
- float ys = -(a / b) * 0 - c / b;
- float[,] T = new float[3, 3] {
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, -ys, 1 }
- };
- L = MultiplyMatrix(L, T);
- X = MultiplyMatrix(X, T);
- double radians = Math.Atan(-(a / b));
- float[,] R = new float[3, 3] {
- { Math.Cos(radians), -Math.Sin(radians), 0 },
- { Math.Sin(radians), Math.Cos(radians), 0 },
- { 0, 0, 1 }
- };
- L = MultiplyMatrix(L, R);
- X = MultiplyMatrix(X, R);
- float[,] Rr = new float[3, 3] {
- { 1, 0, 0 },
- { 0, -1, 0 },
- { 0, 0, 1 }
- };
- X = MultiplyMatrix(X, Rr);
- float[,] Rh = new float[3, 3] {
- { Math.Cos(radians), Math.Sin(radians), 0 },
- { -Math.Sin(radians), Math.Cos(radians), 0 },
- { 0, 0, 1 }
- };
- L = MultiplyMatrix(L, Rh);
- X = MultiplyMatrix(X, Rh);
- float[,] Th = new float[3, 3] {
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, ys, 1 }
- };
- L = MultiplyMatrix(L, Th);
- X = MultiplyMatrix(X, Th);
- for (int i = 0; i p.Length; i++)
- {
- points[i].X = X[i, 0];
- points[i].Y = X[i, 1];
- }
- graph.FillPolygon(Brushes.RoyalBlue, points);
Add Comment
Please, Sign In to add comment