Ejemplo n.º 1
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)));
        }
Ejemplo n.º 2
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)));
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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])));
        }
Ejemplo n.º 5
0
        public GodotVector2 Rotated(float phi)
        {
            float s = Angle() + phi;

            return(new GodotVector2(GodotMathf.Cos(s), GodotMathf.Sin(s)) * Length());
        }