Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 50 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. Point[] points = new Point[3] { left, top, right };
  2.    
  3. DrawField();DrawCoordinateSystem();
  4.    
  5. graph.FillPolygon(Brushes.ForestGreen, points);
  6.    
  7. Point[] pointsCopy = (Point[]) points.Clone();
  8.    
  9. x = A.x + (A.x - P0.x)
  10. y = A.y + (A.y - P0.y)
  11.    
  12. |B*P0.x + C*P0.y,  C|
  13.       |C*P1.x - B*P1.y, -B|
  14.  A.x = --------------------- ,
  15.           -B*B - C*C
  16.  
  17.       |B,  B*P0.x + C*P0.y|
  18.       |C,  C*P1.y - B*P1.y|
  19.  A.y = ---------------------
  20.           -B*B - C*C
  21.  
  22.  B = P2.x - P1.x
  23.  C = P2.y - P1.y
  24.    
  25. by = -ax - c
  26. y = -a/b x - c/b
  27.    
  28. Point A = new Point( -width, -(a / b) * -width - c / b );
  29. Point B = new Point( width, -(a / b) * width - c / b );
  30.    
  31. float[,] L = new float[2, 3] {
  32.     { A.X, A.Y, 1 },
  33.     { B.X, B.Y, 1 }
  34. };
  35.    
  36. float[,] X = new float[3, 3] {
  37.     { points[0].X, points[0].Y, 1 },
  38.     { points[1].X, points[1].Y, 1 },
  39.     { points[2].X, points[2].Y, 1 }
  40. };
  41.    
  42. private static float[,] MultiplyMatrix(float[,] a, float[,] b)
  43. {
  44.     float[,] product = new float[a.GetLength(0), b.GetLength(1)];
  45.  
  46.     for (int row = 0; row  product.GetLength(0); row++)
  47.         for (int col = 0; col  product.GetLength(1); col++)
  48.             // Multiply the row of A by the column of B
  49.             for (int inner = 0; inner  a.GetLength(1); inner++)
  50.                 product[row, col] += a[row, inner] * b[inner, col];
  51.  
  52.     return product;
  53. }
  54.    
  55. float ys = -(a / b) * 0 - c / b;
  56.    
  57. float[,] T = new float[3, 3] {
  58.     { 1, 0, 0 },
  59.     { 0, 1, 0 },
  60.     { 0, -ys, 1 }
  61. };
  62.  
  63. L = MultiplyMatrix(L, T);
  64. X = MultiplyMatrix(X, T);
  65.    
  66. double radians = Math.Atan(-(a / b));
  67.    
  68. float[,] R = new float[3, 3] {
  69.     { Math.Cos(radians), -Math.Sin(radians), 0 },
  70.     { Math.Sin(radians), Math.Cos(radians), 0 },
  71.     { 0, 0, 1 }
  72. };
  73.  
  74. L = MultiplyMatrix(L, R);
  75. X = MultiplyMatrix(X, R);
  76.    
  77. float[,] Rr = new float[3, 3] {
  78.     { 1, 0, 0 },
  79.     { 0, -1, 0 },
  80.     { 0, 0, 1 }
  81. };
  82.  
  83. X = MultiplyMatrix(X, Rr);
  84.    
  85. float[,] Rh = new float[3, 3] {
  86.     { Math.Cos(radians), Math.Sin(radians), 0 },
  87.     { -Math.Sin(radians), Math.Cos(radians), 0 },
  88.     { 0, 0, 1 }
  89. };
  90.  
  91. L = MultiplyMatrix(L, Rh);
  92. X = MultiplyMatrix(X, Rh);
  93.    
  94. float[,] Th = new float[3, 3] {
  95.     { 1, 0, 0 },
  96.     { 0, 1, 0 },
  97.     { 0, ys, 1 }
  98. };
  99.  
  100. L = MultiplyMatrix(L, Th);
  101. X = MultiplyMatrix(X, Th);
  102.    
  103. for (int i = 0; i  p.Length; i++)
  104. {
  105.     points[i].X = X[i, 0];
  106.     points[i].Y = X[i, 1];
  107. }
  108.    
  109. graph.FillPolygon(Brushes.RoyalBlue, points);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top