KWin
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KWin::SpringMotion Class Reference

#include <springmotion.h>

Public Member Functions

 SpringMotion ()
 
 SpringMotion (qreal springConstant, qreal dampingRatio)
 
void advance (std::chrono::milliseconds delta)
 
bool isMoving () const
 
qreal velocity () const
 
void setVelocity (qreal velocity)
 
qreal position () const
 
void setPosition (qreal position)
 
qreal anchor () const
 
void setAnchor (qreal anchor)
 
qreal springConstant () const
 
qreal dampingRatio () const
 
qreal epsilon () const
 
void setEpsilon (qreal epsilon)
 

Detailed Description

The SpringMotion class simulates the motion of a spring along one dimension using the mass-spring-damper model. The sping constant parameter controls the acceleration of the spring. The damping ratio controls the oscillation of the spring.

Definition at line 21 of file springmotion.h.

Constructor & Destructor Documentation

◆ SpringMotion() [1/2]

KWin::SpringMotion::SpringMotion ( )

Definition at line 19 of file springmotion.cpp.

◆ SpringMotion() [2/2]

KWin::SpringMotion::SpringMotion ( qreal springConstant,
qreal dampingRatio )

Definition at line 24 of file springmotion.cpp.

Member Function Documentation

◆ advance()

void KWin::SpringMotion::advance ( std::chrono::milliseconds delta)

Advance the simulation by the given delta milliseconds.

Definition at line 139 of file springmotion.cpp.

◆ anchor()

qreal KWin::SpringMotion::anchor ( ) const

Returns the anchor position. It's the position that the spring is pulled towards.

Definition at line 90 of file springmotion.cpp.

◆ dampingRatio()

qreal KWin::SpringMotion::dampingRatio ( ) const

Returns the damping ratio. It controls the oscillation of the spring. Potential values:

  • 0 or undamped: the spring will oscillate indefinitely
  • less than 1 or underdamped: the mass tends to overshoot its starting position, but with every oscillation some energy is dissipated and the oscillation dies away
  • 1 or critically damped: the mass will fail to overshoot and make a single oscillation
  • greater than 1 or overdamped: the mass slowly returns to the anchor position without overshooting

Definition at line 47 of file springmotion.cpp.

◆ epsilon()

qreal KWin::SpringMotion::epsilon ( ) const

If the distance of the mass between two consecutive simulations is smaller than the epsilon value, consider that the mass has stopped moving.

Definition at line 80 of file springmotion.cpp.

◆ isMoving()

bool KWin::SpringMotion::isMoving ( ) const

Definition at line 37 of file springmotion.cpp.

◆ position()

qreal KWin::SpringMotion::position ( ) const

Returns the current position.

Definition at line 66 of file springmotion.cpp.

◆ setAnchor()

void KWin::SpringMotion::setAnchor ( qreal anchor)

Definition at line 95 of file springmotion.cpp.

◆ setEpsilon()

void KWin::SpringMotion::setEpsilon ( qreal epsilon)

Definition at line 85 of file springmotion.cpp.

◆ setPosition()

void KWin::SpringMotion::setPosition ( qreal position)

Definition at line 71 of file springmotion.cpp.

◆ setVelocity()

void KWin::SpringMotion::setVelocity ( qreal velocity)

Definition at line 57 of file springmotion.cpp.

◆ springConstant()

qreal KWin::SpringMotion::springConstant ( ) const

Returns the spring constant. It controls the acceleration of the spring.

Definition at line 42 of file springmotion.cpp.

◆ velocity()

qreal KWin::SpringMotion::velocity ( ) const

Returns the current velocity.

Definition at line 52 of file springmotion.cpp.


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