* @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);
}