Guest User

Untitled

a guest
Jul 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using DJMatrix;
  6.  
  7.  
  8.  
  9. namespace Model1
  10. {
  11. public class Transformation
  12. {
  13. public static Matrix Translate(Vector v)
  14. {
  15.  
  16. float[] temp = v.GetVector();
  17. float[,] tempF = {
  18. {1, 0, 0, temp[0]},
  19. {0, 1, 0, temp[1]},
  20. {0, 0, 1, temp[2]},
  21. {0, 0, 0, 1}
  22. };
  23.  
  24. Matrix m = new Matrix(tempF);
  25. return m;
  26.  
  27. }
  28.  
  29. public static Matrix RotateX(double theta)
  30. {
  31. float[,] tempF = {
  32. {1, 0, 0, 0},
  33. {0, (float)Math.Cos(theta), -(float)(Math.Sin(theta)), 0},
  34. {0, (float)Math.Sin(theta), (float)Math.Cos(theta), 0},
  35. {0, 0, 0, 1}
  36. };
  37. Matrix m = new Matrix(tempF);
  38. return m;
  39. }
  40.  
  41. public static Matrix RotateY(double theta)
  42. {
  43. float[,] tempF = {
  44. {(float)Math.Cos(theta), 0, (float)Math.Sin(theta), 0},
  45. {0, 1, 0, 0},
  46. {-(float)Math.Sin(theta), 0, (float)Math.Cos(theta), 0},
  47. {0, 0, 0, 1}
  48. };
  49. Matrix m = new Matrix(tempF);
  50. return m;
  51. }
  52. public static Matrix RotateZ(double theta)
  53. {
  54. float[,] tempF = {
  55. {(float)Math.Cos(theta), -(float)Math.Sin(theta), 0, 0},
  56. {(float)(Math.Sin(theta)), (float)Math.Cos(theta), 0, 0},
  57. {0, 0, 1, 0},
  58. {0, 0, 0, 1}
  59. };
  60. Matrix m = new Matrix(tempF);
  61. return m;
  62. }
  63. }
  64. }
Add Comment
Please, Sign In to add comment