Understanding LEAPMOTION Programs in c++

Asked 1 years ago, Updated 1 years ago, 69 views

Recently, I tried to create a LEAPMOTION program in c++, but I don't know how to extract each element, such as the y coordinate of the index finger Middlebone. I can read from the sample how to display all x, y, z at the same time, but I don't know how to focus on one thing.

for(intb=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;}

This is part of the sample program, and the starting point, ending point, angle, etc. of each bone on each finger are returned in the form of (x, y, z).I don't know how to get only this y value.

c++ leap-motion

2022-09-30 20:47

1 Answers

Can't I use this?
The return type Leap::Bone::prevJoint() is Leap::Vector, and each element seemed to be of type float.

for(intb=0;b<4;++b){
    Bone::Type boneType=static_cast<Bone::Type>(b);
    Bone bone = finger.bone(boneType);
    float startPointY=bone.prevJoint().y
    float endPointY=bone.nextJoint().y
    float directionY=bone.direction().y

    // Display Processing, etc.
    std::cout<<"start.y"<<startPointY<<std::endl;
    std::cout<<"end.y"<<endPointY<<std::endl;
    std::cout<<"direction.y"<<directionY<<std::endl;
}

Reference URL:
Leap::Bone class
Leap::Vector Class


2022-09-30 20:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.