本文整理汇总了C++中Finger::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Finger::length方法的具体用法?C++ Finger::length怎么用?C++ Finger::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finger
的用法示例。
在下文中一共展示了Finger::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFrame
void LeapListener::onFrame(const Controller & controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", extended fingers: " << frame.fingers().extended().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl;
HandList hands = frame.hands();
for (HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
std::cout << std::string(2, ' ') << handType << ", id: " << hand.id()
<< ", palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Vector normal = hand.palmNormal();
const Vector direction = hand.direction();
// Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(2, ' ') << "pitch: " << direction.pitch() * RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * RAD_TO_DEG << " degrees" << std::endl;
// Get the Arm bone
Arm arm = hand.arm();
std::cout << std::string(2, ' ') << "Arm direction: " << arm.direction()
<< " wrist position: " << arm.wristPosition()
<< " elbow position: " << arm.elbowPosition() << std::endl;
// Get fingers
const FingerList fingers = hand.fingers();
for (FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) {
const Finger finger = *fl;
std::cout << std::string(4, ' ') << fingerNames[finger.type()]
<< " finger, id: " << finger.id()
<< ", length: " << finger.length()
<< "mm, width: " << finger.width() << std::endl;
// Get finger bones
for (int b = 0; b < 4; ++b) {
Bone::Type boneType = static_cast<Bone::Type>(b);
Bone bone = finger.bone(boneType);
std::cout << std::string(6, ' ') << boneNames[boneType]
<< " bone, start: " << bone.prevJoint()
<< ", end: " << bone.nextJoint()
<< ", direction: " << bone.direction() << std::endl;
}
}
}
// Get tools
const ToolList tools = frame.tools();
for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) {
const Tool tool = *tl;
std::cout << std::string(2, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
}
// Get gestures
const GestureList gestures = frame.gestures();
for (int g = 0; g < gestures.count(); ++g) {
Gesture gesture = gestures[g];
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE: {
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE: {
SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
//.........这里部分代码省略.........
示例2: m_bang
void m_bang()
{
Frame frame;
t_atom generalInfo[6];
int num_hands, num_tools, num_gestures;
frame = dispatcher.frame;
num_hands = frame.hands().count();
num_tools = frame.tools().count();
num_gestures = frame.gestures().count();
if(general_flag){
SETFLOAT(&generalInfo[0], (float)frame.id());
SETFLOAT(&generalInfo[1], (float)frame.timestamp());
SETFLOAT(&generalInfo[2], (float)num_hands);
SETFLOAT(&generalInfo[3], (float)frame.fingers().count());
SETFLOAT(&generalInfo[4], (float)frame.tools().count());
SETFLOAT(&generalInfo[5], (float)frame.gestures().count());
ToOutList(0, 6, generalInfo);
}
// tools
for(int i = 0; i<num_tools; i++){
Tool tool;
tool = frame.tools()[i];
t_atom toolInfo[5];
if(tools_position_flag) {
SETFLOAT(&toolInfo[0], i);
SETSYMBOL(&toolInfo[1], gensym("direction"));
SETFLOAT(&toolInfo[2], tool.direction().x);
SETFLOAT(&toolInfo[3], tool.direction().y);
SETFLOAT(&toolInfo[4], tool.direction().z);
ToOutAnything(1, gensym("tool"), 5, toolInfo);
}
if(tools_position_flag) {
SETFLOAT(&toolInfo[0], i);
SETSYMBOL(&toolInfo[1], gensym("position"));
SETFLOAT(&toolInfo[2], tool.tipPosition().x);
SETFLOAT(&toolInfo[3], tool.tipPosition().y);
SETFLOAT(&toolInfo[4], tool.tipPosition().z);
ToOutAnything(1, gensym("tool"), 5, toolInfo);
}
if(tools_velocity_flag){
SETFLOAT(&toolInfo[0], i);
SETSYMBOL(&toolInfo[1], gensym("velocity"));
SETFLOAT(&toolInfo[2], tool.tipVelocity().x);
SETFLOAT(&toolInfo[3], tool.tipVelocity().y);
SETFLOAT(&toolInfo[4], tool.tipVelocity().z);
ToOutAnything(1, gensym("tool"), 5, toolInfo);
}
if(tools_size_flag){
SETFLOAT(&toolInfo[0], i);
SETSYMBOL(&toolInfo[1], gensym("size"));
SETFLOAT(&toolInfo[2], tool.width());
SETFLOAT(&toolInfo[3], tool.length());
ToOutAnything(1, gensym("tool"), 4, toolInfo);
}
}
// hands and fingers
for(int i = 0; i<num_hands; i++){
Hand hand;
hand = frame.hands()[i];
int num_fingers = hand.fingers().count();
int num_tools = hand.tools().count();
t_atom handInfo[5];
if(hands_direction_flag){
// direction
SETFLOAT(&handInfo[0], i);
SETSYMBOL(&handInfo[1], gensym("direction"));
SETFLOAT(&handInfo[2], hand.direction().x);
SETFLOAT(&handInfo[3], hand.direction().y);
SETFLOAT(&handInfo[4], hand.direction().z);
ToOutAnything(1, gensym("hand"), 5, handInfo);
}
if(hands_palm_position_flag){
// position
SETFLOAT(&handInfo[0], i);
SETSYMBOL(&handInfo[1], gensym("palm_position"));
SETFLOAT(&handInfo[2], hand.palmPosition().x);
SETFLOAT(&handInfo[3], hand.palmPosition().y);
SETFLOAT(&handInfo[4], hand.palmPosition().z);
ToOutAnything(1, gensym("hand"), 5, handInfo);
}
if(hands_palm_velocity_flag){
// velocity
SETFLOAT(&handInfo[0], i);
SETSYMBOL(&handInfo[1], gensym("palm_velocity"));
SETFLOAT(&handInfo[2], hand.palmVelocity().x);
SETFLOAT(&handInfo[3], hand.palmVelocity().y);
SETFLOAT(&handInfo[4], hand.palmVelocity().z);
ToOutAnything(1, gensym("hand"), 5, handInfo);
}
if(hands_palm_normal_flag){
// normal
SETFLOAT(&handInfo[0], i);
SETSYMBOL(&handInfo[1], gensym("palm_normal"));
SETFLOAT(&handInfo[2], hand.palmNormal().x);
SETFLOAT(&handInfo[3], hand.palmNormal().y);
SETFLOAT(&handInfo[4], hand.palmNormal().z);
//.........这里部分代码省略.........