Example #1
0
        public AppModel()
        {
            CubeTransform = InitializeCubeTransform();

            FrontHand = LeapManager.FrameArrived
                        .Select(f => f.Hands.Frontmost)
                        .Select(h => h?.IsValid == true ? h : null)
                        .ToReadOnlyReactiveProperty();
            InnerProduct = FrontHand
                           .Select(h => h != null ? h.Direction.Dot(h.PalmNormal) : double.NaN)
                           .ToReadOnlyReactiveProperty();

            EulerAngles_org = FrontHand
                              .Select(h => h != null ? h.GetEulerAngles_org() : new EulerAngles())
                              .ToReadOnlyReactiveProperty();
            EulerAngles = FrontHand
                          .Select(h => h != null ? h.GetEulerAngles() : new EulerAngles())
                          .ToReadOnlyReactiveProperty();

            //Rotation = EulerAngles_org
            Rotation = EulerAngles
                       .Select(Rotation3DHelper.ToMatrix3D)
                       .ToReadOnlyReactiveProperty();

            Rotation
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(m => matrixTransform.Matrix = m);
        }
Example #2
0
 public static Quaternion ToQuaternion(this EulerAngles e) =>
 CreateQuaternionInRadians(UnitY, e.Yaw) *
 CreateQuaternionInRadians(UnitX, e.Pitch) *
 CreateQuaternionInRadians(UnitZ, e.Roll);
Example #3
0
 public static Matrix3D ToMatrix3D(this EulerAngles e) => e.ToQuaternion().ToMatrix3D();