Ejemplo n.º 1
0
 public long Distance(long otherX, long otherY)
 {
     temp1  = this.x - otherX;
     temp1 *= temp1;
     temp2  = this.y - otherY;
     temp2 *= temp2;
     return(FixedMath.Sqrt((temp1 + temp2) >> FixedMath.SHIFT_AMOUNT));
 }
Ejemplo n.º 2
0
        public void Normalize()
        {
            long magnitude = FixedMath.Sqrt(x.Mul(x) + y.Mul(y) + z.Mul(z));

            x = x.Div(magnitude);
            y = y.Div(magnitude);
            z = z.Div(magnitude);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This vector's magnitude.
 /// </summary>
 public long Magnitude()
 {
     temp1 = (this.x * this.x + this.y * this.y);
     if (temp1 == 0)
     {
         return(0);
     }
     temp1 >>= FixedMath.SHIFT_AMOUNT;
     return(FixedMath.Sqrt(temp1));
 }
Ejemplo n.º 4
0
        public long Distance(Vector3d other)
        {
            long tX = other.x - x;

            tX  *= tX;
            tX >>= FixedMath.SHIFT_AMOUNT;
            long tY = other.y - y;

            tY  *= tY;
            tY >>= FixedMath.SHIFT_AMOUNT;
            long tZ = other.z - z;

            tZ  *= tZ;
            tZ >>= FixedMath.SHIFT_AMOUNT;
            return(FixedMath.Sqrt(tX + tY + tZ));
        }
Ejemplo n.º 5
0
        public static Vector2d GenerateRandomPointOnCircle(bool evenDistribution = false)
        {
            long angle    = LSUtility.GetRandomOne().Mul(FixedMath.TwoPi);
            long distance = LSUtility.GetRandomOne();

            if (evenDistribution)
            {
                distance = FixedMath.Sqrt(distance);
            }

            Vector2d randomOffset = new Vector2d(
                FixedMath.Trig.Cos(angle),
                FixedMath.Trig.Sin(angle)
                ) * distance;

            return(randomOffset);
        }
Ejemplo n.º 6
0
            public static long Cos(long theta)
            {
                long sin = Sin(theta);

                return(FixedMath.Sqrt(FixedMath.One - (sin.Mul(sin))));
            }