Пример #1
0
        public GodotVector3 GetEuler()
        {
            GodotBasis   basis = Orthonormalized();
            GodotVector3 vector3;

            vector3.z = 0.0f;
            float num = basis.y[2];

            if (num < 1.0)
            {
                if (num > -1.0)
                {
                    vector3.x = GodotMathf.Asin(-num);
                    vector3.y = GodotMathf.Atan2(basis.x[2], basis.z[2]);
                    vector3.z = GodotMathf.Atan2(basis.y[0], basis.y[1]);
                }
                else
                {
                    vector3.x = 1.570796f;
                    vector3.y = -GodotMathf.Atan2(-basis.x[1], basis.x[0]);
                }
            }
            else
            {
                vector3.x = -1.570796f;
                vector3.y = -GodotMathf.Atan2(basis.x[1], basis.x[0]);
            }
            return(vector3);
        }
Пример #2
0
        public GodotQuat Quat()
        {
            float num1 = x[0] + y[1] + z[2];

            if (num1 > 0.0)
            {
                float num2 = GodotMathf.Sqrt(num1 + 1f) * 2f;
                float num3 = 1f / num2;
                return(new GodotQuat((z[1] - y[2]) * num3, (x[2] - z[0]) * num3, (y[0] - x[1]) * num3, num2 * 0.25f));
            }
            if (x[0] > y[1] && x[0] > z[2])
            {
                float num2 = GodotMathf.Sqrt((float)(x[0] - y[1] - z[2] + 1.0)) * 2f;
                float num3 = 1f / num2;
                return(new GodotQuat(num2 * 0.25f, (x[1] + y[0]) * num3, (x[2] + z[0]) * num3, (z[1] - y[2]) * num3));
            }
            if (y[1] > z[2])
            {
                float num2 = GodotMathf.Sqrt((float)(-x[0] + y[1] - z[2] + 1.0)) * 2f;
                float num3 = 1f / num2;
                return(new GodotQuat((x[1] + y[0]) * num3, num2 * 0.25f, (y[2] + z[1]) * num3, (x[2] - z[0]) * num3));
            }
            float num4 = GodotMathf.Sqrt((float)(-x[0] - y[1] + z[2] + 1.0)) * 2f;
            float num5 = 1f / num4;

            return(new GodotQuat((x[2] + z[0]) * num5, (y[2] + z[1]) * num5, num4 * 0.25f, (y[0] - x[1]) * num5));
        }
Пример #3
0
        public float Length()
        {
            double num1 = x * (double)x;
            float  num2 = y * y;
            float  num3 = z * z;
            double num4 = num2;

            return(GodotMathf.Sqrt((float)(num1 + num4) + num3));
        }
Пример #4
0
        public GodotVector3 Intersect3(GodotPlane b, GodotPlane c)
        {
            float s = normal.Cross(b.normal).Dot(c.normal);

            if (GodotMathf.Abs(s) <= 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            return(((b.normal.Cross(c.normal) * d) + (c.normal.Cross(normal) * b.d) + (normal.Cross(b.normal) * c.d)) / s);
        }
Пример #5
0
        public GodotBasis(GodotVector3 axis, float phi)
        {
            GodotVector3 vector3 = new GodotVector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z);
            float        num1    = GodotMathf.Cos(phi);
            float        num2    = GodotMathf.Sin(phi);

            x = new GodotVector3(vector3.x + (num1 * (1f - vector3.x)), (float)((axis.x * axis.y * (1.0 - num1)) - (axis.z * num2)), (float)((axis.z * axis.x * (1.0 - num1)) + (axis.y * num2)));
            y = new GodotVector3((float)((axis.x * axis.y * (1.0 - num1)) + (axis.z * num2)), vector3.y + (num1 * (1f - vector3.y)), (float)((axis.y * axis.z * (1.0 - num1)) - (axis.x * num2)));
            z = new GodotVector3((float)((axis.z * axis.x * (1.0 - num1)) - (axis.y * num2)), (float)((axis.y * axis.z * (1.0 - num1)) + (axis.x * num2)), vector3.z + (num1 * (1f - vector3.z)));
        }
Пример #6
0
        internal void Normalize()
        {
            float s = ((x * x) + (y * y));

            if (s == 0.0)
            {
                return;
            }
            float num = GodotMathf.Sqrt(s);

            x /= num;
            y /= num;
        }
Пример #7
0
        public GodotQuat Slerpni(GodotQuat b, float t)
        {
            float s1 = Dot(b);

            if (GodotMathf.Abs(s1) > 0.999899983406067)
            {
                return(this);
            }
            float s2   = GodotMathf.Acos(s1);
            float num1 = 1f / GodotMathf.Sin(s2);
            float num2 = GodotMathf.Sin(t * s2) * num1;
            float num3 = GodotMathf.Sin((1f - t) * s2) * num1;

            return(new GodotQuat((num3 * x) + (num2 * b.x), (num3 * y) + (num2 * b.y), (num3 * z) + (num2 * b.z), (num3 * w) + (num2 * b.w)));
        }
Пример #8
0
        public GodotVector3 IntersectRay(GodotVector3 from, GodotVector3 dir)
        {
            float s = normal.Dot(dir);

            if (GodotMathf.Abs(s) <= 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            float num = (normal.Dot(from) - d) / s;

            if (num > 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            return(from + (dir * -num));
        }
Пример #9
0
        public GodotVector3 IntersectSegment(GodotVector3 begin, GodotVector3 end)
        {
            GodotVector3 b = begin - end;
            float        s = normal.Dot(b);

            if (GodotMathf.Abs(s) <= 9.99999997475243E-07)
            {
                return(new GodotVector3());
            }
            float num = (normal.Dot(begin) - d) / s;

            if (num < -9.99999997475243E-07 || num > 1.00000095367432)
            {
                return(new GodotVector3());
            }
            return(begin + (b * -num));
        }
Пример #10
0
        public GodotQuat(GodotVector3 axis, float angle)
        {
            float num1 = axis.Length();

            if (num1 == 0.0)
            {
                x = 0.0f;
                y = 0.0f;
                z = 0.0f;
                w = 0.0f;
            }
            else
            {
                float num2 = GodotMathf.Sin(angle * 0.5f) / num1;
                x = axis.x * num2;
                y = axis.y * num2;
                z = axis.z * num2;
                w = GodotMathf.Cos(angle * 0.5f);
            }
        }
Пример #11
0
        public GodotQuat Slerp(GodotQuat b, float t)
        {
            float s1 = ((x * b.x) + (y * b.y) + (z * b.z) + (w * b.w));

            float[] numArray = new float[4];
            if (s1 < 0.0)
            {
                s1          = -s1;
                numArray[0] = -b.x;
                numArray[1] = -b.y;
                numArray[2] = -b.z;
                numArray[3] = -b.w;
            }
            else
            {
                numArray[0] = b.x;
                numArray[1] = b.y;
                numArray[2] = b.z;
                numArray[3] = b.w;
            }
            float num1;
            float num2;

            if (1.0 - s1 > 9.99999997475243E-07)
            {
                float s2   = GodotMathf.Acos(s1);
                float num3 = GodotMathf.Sin(s2);
                num1 = GodotMathf.Sin((1f - t) * s2) / num3;
                num2 = GodotMathf.Sin(t * s2) / num3;
            }
            else
            {
                num1 = 1f - t;
                num2 = t;
            }
            return(new GodotQuat((num1 * x) + (num2 * numArray[0]), (num1 * y) + (num2 * numArray[1]), (num1 * z) + (num2 * numArray[2]), (num1 * w) + (num2 * numArray[3])));
        }
Пример #12
0
 public GodotVector3 Ceil()
 {
     return(new GodotVector3(GodotMathf.Ceil(x), GodotMathf.Ceil(y), GodotMathf.Ceil(z)));
 }
Пример #13
0
 public GodotVector2 Floor()
 {
     return(new GodotVector2(GodotMathf.Floor(x), GodotMathf.Floor(y)));
 }
Пример #14
0
 public GodotVector3 Abs()
 {
     return(new GodotVector3(GodotMathf.Abs(x), GodotMathf.Abs(y), GodotMathf.Abs(z)));
 }
Пример #15
0
 public float AngleTo(GodotVector3 to)
 {
     return(GodotMathf.Atan2(Cross(to).Length(), Dot(to)));
 }
Пример #16
0
 public float Length()
 {
     return(GodotMathf.Sqrt((x * x) + (y * y)));
 }
Пример #17
0
 public GodotVector3 Snapped(GodotVector3 by)
 {
     return(new GodotVector3(GodotMathf.Stepify(x, by.x), GodotMathf.Stepify(y, by.y), GodotMathf.Stepify(z, by.z)));
 }
Пример #18
0
 public GodotVector3 Floor()
 {
     return(new GodotVector3(GodotMathf.Floor(x), GodotMathf.Floor(y), GodotMathf.Floor(z)));
 }
Пример #19
0
 public float AngleTo(GodotVector2 to)
 {
     return(GodotMathf.Atan2(Cross(to), Dot(to)));
 }
Пример #20
0
        public GodotVector2 Rotated(float phi)
        {
            float s = Angle() + phi;

            return(new GodotVector2(GodotMathf.Cos(s), GodotMathf.Sin(s)) * Length());
        }
Пример #21
0
 public float Length()
 {
     return(GodotMathf.Sqrt(LengthSquared()));
 }
Пример #22
0
 public GodotVector2 Snapped(GodotVector2 by)
 {
     return(new GodotVector2(GodotMathf.Stepify(x, by.x), GodotMathf.Stepify(y, by.y)));
 }
Пример #23
0
 public GodotVector2 Abs()
 {
     return(new GodotVector2(GodotMathf.Abs(x), GodotMathf.Abs(y)));
 }
Пример #24
0
 public float AngleToPoint(GodotVector2 to)
 {
     return(GodotMathf.Atan2(x - to.x, y - to.y));
 }
Пример #25
0
 public float DistanceTo(GodotVector2 to)
 {
     return(GodotMathf.Sqrt(((x - to.x) * (x - to.x)) + ((y - to.y) * (y - to.y))));
 }
Пример #26
0
 public bool IsNormalized()
 {
     return(GodotMathf.Abs(LengthSquared() - 1f) < 9.99999997475243E-07);
 }
Пример #27
0
 public bool HasPoint(GodotVector3 point, float epsilon = 1E-06f)
 {
     return(GodotMathf.Abs(normal.Dot(point) - d) <= (double)epsilon);
 }
Пример #28
0
 public float Angle()
 {
     return(GodotMathf.Atan2(y, x));
 }