예제 #1
0
        public long XZSqrMagnitude(ref FixVector3 rhs)
        {
            long num  = this.x - rhs.x;
            long num2 = this.z - rhs.z;

            return((num * num) + (num2 * num2));
        }
예제 #2
0
        public static FixVector3 Transform(FixVector3 point, FixVector3 forward, FixVector3 trans, FixVector3 scale)
        {
            FixVector3 up   = FixVector3.up;
            FixVector3 num2 = FixVector3.Cross(FixVector3.up, forward);

            return(Transform(ref point, ref num2, ref up, ref forward, ref trans, ref scale));
        }
예제 #3
0
        public static bool WithInFrontSectorArea(FixVector3 orgin, FixVector3 direction, long radius, FixVector3 position)
        {
            // check distance
            if (FixVector3.SqrDistance(orgin, position) > radius)
            {
                return(false);
            }

            FixVector3 targetDirection = position - orgin;

            float a = FixVector3.Angle(targetDirection, direction);

            //Debug.LogError( a );
            //Debug.DrawLine( orgin, position, Color.red );
            //Debug.DrawLine( orgin, direction, Color.red );

            if (Mathf.Abs(a) < 30)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        public static float Angle(FixVector3 lhs, FixVector3 rhs)
        {
            double d = ((double)Dot(lhs, rhs)) / (lhs.magnitude * rhs.magnitude);

            d = (d >= -1.0) ? ((d <= 1.0) ? d : 1.0) : -1.0;
            return((float)Math.Acos(d));
        }
예제 #5
0
        private static bool isINRect(FixVector3 point, FixVector3 v0, FixVector3 v1, FixVector3 v2, FixVector3 v3)
        {
            long x = point.x;
            long y = point.z;

            long v0x = v0.x;
            long v0y = v0.z;

            long v1x = v1.x;
            long v1y = v1.z;

            long v2x = v2.x;
            long v2y = v2.z;

            long v3x = v3.x;
            long v3y = v3.z;

            if (Multiply(x, y, v0x, v0y, v1x, v1y) * Multiply(x, y, v3x, v3y, v2x, v2y) <= 0 && Multiply(x, y, v3x, v3y, v0x, v0y) * Multiply(x, y, v2x, v2y, v1x, v1y) <= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
 public static FixVector3 Divide(FixVector3 a, int b)
 {
     a.x = Divide(a.x, b);
     a.y = Divide(a.y, b);
     a.z = Divide(a.z, b);
     return(a);
 }
예제 #7
0
 public static FixVector3 Divide(FixVector3 a, long b)
 {
     a.x = (int)Divide((long)a.x, b);
     a.y = (int)Divide((long)a.y, b);
     a.z = (int)Divide((long)a.z, b);
     return(a);
 }
예제 #8
0
 public static FixVector3 Divide(FixVector3 a, long m, long b)
 {
     a.x = (int)Divide((long)(a.x * m), b);
     a.y = (int)Divide((long)(a.y * m), b);
     a.z = (int)Divide((long)(a.z * m), b);
     return(a);
 }
예제 #9
0
        //The length of two point is square root of ( x * x + y * y + z * z ).
        public static int SqrDistance(FixVector3 f1, FixVector3 f2)
        {
            long x = f1.x - f2.x;
            long y = f1.y - f2.y;
            long z = f1.z - f2.z;

            return(Fix32Math.Sqrt((x * x) + (y * y) + (z * z)));
        }
예제 #10
0
        public static FixVector3 Transform(ref FixVector3 point, ref FixVector3 axis_x, ref FixVector3 axis_y, ref FixVector3 axis_z, ref FixVector3 trans, ref FixVector3 scale)
        {
            long num  = point.x * scale.x;
            long num2 = point.y * scale.x;
            long num3 = point.z * scale.x;

            return(new FixVector3(((int)Divide((long)(((axis_x.x * num) + (axis_y.x * num2)) + (axis_z.x * num3)), (long)0xf4240L)) + trans.x, ((int)Divide((long)(((axis_x.y * num) + (axis_y.y * num2)) + (axis_z.y * num3)), (long)0xf4240L)) + trans.y, ((int)Divide((long)(((axis_x.z * num) + (axis_y.z * num2)) + (axis_z.z * num3)), (long)0xf4240L)) + trans.z));
        }
예제 #11
0
        public static bool WithInFrontRectArea(FixVector3 orgin, Quaternion r, long width, long height, FixVector3 position)
        {
            FixVector3 lb = orgin - (new FixVector3(width >> 1, 0, 0)) * r.eulerAngles;
            FixVector3 rb = orgin + (new FixVector3(width >> 1, 0, 0)) * r.eulerAngles;
            FixVector3 lt = orgin + (new FixVector3(-width >> 1, 0, height)) * r.eulerAngles;
            FixVector3 rt = orgin + (new FixVector3(width >> 1, 0, height)) * r.eulerAngles;

            return(isINRect(position, lt, rt, rb, lb));
        }
예제 #12
0
        public static bool WithInCircleArea(FixVector3 orgin, long radius, FixVector3 position)
        {
            if (FixVector3.SqrDistance(orgin, position) <= radius)
            {
                return(true);
            }

            return(false);
        }
예제 #13
0
 static FixVector3()
 {
     zero    = new FixVector3(0, 0, 0);
     one     = new FixVector3(Precision, Precision, Precision);
     half    = new FixVector3(FloatPrecision * 0.5f, FloatPrecision * 0.5f, FloatPrecision * 0.5f);
     forward = new FixVector3(0, 0, Precision);
     up      = new FixVector3(0, Precision, 0);
     right   = new FixVector3(Precision, 0, 0);
 }
예제 #14
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }
            FixVector3 num = (FixVector3)o;

            return(((this.x == num.x) && (this.y == num.y)) && (this.z == num.z));
        }
예제 #15
0
        public static FixVector3 MoveTowards(FixVector3 from, FixVector3 to, int dt)
        {
            FixVector3 num2 = to - from;

            if (num2.sqrMagnitudeLong <= (dt * dt))
            {
                return(to);
            }
            FixVector3 num = to - from;

            return(from + num.NormalizeTo(dt));
        }
예제 #16
0
        public bool Contains(FixVector3 point, bool allowInverse)
        {
            if (!allowInverse)
            {
                return(this.Contains(point));
            }
            bool flag = false;

            if ((((this.width < 0f) && (point.x <= this.xMin)) && (point.x > this.xMax)) || (((this.width >= 0f) && (point.x >= this.xMin)) && (point.x < this.xMax)))
            {
                flag = true;
            }
            return(flag && ((((this.height < 0f) && (point.y <= this.yMin)) && (point.y > this.yMax)) || (((this.height >= 0f) && (point.y >= this.yMin)) && (point.y < this.yMax))));
        }
예제 #17
0
        public static FixFactor AngleInt(FixVector3 lhs, FixVector3 rhs)
        {
            long den = lhs.magnitude * rhs.magnitude;

            return(Fix32Math.acos((long)Dot(ref lhs, ref rhs), den));
        }
예제 #18
0
 public static long DotXZLong(FixVector3 lhs, FixVector3 rhs)
 {
     return((lhs.x * rhs.x) + (lhs.z * rhs.z));
 }
예제 #19
0
 public static long DotLong(ref FixVector3 lhs, ref FixVector3 rhs)
 {
     return(((lhs.x * rhs.x) + (lhs.y * rhs.y)) + (lhs.z * rhs.z));
 }
예제 #20
0
 public static FixVector2 FromInt3XZ(FixVector3 o)
 {
     return(new FixVector2(o.x, o.z));
 }
예제 #21
0
 public static FixVector3 Cross(FixVector3 lhs, FixVector3 rhs)
 {
     return(new FixVector3(Fix32Math.Divide((int)((lhs.y * rhs.z) - (lhs.z * rhs.y)), Precision), Fix32Math.Divide((int)((lhs.z * rhs.x) - (lhs.x * rhs.z)), Precision), Fix32Math.Divide((int)((lhs.x * rhs.y) - (lhs.y * rhs.x)), Precision)));
 }
예제 #22
0
 public static FixVector3 Lerp(FixVector3 a, FixVector3 b, float f)
 {
     return(new FixVector3(Mathf.RoundToInt(a.x * (1f - f)) + Mathf.RoundToInt(b.x * f), Mathf.RoundToInt(a.y * (1f - f)) + Mathf.RoundToInt(b.y * f), Mathf.RoundToInt(a.z * (1f - f)) + Mathf.RoundToInt(b.z * f)));
 }
예제 #23
0
 public static FixVector3 Lerp(FixVector3 a, FixVector3 b, FixFactor f)
 {
     return(new FixVector3(((int)Fix32Math.Divide((long)((b.x - a.x) * f.nom), f.den)) + a.x, ((int)Fix32Math.Divide((long)((b.y - a.y) * f.nom), f.den)) + a.y, ((int)Fix32Math.Divide((long)((b.z - a.z) * f.nom), f.den)) + a.z));
 }
예제 #24
0
 public static FixVector3 Lerp(FixVector3 a, FixVector3 b, int factorNom, int factorDen)
 {
     return(new FixVector3(Fix32Math.Divide((int)((b.x - a.x) * factorNom), factorDen) + a.x, Fix32Math.Divide((int)((b.y - a.y) * factorNom), factorDen) + a.y, Fix32Math.Divide((int)((b.z - a.z) * factorNom), factorDen) + a.z));
 }
예제 #25
0
 public static FixVector3 Transform(FixVector3 point, ref FixVector3 axis_x, ref FixVector3 axis_y, ref FixVector3 axis_z, ref FixVector3 trans)
 {
     return(new FixVector3(Divide((int)(((axis_x.x * point.x) + (axis_y.x * point.y)) + (axis_z.x * point.z)), 0x3e8) + trans.x, Divide((int)(((axis_x.y * point.x) + (axis_y.y * point.y)) + (axis_z.y * point.z)), 0x3e8) + trans.y, Divide((int)(((axis_x.z * point.x) + (axis_y.z * point.y)) + (axis_z.z * point.z)), 0x3e8) + trans.z));
 }
예제 #26
0
 public static int Dot(FixVector3 lhs, FixVector3 rhs)
 {
     return(((lhs.x * rhs.x) + (lhs.y * rhs.y)) + (lhs.z * rhs.z));
 }
예제 #27
0
 public bool IsEqualXZ(ref FixVector3 rhs)
 {
     return((this.x == rhs.x) && (this.z == rhs.z));
 }
예제 #28
0
 public bool Contains(FixVector3 point)
 {
     return((((point.x >= this.xMin) && (point.x < this.xMax)) && (point.y >= this.yMin)) && (point.y < this.yMax));
 }