Package com.leapmotion.leap

Examples of com.leapmotion.leap.Vector


  public PVector getTipOnScreen(Pointable pointable) {
    PVector pos;

    ScreenList sl = this.controller.locatedScreens();
    com.leapmotion.leap.Screen calibratedScreen = sl.get(activeScreenNr);
    Vector loc = calibratedScreen.intersect(pointable, true);

    float _x = PApplet.map(loc.getX(), 0, 1, 0, this.p.displayWidth);
    _x -= p.getLocationOnScreen().x;
    float _y = PApplet.map(loc.getY(), 0, 1, this.p.displayHeight, 0);
    _y -= p.getLocationOnScreen().y;

    pos = new PVector(_x, _y);
    return pos;
  }
View Full Code Here


   * @param pointable
   * @return
   */

  public PVector getVelocityOnScreen(Pointable pointable) {
    Vector loc = new Vector();
    Vector oldLoc = new Vector();
    try {
      oldLoc =
          getLastController().locatedScreens().get(this.activeScreenNr)
              .intersect(getPointableById(pointable.id(), getLastFrame()), true);
      loc = this.controller.locatedScreens().get(this.activeScreenNr).intersect(pointable, true);
    } catch (NullPointerException e) {
      // dirty dirty hack to keep the programm runing. i like it.
    }

    float _x = PApplet.map(loc.getX(), 0, 1, 0, this.p.displayWidth);
    _x -= this.p.getLocationOnScreen().x;
    float _y = PApplet.map(loc.getY(), 0, 1, this.p.displayHeight, 0);
    _y -= this.p.getLocationOnScreen().y;

    float _x2 = PApplet.map(oldLoc.getX(), 0, 1, 0, this.p.displayWidth);
    _x2 -= this.p.getLocationOnScreen().x;
    float _y2 = PApplet.map(oldLoc.getY(), 0, 1, this.p.displayHeight, 0);
    _y2 -= this.p.getLocationOnScreen().y;

    return new PVector(_x - _x2, _y - _y2);
  }
View Full Code Here

   *
   * @param pointable the pointable you want the origin of
   * @return a PVector containing the position of the origin of the passed pointable
   */
  public PVector getOrigin(Pointable pointable) {
    Vector anklePos;

    float length = pointable.length();
    PVector direction = new PVector();
    direction.x = pointable.direction().getX();
    direction.y = pointable.direction().getY();
    direction.z = pointable.direction().getZ();
    direction.mult(length);
    anklePos =
        new Vector(pointable.tipPosition().getX() - direction.x, pointable.tipPosition().getY()
            - direction.y, pointable.tipPosition().getZ() - direction.z);

    return vectorToPVector(anklePos);
  }
View Full Code Here

TOP

Related Classes of com.leapmotion.leap.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.