Пример #1
0
 public Geom3DLine(Geom3DVector pt, Geom3DVector v, bool isDir)
 {
     point = new Geom3DVector(pt);
     if (isDir)
     {
         dir = new Geom3DVector(v);
     }
     else
     {
         dir = v.sub(pt);
     }
 }
Пример #2
0
        //<Carson(Taipei)><01-31-2019><Modified>
        /// <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;

            if (r < 0)
            {
                return(false);
            }
            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);
        }
Пример #3
0
 public Geom3DPlane(Geom3DVector o, Geom3DVector norm)
 {
     origin = new Geom3DVector(o);
     normal = new Geom3DVector(norm);
 }
Пример #4
0
 public float dot(Geom3DVector v)
 {
     return(x * v.x + y * v.y + z * v.z);
 }
Пример #5
0
 public Geom3DVector sub(Geom3DVector v)
 {
     return(new Geom3DVector(x - v.x, y - v.y, z - v.z));
 }
Пример #6
0
 public Geom3DVector add(Geom3DVector v)
 {
     return(new Geom3DVector(x + v.x, y + v.y, z + v.z));
 }
Пример #7
0
 public Geom3DVector(Geom3DVector v)
 {
     x = v.x;
     y = v.y;
     z = v.z;
 }