Esempio n. 1
0
 public static void Read(this IO.EndianReader s, out Plane3f v)
 {
     v = new Plane3f(
         s.ReadSingle(),                 // X
         s.ReadSingle(),                 // Y
         s.ReadSingle(),                 // Z
         s.ReadSingle()                  // D
         );
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the position of the intersection of a ray with a plane, or null if no such intersection exists.
        /// </summary>
        /// <param name="ray">The ray.</param>
        /// <param name="plane">The plane.</param>
        /// <returns>The position of the intersection of the ray with the plane, or null if no such intersection exists.</returns>
        public static Vector3?GetIntersection(Ray ray, Plane plane)
        {
            var numerator   = Plane.DotNormal(plane, plane.Normal * plane.D - new System.Numerics.Vector3(ray.Origin.X, ray.Origin.Y, ray.Origin.Z));
            var denominator = Plane.DotNormal(plane, new System.Numerics.Vector3(ray.Direction.X, ray.Direction.Y, ray.Direction.Z));

            if (denominator != 0)
            {
                var distanceAlongRay = numerator / denominator;
                return(ray.Origin + ray.Direction * distanceAlongRay);
            }

            return(null);
        }
Esempio n. 3
0
        public static IO.EndianStream Stream(this IO.EndianStream s, ref Plane3f value)
        {
            if (s.IsReading)
            {
                s.Reader.Read(out value);
            }
            else if (s.IsWriting)
            {
                s.Writer.Write(value);
            }

            return(s);
        }
Esempio n. 4
0
 public static void Write(this IO.EndianWriter s, Plane3f v)
 {
     s.Write(v.Normal);
     s.Write(v.D);
 }