Example #1
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. If <paramref name="flip"/> is true
 /// there is an additional check whether the angle between the two normal vectors is less than
 /// 90°. If not, the y-axis is reversed and the angle between the two normal vectors will be
 /// less than 90°
 /// </summary>
 /// <param name="alignTo">Plane to align to</param>
 /// <param name="relocate">relocate this plane</param>
 /// <param name="flip"></param>
 public void Align(Plane alignTo, bool relocate, bool flip)
 {
     Align(alignTo, relocate);
     if (flip)
     {
         if (new Angle(this.Normal, alignTo.Normal) > Math.PI / 2.0)
         {
             this.coordSys = new CoordSys(this.Location, this.DirectionX, -this.DirectionY);
         }
     }
 }
Example #2
0
 /// <summary>
 /// Creates a new plane with the given parameters. Throws a <see cref="PlaneException"/>, if
 /// the three points are colinear
 /// </summary>
 /// <param name="Location">location of the plane</param>
 /// <param name="p1">specifies the direction of the x-axis</param>
 /// <param name="p2">specifies the direction of the y-axis, wich will be perpendicular to the x-axis</param>
 public Plane(GeoPoint Location, GeoPoint p1, GeoPoint p2)
 {
     try
     {
         coordSys = new CoordSys(Location, p1 - Location, p2 - Location);
     }
     catch (CoordSysException e)
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
 }
Example #3
0
 private CoordSys coordSys; // dieses beschreibt die Ebene durch Location, DirectionX, DirectionY
                            // redundante Daten (nicht speichern)
 /// <summary>
 /// Creates a new plane with the given parameters. Throws a <see cref="PlaneException"/>, if <paramref name="DirectionX"/>
 /// and <paramref name="DirectionY"/> have the same direction.
 /// </summary>
 /// <param name="Location">location of the plane</param>
 /// <param name="DirectionX">direction of the x-axis</param>
 /// <param name="DirectionY">direction of the y-axis, will be adapted if not perpendicular to the x-axis</param>
 public Plane(GeoPoint Location, GeoVector DirectionX, GeoVector DirectionY)
 {
     try
     {
         coordSys = new CoordSys(Location, DirectionX, DirectionY);
     }
     catch (CoordSysException e)
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
 }
Example #4
0
 /// <summary>
 /// Creates a new plane. The parameter data is under-determined for the plane, so the x-axis and y-axis
 /// will be determined arbitrarily
 /// </summary>
 /// <param name="Location">location of the plane</param>
 /// <param name="Normal">normal vector of the plane</param>
 public Plane(GeoPoint Location, GeoVector Normal)
 {   // ist ja nicht eindeutig bezüglich x und y Richtung.
     // hier wird CndOCas verwendet, damit es in gleicher weise wie dort generiert wird.
     if (Normal.IsNullVector())
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
     try
     {
         if (Normal.x == 0 && Normal.y == 0 && Normal.z > 0)
         {   // kommt wohl oft vor:
             coordSys = new CoordSys(Location, GeoVector.XAxis, GeoVector.YAxis);
         }
         else
         //oCasBuddy = new CndOCas.Plane();
         //oCasBuddy.InitFromPntDir(Location.gpPnt(),Normal.gpDir());
         //coordSys = new CoordSys(new GeoPoint(oCasBuddy.Location),new GeoVector(oCasBuddy.DirectionX),new GeoVector(oCasBuddy.DirectionY));
         // OpenCascade ist zu unsicher (gibt manchmal exceptions), deshalb jetzt selbstgestrickt
         {
             GeoVector dx;
             if (Math.Abs(Normal.x) > Math.Abs(Normal.y))
             {
                 if (Math.Abs(Normal.y) < Math.Abs(Normal.z))
                 {   // y ist die kleinste Komponente, also X-Achse
                     dx = GeoVector.YAxis;
                 }
                 else
                 {
                     dx = GeoVector.ZAxis;
                 }
             }
             else
             {
                 if (Math.Abs(Normal.x) < Math.Abs(Normal.z))
                 {   // x ist die kleinste Komponente, also X-Achse
                     dx = GeoVector.XAxis;
                 }
                 else
                 {
                     dx = GeoVector.ZAxis;
                 }
             }
             GeoVector v = Normal ^ dx;
             coordSys = new CoordSys(Location, v, v ^ Normal);
         }
     }
     catch (CoordSysException)
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
 }
Example #5
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));
            }
        }
Example #6
0
        /// <summary>
        /// Creates a new plane parallel to a <see cref="StandardPlane"/> with a given offset
        /// </summary>
        /// <param name="std">the standard plane</param>
        /// <param name="offset">the offset to the standard plane</param>
        public Plane(StandardPlane std, double offset)
        {
            switch (std)
            {
            default:
            case StandardPlane.XYPlane:
                coordSys = new CoordSys(new GeoPoint(0.0, 0.0, offset), new GeoVector(1.0, 0.0, 0.0), new GeoVector(0.0, 1.0, 0.0));
                break;

            case StandardPlane.XZPlane:
                coordSys = new CoordSys(new GeoPoint(0.0, offset, 0.0), new GeoVector(1.0, 0.0, 0.0), new GeoVector(0.0, 0.0, 1.0));
                break;

            case StandardPlane.YZPlane:
                coordSys = new CoordSys(new GeoPoint(offset, 0.0, 0.0), new GeoVector(0.0, 1.0, 0.0), new GeoVector(0.0, 0.0, 1.0));
                break;
            }
        }
Example #7
0
 public Plane(IJsonReadStruct data)
 {
     coordSys = data.GetValue <CoordSys>();
 }
Example #8
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 public Plane(SerializationInfo info, StreamingContext context)
 {
     coordSys = (CoordSys)info.GetValue("CoordSys", typeof(CoordSys));
 }
Example #9
0
 public Plane(Plane basePlane)
 {
     coordSys = new CoordSys(basePlane.Location, basePlane.DirectionX, basePlane.DirectionY);
 }
Example #10
0
 public Plane(Plane basePlane, double offset)
 {
     coordSys = new CoordSys(basePlane.Location + offset * basePlane.Normal, basePlane.DirectionX, basePlane.DirectionY);
 }