Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created January 16, 2017 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/97659608cd8e63f27277451fec2b3a8c to your computer and use it in GitHub Desktop.
Save sakapon/97659608cd8e63f27277451fec2b3a8c to your computer and use it in GitHub Desktop.
LeapSample / HandRotationLeap
using System;
using System.Windows.Media.Media3D;
namespace HandRotationLeap
{
public static class Leap3DHelper
{
public static Vector3D ToVector3D(this Leap.Vector v) => new Vector3D(v.x, v.y, v.z);
// Wrong values.
public static EulerAngles GetEulerAngles_org(this Leap.Hand h) => new EulerAngles
{
Yaw = h.Direction.Yaw,
Pitch = h.Direction.Pitch,
Roll = h.PalmNormal.Roll,
};
// Improved values.
public static EulerAngles GetEulerAngles(this Leap.Hand h) =>
Rotation3DHelper.ToEulerAngles(-h.Direction.ToVector3D(), -h.PalmNormal.ToVector3D());
}
}
@sakapon
Copy link
Author

sakapon commented Jan 16, 2017

The whole source code is HandRotationLeap (GitHub).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment