Exemplo n.º 1
0
        /// <summary>
        /// Checks whether the current triangle intersects with a line segment.
        /// </summary>
        /// <returns>
        /// The distance between the intersection point and v1.
        /// </returns>
        public void Intersects(ref Vector3 v1, ref Vector3 v2, out float?result)
        {
            const float Epsilon = 1E-10F;

            Vector3 dir;

            Vector3.Subtract(ref v2, ref v1, out dir);

            float length = dir.Length();

            if (length <= Epsilon)
            {
                result = null;
                return;
            }

            float inv = 1.0f / length;

            dir.X *= inv;
            dir.Y *= inv;
            dir.Z *= inv;

            RayExtensions.Intersects(new Ray(v1, dir), ref V1, ref V2, ref V3, out result);
            if (result.HasValue && result.Value > length)
            {
                result = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks whether the current triangle intersects with a ray.
        /// </summary>
        public float?Intersects(Ray ray)
        {
            float?result;

            RayExtensions.Intersects(ray, ref V1, ref V2, ref V3, out result);
            return(result);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks whether the current triangle intersects with a ray.
 /// </summary>
 public void Intersects(ref Ray ray, out float?result)
 {
     RayExtensions.Intersects(ray, ref V1, ref V2, ref V3, out result);
 }