Esempio n. 1
0
 public static Vector3d operator -(Vector3d a, Vector3d b)
 {
     Vector3d derp = new Vector3d();
     derp.X = a.X - a.X;
     derp.Y = a.Y - a.Y;
     derp.Z = a.Z - a.Z;
     return derp;
 }
Esempio n. 2
0
 public static Vector3d operator +(Vector3d a, Vector3d b)
 {
     Vector3d derp = new Vector3d();
     derp.X = a.X + a.X;
     derp.Y = a.Y + a.Y;
     derp.Z = a.Z + a.Z;
     return derp;
 }
Esempio n. 3
0
 public static double Distance(Vector3d v1, Vector3d v2)
 {
     if (v1 == null || v2 == null) return double.MaxValue;
     double x = v1.X - v2.X;
     double y = v1.Y - v2.Y;
     double z = v1.Z - v2.Z;
     return Math.Sqrt(x * x + y * y + z * z);
 }
Esempio n. 4
0
 public Vector3i(Vector3d f)
 {
     this.X = (long)f.X;
     this.Y = (long)f.Y;
     this.Z = (long)f.Z;
 }
Esempio n. 5
0
 public abstract Vector3d Local2Global(int CX, int CZ, Vector3d local);
Esempio n. 6
0
 public abstract Vector3d Global2Local(Vector3d global, out int CX, out int CZ);
Esempio n. 7
0
        public override Vector3d Global2Local(Vector3d global, out int CX, out int CZ)
        {
            Vector3d r = global;
            CX = (int)r.X / ChunkX;
            CZ = (int)r.Z / ChunkZ;

            r.X = r.X % ChunkX; //(px >> 4) & 0xf;
            r.Z = r.Z % ChunkZ; //(py >> 4) & 0xf;
            return r;
        }
Esempio n. 8
0
 public override Vector3d Local2Global(int CX, int CZ, Vector3d local)
 {
     Vector3d r = local;
     r.X += CX * ChunkX;
     r.Z += CZ * ChunkZ;
     return r;
 }
Esempio n. 9
0
        /// <summary>
        /// Calculates interpolated point between two points using Catmull-Rom Spline
        /// </summary>
        /// <remarks>
        /// Points calculated exist on the spline between points two and three.
        /// </remarks>
        /// <param name="p0">First Point</param>
        /// <param name="p1">Second Point</param>
        /// <param name="p2">Third Point</param>
        /// <param name="p3">Fourth Point</param>
        /// <param name="t">
        /// Normalised distance between second and third point 
        /// where the spline point will be calculated
        /// </param>
        /// <returns>
        /// Calculated Spline Point
        /// </returns>
        public static Vector3d PointOnCurve(Vector3d p0, Vector3d p1, Vector3d p2, Vector3d p3, double t)
        {
            Vector3d ret = new Vector3d(0,0,0);

            double t2 = t * t;
            double t3 = t2 * t;

            ret.X = 0.5d * ((2.0d * p1.X) +
            (-p0.X + p2.X) * t +
            (2.0d * p0.X - 5.0d * p1.X + 4 * p2.X - p3.X) * t2 +
            (-p0.X + 3.0d * p1.X - 3.0d * p2.X + p3.X) * t3);

            ret.Y = 0.5d * ((2.0d * p1.Y) +
            (-p0.Y + p2.Y) * t +
            (2.0d * p0.Y - 5.0d * p1.Y + 4 * p2.Y - p3.Y) * t2 +
            (-p0.Y + 3.0d * p1.Y - 3.0d * p2.Y + p3.Y) * t3);

            ret.Z = 0.5d * ((2.0d * p1.Z) +
            (-p0.Z + p2.Z) * t +
            (2.0d * p0.Z - 5.0d * p1.Z + 4 * p2.Z - p3.Z) * t2 +
            (-p0.Z + 3.0d * p1.Z - 3.0d * p2.Z + p3.Z) * t3);

            return ret;
        }