Public Member Functions | Protected Attributes
LeapUtil::ScrollMomentum Class Reference

Utility class for adding simple momentum to 2D or 3D UI elements. More...

#include <LeapUtil.h>

List of all members.

Public Member Functions

const Leap::VectorgetDirection () const
float getDrag () const
float getDragPower () const
float getFixedTimeStep () const
float getMinSpeed () const
const Leap::VectorgetPosition () const
float getScrollSize () const
float getSpeed () const
const Leap::Vector getVelocity () const
 ScrollMomentum ()
void setDirection (const Leap::Vector &vDirection)
void setDrag (float fDrag)
void setDragPower (float fDragPower)
void setFixedTimeStep (float fFixedTimeStep)
void setMinSpeed (float fMinSpeed)
void setPosition (const Leap::Vector &vPosition)
void setScrollSize (float fScrollSize)
void setSpeed (float fSpeed)
void setVelocity (const Leap::Vector &vDirection, float fSpeed)
void update (float fDeltaTimeSeconds)

Protected Attributes

float m_fDrag
float m_fDragPower
float m_fFixedTimeStep
float m_fMinSpeed
float m_fPendingDeltaTime
float m_fScrollSize
float m_fSpeed
Leap::Vector m_vDirection
Leap::Vector m_vPosition

Detailed Description

Utility class for adding simple momentum to 2D or 3D UI elements.

Definition at line 428 of file LeapUtil.h.


Constructor & Destructor Documentation

Definition at line 430 of file LeapUtil.h.


Member Function Documentation

The direction of movement. Direction should never be set to the zero vector. The default value is Y+ vector (0, 1, 0)

Definition at line 451 of file LeapUtil.h.

float LeapUtil::ScrollMomentum::getDrag ( ) const [inline]

The coefficient of drag to use for slowing movement over time. Drag is always a positive value. The default value is 0.4

Definition at line 491 of file LeapUtil.h.

float LeapUtil::ScrollMomentum::getDragPower ( ) const [inline]

Drag power controls how drag is calculated from speed. Drag force is (speed/scrollSize)^dragPower A drag power of 1 would be linear falloff. The default value is 2.0 (square falloff)

Definition at line 498 of file LeapUtil.h.

A fixed time step is used to ensure consistent behavior. The deltaTime passed to update is processed in increments of the fixed time step. Any unhandled time is cached for processing on the next call to update. The default value is 1/60th of a second.

Definition at line 485 of file LeapUtil.h.

float LeapUtil::ScrollMomentum::getMinSpeed ( ) const [inline]

When absolute value of speed falls to or below MinSpeed speed is set to 0. This is to prevent asymptotically approaching the limit of floating point resolution and getting jitter or undesirable effects. The default value is 0.125

Definition at line 478 of file LeapUtil.h.

The current scroll position. Calling SetPosition assigns an initial position value. Calls to update will change position based on velocity (speed * direction) The default value is the zero vector (0, 0, 0)

Definition at line 445 of file LeapUtil.h.

float LeapUtil::ScrollMomentum::getScrollSize ( ) const [inline]

ScrollSize is used to tune the rate at which drag starts to taper its effect on speed. Because drag is proportional to speed^dragPower it slows objects moving at speeds greater than 1 quickly and tapers for speeds below 1. The drag calculations are done using speed/ScrollSize as the value to square. ScrollSize is always > 0. The default value is 512

Definition at line 462 of file LeapUtil.h.

float LeapUtil::ScrollMomentum::getSpeed ( ) const [inline]

Current speed of movement. Speed is not defined in strict terms of any particular unit. A value in pixels/second or mm/sec will work well for speed. Calling SetSpeed assigns an initial speed value. Calls to update will change speed as drag slows down movement. Speed can be positive or negative.

Definition at line 471 of file LeapUtil.h.

Current velocity (scaled direction vector) - changes over time as drag slows movement. Convenience method - just multiplies direction by current speed.

Definition at line 503 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setDirection ( const Leap::Vector vDirection) [inline]

Definition at line 452 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setDrag ( float  fDrag) [inline]

Definition at line 492 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setDragPower ( float  fDragPower) [inline]

Definition at line 499 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setFixedTimeStep ( float  fFixedTimeStep) [inline]

Definition at line 486 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setMinSpeed ( float  fMinSpeed) [inline]

Definition at line 479 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setPosition ( const Leap::Vector vPosition) [inline]

Definition at line 446 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setScrollSize ( float  fScrollSize) [inline]

Definition at line 463 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setSpeed ( float  fSpeed) [inline]

Definition at line 472 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::setVelocity ( const Leap::Vector vDirection,
float  fSpeed 
) [inline]

Convenience method for setting a direction and initial speed in one call. see SetDirection() and SetSpeed()

Definition at line 507 of file LeapUtil.h.

void LeapUtil::ScrollMomentum::update ( float  fDeltaTimeSeconds) [inline]

Update handles time stepping. Update modifies velocity by drag and position by velocity. Time is processed fixed size chunks. If _deltaTimeSeconds is larger than that chunk, update will iterate through the time in increments of the fixed time step. If it is smaller, the delta time is accumulated over successive calls to update until one time step has passed and then it is processed.

Definition at line 519 of file LeapUtil.h.


Member Data Documentation

Definition at line 588 of file LeapUtil.h.

Definition at line 589 of file LeapUtil.h.

Definition at line 590 of file LeapUtil.h.

Definition at line 587 of file LeapUtil.h.

Definition at line 591 of file LeapUtil.h.

Definition at line 585 of file LeapUtil.h.

Definition at line 586 of file LeapUtil.h.

Definition at line 584 of file LeapUtil.h.

Definition at line 583 of file LeapUtil.h.


The documentation for this class was generated from the following file:


leap_motion
Author(s): Florian Lier , Mirza Shah , Isaac IY Saito
autogenerated on Sat Jun 8 2019 18:47:26