Exemplo n.º 1
0
        /// <summary>
        /// Determines whether the given line intersects the current instance of <see cref="PlaneF"/>.
        /// </summary>
        /// <param name="line">The line to check.</param>
        /// <param name="scale">When the method completes, contains the line and plane intersection.</param>
        /// <returns>True if the given line intersects the current instance of <see cref="PlaneF"/>; False otherwise.</returns>
        public bool Intersects(ref Line3F line, out float scale)
        {
            scale = 0;
            float d1 = A * line.Start.X + B * line.Start.Y + C * line.Start.Z + D;
            float d2 = A * line.End.X + B * line.End.Y + C * line.End.Z + D;

            if (d1 == d2)
            {
                return(false);
            }
            if (d1 > 0.0f && d2 > 0.0f)
            {
                return(false);
            }
            if (d1 < 0.0f && d2 < 0.0f)
            {
                return(false);
            }
            float fraction = (d1 / (d1 - d2));

            if (fraction < 0.0f || fraction > 1.0f)
            {
                return(false);
            }
            scale = fraction;
            return(true);
        }
Exemplo n.º 2
0
		public bool Equals( Line3F v, float epsilon )
		{
			if( !Start.Equals( v.Start, epsilon ) )
				return false;
			if( !End.Equals( v.End, epsilon ) )
				return false;
			return true;
		}
Exemplo n.º 3
0
        public bool Intersects(Line3F line)
        {
            Vector3F s = line.Start - Origin;
            Vector3F e = line.End - Origin;
            Vector3F r = e - s;
            float    a = Vector3F.Dot(-s, r);

            if (a <= 0)
            {
                return(Vector3F.Dot(s, s) < Radius * Radius);
            }
            else if (a >= Vector3F.Dot(r, r))
            {
                return(Vector3F.Dot(e, e) < Radius * Radius);
            }
            else
            {
                r = s + (a / (Vector3F.Dot(r, r))) * r;
                return(Vector3F.Dot(r, r) < Radius * Radius);
            }
        }
Exemplo n.º 4
0
        public bool Intersects(Line3F line)
        {
            float scale;

            return(Intersects(line, out scale));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Determines whether the given line intersects the current instance of <see cref="PlaneF"/>.
 /// </summary>
 /// <param name="line">The line to check.</param>
 /// <param name="scale">When the method completes, contains the line and plane intersection.</param>
 /// <returns>True if the given line intersects the current instance of <see cref="PlaneF"/>; False otherwise.</returns>
 public bool Intersects(Line3F line, out float scale)
 {
     return(Intersects(ref line, out scale));
 }
Exemplo n.º 6
0
		public Line3F( Line3F source )
		{
			Start = source.Start;
			End = source.End;
		}