public void UnityToIRescue() { Vector3 xyzd = new Vector3(90, -45, -45); Vector3 zxyd = new Vector3(45, -90, -45); Vector3 actual = EulerAnglesConversion.ZXYtoXYZ(zxyd); Assert.AreEqual(xyzd.ToString(), actual.ToString()); xyzd = new Vector3(90, 90, -90); zxyd = new Vector3(0, -90, 180); actual = EulerAnglesConversion.ZXYtoXYZ(zxyd); Assert.AreEqual(xyzd.ToString(), actual.ToString()); xyzd = new Vector3(0, 0, 0); zxyd = new Vector3(0, 0, 0); actual = EulerAnglesConversion.ZXYtoXYZ(zxyd); Assert.AreEqual(xyzd.ToString(), actual.ToString()); }
/// <summary> /// Get all the transforms of the visible markers. /// </summary> /// <returns>Hash table with the marker id as the key and an IRVectorTransform as the value.</returns> private Dictionary <int, TransformationMatrix> GetVisibleMarkers() { List <int> visibleMarkers = this.markerDetector.updatedMarkerTransforms; if (visibleMarkers.Count > 0) { this.visibleMarkerTransforms = new Dictionary <int, TransformationMatrix>(); } for (int i = 0; i < visibleMarkers.Count; i++) { int markerId = visibleMarkers[i]; UnityEngine.Vector3 metaOrientation = EulerAnglesConversion.ZXYtoXYZ(IMULocalizer.Instance.localizerOrientation); this.markerDetector.SetMarkerTransform(markerId, ref this.markerTransform); ////Remove meta sdk added rotation for horizontal markers this.markerTransform.Rotate(UnityEngine.Vector3.right, 90f); UnityEngine.Vector3 xyzAngles = EulerAnglesConversion.ZXYtoXYZ(this.markerTransform.eulerAngles); TransformationMatrix tcm = new TransformationMatrix( this.markerTransform.position.x, this.markerTransform.position.y, this.markerTransform.position.z, xyzAngles.x, xyzAngles.y, xyzAngles.z); TransformationMatrix tum = new TransformationMatrix(); tum[3, 3] = 1; // Remove the imu orientation that the meta sdk added. TransformationMatrix Tcu = new TransformationMatrix(0, 0, 0, metaOrientation.x, metaOrientation.y, metaOrientation.z); Tcu.Inverse().Multiply(tcm, tum); // Rotate with 180 degrees in y to get transformation to the front of the marker instead of to the back. tum.Multiply(new TransformationMatrix(0, 0, 0, 0, 180, 0), tum); this.visibleMarkerTransforms.Add(markerId, tum); } return(this.visibleMarkerTransforms); }