Math.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace AtomicEngine
  4. {
  5. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  6. public struct Vector3
  7. {
  8. public Vector3 (float x, float y, float z)
  9. {
  10. this.x = x;
  11. this.y = y;
  12. this.z = z;
  13. }
  14. public override string ToString()
  15. {
  16. return x + ", " + y + ", " + z;
  17. }
  18. public float x;
  19. public float y;
  20. public float z;
  21. /// Zero vector.
  22. static public readonly Vector3 Zero = new Vector3(0, 0, 0);
  23. /// (-1,0,0) vector.
  24. static public readonly Vector3 Left = new Vector3(-1, 0, 0);
  25. /// (1,0,0) vector.
  26. static public readonly Vector3 Right = new Vector3(1, 0, 0);
  27. /// (0,1,0) vector.
  28. static public readonly Vector3 Up = new Vector3(0, 1, 0);
  29. /// (0,-1,0) vector.
  30. static public readonly Vector3 Down = new Vector3(0, -1, 0);
  31. /// (0,0,1) vector.
  32. static public readonly Vector3 Forward = new Vector3(0, 0, 1);
  33. /// (0,0,-1) vector.
  34. static public readonly Vector3 Back = new Vector3(0, 0, -1);
  35. /// (1,1,1) vector.
  36. static public readonly Vector3 One = new Vector3(1, 1, 1);
  37. }
  38. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  39. public struct Vector4
  40. {
  41. }
  42. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  43. public struct Vector2
  44. {
  45. public Vector2 (float x, float y)
  46. {
  47. this.x = x;
  48. this.y = y;
  49. }
  50. public float x;
  51. public float y;
  52. }
  53. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  54. public struct Quaternion
  55. {
  56. public Quaternion (float w = 1.0f, float x = 0.0f, float y = 0.0f, float z = 0.0f)
  57. {
  58. this.w = w;
  59. this.x = x;
  60. this.y = y;
  61. this.z = z;
  62. }
  63. public override string ToString()
  64. {
  65. return x + ", " + y + ", " + z;
  66. }
  67. public float w;
  68. public float x;
  69. public float y;
  70. public float z;
  71. static public readonly Quaternion Identity = new Quaternion();
  72. }
  73. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  74. public struct Color
  75. {
  76. public Color (float r, float g, float b, float a = 1.0f)
  77. {
  78. this.r = r;
  79. this.g = g;
  80. this.b = b;
  81. this.a = a;
  82. }
  83. public float r;
  84. public float g;
  85. public float b;
  86. public float a;
  87. }
  88. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  89. public struct IntRect
  90. {
  91. }
  92. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  93. public struct IntVector2
  94. {
  95. public int x;
  96. public int y;
  97. public IntVector2 (int x, int y)
  98. {
  99. this.x = x;
  100. this.y = y;
  101. }
  102. static public readonly IntVector2 Zero = new IntVector2(0, 0);
  103. }
  104. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  105. public struct BoundingBox
  106. {
  107. }
  108. [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  109. public struct Rect
  110. {
  111. }}