Beispiel #1
0
        public bool Intersect(Plane3D b, out Line3D intersection)
        {
            intersection = null;

            if (IsParallel(b)) return false;

            Point3D p;
            Vector3D v1 = Normal.CrossProduct(b.Normal);
            Vector3D v2 = new Vector3D(v1.X * v1.X, v1.Y * v1.Y, v1.Z * v1.Z);
            double w1 = -Distance;
            double w2 = -b.Distance;
            double id;

            if ((v2.Z > v2.Y) && (v2.Z > v2.X) && (v2.Z > Double.Epsilon))
            {
                // point on XY plane
                id = 1.0 / v1.Z;
                p = new Point3D(Normal.Y * w2 - b.Normal.Y * w1, b.Normal.X * w1 - Normal.X * w2, 0.0);
            }
            else if ((v2.Y > v2.X) && (v2.Y > Double.Epsilon))
            {
                // point on XZ plane
                id = -1.0 / v1.Y;
                p = new Point3D(Normal.Z * w2 - b.Normal.Z * w1, 0.0, b.Normal.Y * w1 - Normal.Y * w2);
            }
            else if (v2.X > Double.Epsilon)
            {
                // point on YZ plane
                id = 1.0 / v1.X;
                p = new Point3D(0.0, Normal.Z * w2 - b.Normal.Z * w1, b.Normal.Y * w1 - Normal.Y * w2);
            }
            else return false;

            p = (p.ToVector() * id).ToPoint();
            id = 1.0 / Math.Sqrt(v2.X + v2.Y + v2.Z);
            v1 *= id;

            intersection = new Line3D(p, p.ToVector() + v1);

            return true;
        }
Beispiel #2
0
        public Slice3D(Vector3D normal, Point3D topLeft, double width, double height)
        {
            Vector3D right = normal.Rotate(Vector3D.AxisY, -90.0);
            Vector3D down = normal.Rotate(Vector3D.AxisX, -90.0);

            _topLeft = topLeft;
            _topRight = _topLeft + (right * width);
            _bottomLeft = _topLeft + (down * height);
            _bottomRight = _bottomLeft + (right * width);

            _normal = normal;
            _width = width;
            _height = height;
            _plane = new Plane3D(normal, _topLeft);
        }
Beispiel #3
0
 public bool IsParallel(Plane3D plane)
 {
     return Normal == plane.Normal;
 }