Exemple #1
0
 /// <summary>
 /// Inersection of plane with line
 /// </summary>
 /// <param name="line"></param>
 /// <param name="inter"></param>
 /// <returns>true if intersection exists</returns>
 public bool intersectLine(Geom3DLine line, Geom3DVector inter)
 {
     float q = normal.x * (origin.x - line.point.x) + normal.y * (origin.y - line.point.y) + normal.z * (origin.z - line.point.z);
     float d = normal.x * line.dir.x + normal.y * line.dir.y + normal.z * line.dir.z;
     if (d == 0)
     {
         inter.x = inter.y = inter.z = 0;
         return false;
     }
     float r = q / d;
     inter.x = line.point.x + r * line.dir.x;
     inter.y = line.point.y + r * line.dir.y;
     inter.z = line.point.z + r * line.dir.z;
     return true;
 }
Exemple #2
0
        /// <summary>
        /// Inersection of plane with line
        /// </summary>
        /// <param name="line"></param>
        /// <param name="inter"></param>
        /// <returns>true if intersection exists</returns>
        public bool intersectLine(Geom3DLine line, Geom3DVector inter)
        {
            float q = normal.x * (origin.x - line.point.x) + normal.y * (origin.y - line.point.y) + normal.z * (origin.z - line.point.z);
            float d = normal.x * line.dir.x + normal.y * line.dir.y + normal.z * line.dir.z;

            if (d == 0)
            {
                inter.x = inter.y = inter.z = 0;
                return(false);
            }
            float r = q / d;

            inter.x = line.point.x + r * line.dir.x;
            inter.y = line.point.y + r * line.dir.y;
            inter.z = line.point.z + r * line.dir.z;
            return(true);
        }