using Microsoft.VisualStudio.TestTools.UnitTesting; using NavisworksTransport.Utils.CoordinateSystem; using System.Numerics; namespace NavisworksTransport.UnitTests.CoordinateSystem { [TestClass] public class RotatedObjectExtentHelperTests { [TestMethod] public void YUp_HostY90_ForRealObject_ShouldKeepUpExtentUnchanged() { var adapter = new HostCoordinateAdapter(CoordinateSystemType.YUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.YUp); Quaternion correction = adapter.CreateHostRotationCorrection( new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, forwardSize: 6.0, sideSize: 4.0, upSize: 2.0, correctionQuaternion: correction); Assert.AreEqual(4.0, result.forwardExtent, 1e-6); Assert.AreEqual(6.0, result.sideExtent, 1e-6); Assert.AreEqual(2.0, result.upExtent, 1e-6); } [TestMethod] public void YUp_HostZ90_ForRealObject_ShouldPromoteForwardSizeToUpExtent() { var adapter = new HostCoordinateAdapter(CoordinateSystemType.YUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.YUp); Quaternion correction = adapter.CreateHostRotationCorrection( new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, forwardSize: 6.0, sideSize: 4.0, upSize: 2.0, correctionQuaternion: correction); Assert.AreEqual(2.0, result.forwardExtent, 1e-6); Assert.AreEqual(4.0, result.sideExtent, 1e-6); Assert.AreEqual(6.0, result.upExtent, 1e-6); } [TestMethod] public void ZUp_HostY90_ShouldPromoteForwardSizeToUpExtent() { var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.ZUp); Quaternion correction = adapter.CreateCanonicalRotationCorrection( new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, forwardSize: 6.0, sideSize: 4.0, upSize: 2.0, correctionQuaternion: correction); Assert.AreEqual(2.0, result.forwardExtent, 1e-6); Assert.AreEqual(4.0, result.sideExtent, 1e-6); Assert.AreEqual(6.0, result.upExtent, 1e-6); } [TestMethod] public void ZUp_HostZ90_ShouldKeepUpExtentUnchanged() { var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.ZUp); Quaternion correction = adapter.CreateCanonicalRotationCorrection( new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, forwardSize: 6.0, sideSize: 4.0, upSize: 2.0, correctionQuaternion: correction); Assert.AreEqual(4.0, result.forwardExtent, 1e-6); Assert.AreEqual(6.0, result.sideExtent, 1e-6); Assert.AreEqual(2.0, result.upExtent, 1e-6); } } }