@Override
public PointingRay3DFloatDistribution getRays(TrackedPosture3DFloat posture, boolean right, double pointingProbability) {
double handHeightAngle = getHandHeightAngle(posture, right, false);
Point3D hand = getPoint3D(posture, right ? Joints.HandRight : Joints.HandLeft);
Point3D spineShoulder = getPoint3D(posture, Joints.SpineShoulder);
Point3D spineHeadDirection = getPoint3D(posture, Joints.Head).subtract(spineShoulder);
double factor = 0;
final double[] parameters = getParameters();
for (int i = 0; i < parameters.length; i++) {
factor += Math.pow(handHeightAngle, parameters.length - i - 1) * parameters[i];
}
Point3D start = spineShoulder.add(spineHeadDirection.multiply(factor));
return PointingRay3DFloatDistribution.newBuilder().addRay(PointingRay3DFloat.newBuilder()
.setType(PointingType.OTHER)
.setRightHandPointing(right)
.setCertainty((float) pointingProbability)
.setRay(Ray3DFloatType.Ray3DFloat.newBuilder()
.setOrigin(toVec3DFloat(hand))
.setDirection(toVec3DFloat(hand.subtract(start).normalize()))
)
).build();
}