Пример #1
0
        public T DistanceTo(Vector3 <T> other, T unit)
        {
            T dx = this.x - other.x;
            T dy = this.y - other.y;
            T dz = this.z - other.z;


            Numeric <T> vx = GenericMath.Abs(dx);

            vx = GenericMath.Power <T>(vx, unit, 2);

            Numeric <T> vy = GenericMath.Abs(dy);

            vy = GenericMath.Power <T>(vy, unit, 2);

            Numeric <T> vz = GenericMath.Abs(dz);

            vz = GenericMath.Power <T>(vz, unit, 2);

            return(GenericMath.Sqrt <T>(vx + vy + vz, unit));


            //(Math.Sqrt(Math.Pow(Math.Abs(x1 - x2), 2) + Math.Pow(Math.Abs(y1 - y2), 2) + Math.Pow(Math.Abs(z1 - z2), 2)));
        }
Пример #2
0
 /// <summary>
 /// Length of the vector
 /// </summary>
 /// <returns></returns>
 public T Length(T unit)
 {
     return(GenericMath.Sqrt <T>(x * x + y * y + z * z, unit));
 }