Pārlūkot izejas kodu

Always use double

Daniele Bartolini 9 gadi atpakaļ
vecāks
revīzija
bba11aa806

+ 5 - 5
tools/core/math/MathUtils.cs

@@ -9,21 +9,21 @@ namespace Crown
 {
 	public static class MathUtils
 	{
-		public static bool Fequal(float a, float b, float epsilon = 0.00001f)
+		public static bool Equal(double a, double b, double epsilon = 0.00001f)
 		{
 			return b <= (a + epsilon)
 				&& b >= (a - epsilon)
 				;
 		}
 
-		public static float Frad(float deg)
+		public static double Rad(double deg)
 		{
-			return deg * (float)Math.PI / 180.0f;
+			return deg * Math.PI / 180.0;
 		}
 
-		public static float Fdeg(float rad)
+		public static double Deg(double rad)
 		{
-			return rad * 180.0f / (float)Math.PI;
+			return rad * 180.0 / Math.PI;
 		}
 	}
 }

+ 7 - 15
tools/core/math/Quaternion.cs

@@ -10,9 +10,9 @@ namespace Crown
 {
 	public struct Quaternion
 	{
-		public float x, y, z, w;
+		public double x, y, z, w;
 
-		public Quaternion(float x, float y, float z, float w)
+		public Quaternion(double x, double y, double z, double w)
 		{
 			this.x = x;
 			this.y = y;
@@ -20,20 +20,12 @@ namespace Crown
 			this.w = w;
 		}
 
-		public Quaternion(double x, double y, double z, double w)
-		{
-			this.x = (float)x;
-			this.y = (float)y;
-			this.z = (float)z;
-			this.w = (float)w;
-		}
-
 		public Quaternion(ArrayList arr)
 		{
-			this.x = (float)(double)arr[0];
-			this.y = (float)(double)arr[1];
-			this.z = (float)(double)arr[2];
-			this.w = (float)(double)arr[3];
+			this.x = (double)arr[0];
+			this.y = (double)arr[1];
+			this.z = (double)arr[2];
+			this.w = (double)arr[3];
 		}
 
 		public Quaternion(Vector3 axis, float angle)
@@ -47,7 +39,7 @@ namespace Crown
 			this.w = ca;
 		}
 
-		public static Quaternion FromEuler(float rx, float ry, float rz)
+		public static Quaternion FromEuler(double rx, double ry, double rz)
 		{
 			// http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/
 			double c1 = Math.Cos(ry*0.5);

+ 4 - 10
tools/core/math/Vector2.cs

@@ -10,24 +10,18 @@ namespace Crown
 {
 	public struct Vector2
 	{
-		public float x, y;
+		public double x, y;
 
-		public Vector2(float x, float y)
+		public Vector2(double x, double y)
 		{
 			this.x = x;
 			this.y = y;
 		}
 
-		public Vector2(double x, double y)
-		{
-			this.x = (float)x;
-			this.y = (float)y;
-		}
-
 		public Vector2(ArrayList arr)
 		{
-			this.x = (float)(double)arr[0];
-			this.y = (float)(double)arr[1];
+			this.x = (double)(double)arr[0];
+			this.y = (double)(double)arr[1];
 		}
 
 		public static Vector2 operator+(Vector2 a, Vector2 b)

+ 5 - 12
tools/core/math/Vector3.cs

@@ -10,27 +10,20 @@ namespace Crown
 {
 	public struct Vector3
 	{
-		public float x, y, z;
+		public double x, y, z;
 
-		public Vector3(float x, float y, float z)
+		public Vector3(double x, double y, double z)
 		{
 			this.x = x;
 			this.y = y;
 			this.z = z;
 		}
 
-		public Vector3(double x, double y, double z)
-		{
-			this.x = (float)x;
-			this.y = (float)y;
-			this.z = (float)z;
-		}
-
 		public Vector3(ArrayList arr)
 		{
-			this.x = (float)(double)arr[0];
-			this.y = (float)(double)arr[1];
-			this.z = (float)(double)arr[2];
+			this.x = (double)arr[0];
+			this.y = (double)arr[1];
+			this.z = (double)arr[2];
 		}
 
 		public static Vector3 operator+(Vector3 a, Vector3 b)

+ 6 - 14
tools/core/math/Vector4.cs

@@ -10,9 +10,9 @@ namespace Crown
 {
 	public struct Vector4
 	{
-		public float x, y, z, w;
+		public double x, y, z, w;
 
-		public Vector4(float x, float y, float z, float w)
+		public Vector4(double x, double y, double z, double w)
 		{
 			this.x = x;
 			this.y = y;
@@ -20,20 +20,12 @@ namespace Crown
 			this.w = w;
 		}
 
-		public Vector4(double x, double y, double z, double w)
-		{
-			this.x = (float)x;
-			this.y = (float)y;
-			this.z = (float)z;
-			this.w = (float)w;
-		}
-
 		public Vector4(ArrayList arr)
 		{
-			this.x = (float)(double)arr[0];
-			this.y = (float)(double)arr[1];
-			this.z = (float)(double)arr[2];
-			this.w = (float)(double)arr[3];
+			this.x = (double)arr[0];
+			this.y = (double)arr[1];
+			this.z = (double)arr[2];
+			this.w = (double)arr[3];
 		}
 
 		public static Vector4 operator+(Vector4 a, Vector4 b)