Пример #1
0
        public void Add(GeoPoint from, GeoVector dir, double size, System.Drawing.Color color)
        {
            Line l = Line.Construct();

            l.StartPoint = from;
            l.EndPoint   = from + size * dir.Normalized;
            ColorDef cd = new ColorDef(color.Name, color);

            l.ColorDef = cd;
            toShow.Add(l);
            GeoVector perp = dir ^ GeoVector.ZAxis;

            if (Precision.IsNullVector(perp))
            {
                perp = dir ^ GeoVector.XAxis;
            }
            GeoPoint p1 = from + size * 0.9 * dir.Normalized + size * 0.1 * perp.Normalized;
            GeoPoint p2 = from + size * 0.9 * dir.Normalized - size * 0.1 * perp.Normalized;
            Line     l1 = Line.Construct();

            l1.StartPoint = l.EndPoint;
            l1.EndPoint   = p1;
            l1.ColorDef   = cd;
            toShow.Add(l1);
            Line l2 = Line.Construct();

            l2.StartPoint = l.EndPoint;
            l2.EndPoint   = p2;
            l2.ColorDef   = cd;
            toShow.Add(l2);
        }
Пример #2
0
        public bool Intersect(Plane other, out GeoPoint loc, out GeoVector dir)
        {
            dir = this.Normal ^ other.Normal;
            if (Precision.IsNullVector(dir))
            {
                loc = GeoPoint.Origin;
                dir = GeoVector.XAxis;
                return(false);
            }
            GeoVector ldir = dir ^ Normal;

            loc = other.Intersect(this.Location, ldir);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Aligns the <see cref="DirectionX"/> and <see cref="DirectionY"/> vectors of this plane
        /// so that the projection of DirectionX of AlignTo and DircetionX of this plane are parallel.
        /// If the two planes are parallel, the DirectionX and DirectionY of both planes will
        /// also be parallel. The plane will not be changed. The <see cref="Location"/> of this
        /// plane will be changed to a point closest to the location of AlignTo, if relocate
        /// is true, otherwise the location remains unchanged.
        /// </summary>
        /// <param name="AlignTo">Plane to align to</param>
        /// <param name="relocate">relocate this plane</param>
        public void Align(Plane alignTo, bool relocate)
        {
            GeoVector x0 = ToGlobal(Project(alignTo.DirectionX));

            if (Precision.IsNullVector(x0))
            {                                               // die x-Achse von AlignTo steht senkrecht auf dieser Ebene
                x0 = ToGlobal(Project(alignTo.DirectionY)); // das kann nicht auch noch senkrecht sein
            }
            x0.Norm();
            GeoVector y0 = coordSys.Normal ^ x0;

            coordSys = new CoordSys(coordSys.Location, x0, y0);
            if (relocate)
            {
                coordSys.Location = ToGlobal(Project(alignTo.Location));
            }
        }