예제 #1
0
        /// <summary>
        /// Orient this coordinate system to GCS as if this coordinate system was constrained as a plane (i.e. x' and y' are constrianed by the plane)
        /// If plane is not vertical plane z' will be orientated up.
        /// If plane is vertical y' will be orientated up.
        /// </summary>
        public void OrientPlaneTypeLcsToGcs()
        {
            double dot = this.LocalZ.Normalize().Dot(FdVector3d.UnitZ());

            if (dot == 1)
            {
                // the plane is horisontal and z' is equal to Z

                // set x' to X
                this.SetXAroundZ(FdVector3d.UnitX());
            }
            else if (dot < 1 && dot > 0)
            {
                // the plane is not horisontal nor vertical but z' is pointing up

                // set x' to the cross-product of z' and Z
                // this.SetXAroundZ(FdVector3d.UnitZ().Cross(this.LocalZ));
            }
            else if (dot == 0)
            {
                // the plane is vertical

                // set y' to Z. This is the equivalent as setting x' to the cross-product of z' and Z in this case.
                this.SetYAroundZ(FdVector3d.UnitZ());
            }
            else if (dot < 0 && dot > -1)
            {
                // the plane is not horisontal nor vertical, z' is pointing down

                // flip coordinate system around x' so that z' points up
                this.SetZAroundX(this.LocalZ.Reverse());

                // set x' to the cross-product of z' and Z
                // this.SetXAroundZ(FdVector3d.UnitZ().Cross(this.LocalZ));
            }
            else if (dot == -1)
            {
                // the plane is horisontal but z' is equal to negative Z

                // flip coordinate system around x' so that z' points up
                this.SetZAroundX(this.LocalZ.Reverse());

                // set x' to X
                // this.SetXAroundZ(FdVector3d.UnitX());
            }
            else
            {
                throw new System.ArgumentException($"Impossible to orient axes. Dot product, {dot}, should be between -1 and 1");
            }
        }
예제 #2
0
 /// <summary>
 /// Global coordinate system
 /// </summary>
 public static FdCoordinateSystem Global()
 {
     return(new FdCoordinateSystem(FdPoint3d.Origin(), FdVector3d.UnitX(), FdVector3d.UnitY()));
 }