The LightBuzz SDK provides Math utilities for measuring distances, angles, and rotations. You can use these utilities with 2D or 3D joint coordinates.
The powerful utility class is called Calculations and provides the following functionality.
Calculations.Distance(Vector3D point1, Vector3D point2) : float
Calculations.Distance(Vector2D point1, Vector2D point2) : float
Measures physical distances (meters) or screen distances (pixels).
The following example measures the distance between the two shoulders in the 3D space:
var shoulderLeft = body.Joints[JointType.ShoulderLeft].Position3D; var shoulderRight = body.Joints[JointType.ShoulderRight].Position3D; float distance = Calculations.Distance(shoulderLeft, shoulderRight);
Calculations.Angle(Vector3D point1, Vector3D point2, Vector3D point3) : float
Calculations.Angle(Vector2D point1, Vector2D point2, Vector2D point3) : float
Measures the angle between three points in the 2D or 3D space.
- The first parameter is the initial point.
- The second parameter is the vertex of the angle.
- The third parameter is the terminal point.
The following examples measures the elbow flexion angle:
var shoulder = body.Joints[JointType.ShoulderLeft].Position3D; var elbow = body.Joints[JointType.ElbowLeft].Position3D; var wrist = body.Joints[JointType.WristLeft].Position3D; float angle = Calculations.Angle(shoulder, elbow, wrist);
The angle is measured in degrees.
Calculations.Rotation(Vector3D point1, Vector3D point2, Plane plane) : float
Measures the rotation of a segment formed by the specified points around the specified plane of motion. The plane of motion could be one of the following:
Image source: ACE Fitness
The following code shows how to measure the rotation of the spine around the sagittal plane of motion:
var neck = body.Joints[JointType.Neck].Position3D; var pelvis = body.Joints[JointType.Pelvis].Position3D; var plane = Plane.Sagittal; float rotation = Calculations.Angle(neck, pelvis, plane);
The rotation angle is measured in degrees.