Example #1
0
        public void QuaternionVersusMatrixMovingTests()
        {
            XbimVector3D t = new XbimVector3D(2, 0, 0);
            XbimMatrix3D T = new XbimMatrix3D(t);

            T.RotateAroundZAxis(Math.PI / 2);
            XbimQuaternion q;

            XbimQuaternion.RotationMatrix(ref T, out q);

            // Do the quaternion approach
            XbimVector3D v = new XbimVector3D(1, 1, 0);
            XbimVector3D v1;

            XbimQuaternion.Transform(ref v, ref q, out v1);
            // Rotate and translate
            var p1Result = v1 + t;

            // Do the same with matrix approach
            XbimPoint3D p        = new XbimPoint3D(1, 1, 0);
            var         p2Result = T.Transform(p);

            Assert.AreEqual(p1Result, XbimPoint3D.Subtract(p2Result, XbimPoint3D.Zero));

            // Test quaternion and delta translation (relocating)
            XbimVector3D mt       = new XbimVector3D(2, 2, 0);
            var          dt       = t - mt;
            var          pMoved   = v1 + dt;
            var          p3Result = pMoved + mt;

            Assert.AreEqual(p1Result, p3Result);
        }
Example #2
0
        /// <summary>
        /// distance point is from the axially aligned bounding boxes (usually in object space)
        /// </summary>
        /// <param name="pt">Point to get closet point on bounding box from</param>
        /// <param name="boundBox">Bounding Box as Rect3D</param>
        /// <returns>Distance from the box edge</returns>
        internal static double DistanceFromSpace(XbimPoint3D pt, XbimRect3D boundBox)
        {
            XbimPoint3D  hitPt = ClosetPointOnBoundingBox(pt, boundBox);
            XbimVector3D vect  = XbimPoint3D.Subtract(pt, hitPt);

            return(vect.Length);
        }
Example #3
0
 private double GetDistance(XbimPoint3D a, IfcCartesianPoint b)
 {
     return(XbimPoint3D.Subtract(a, b.XbimPoint3D()).Length);
 }