VelocityEstimator

Description

Used to estimate release velocities of grabbable objects, without it, the objects would behave as if no external forces are impacting them (excluding the non-precision joint grabbable) on throw

Public methods

void StartVelocityEstimation()

  • ends any previous velocity estimation

  • starts a coroutine which calculates linear and angular velocities

void FinishVelocityEstimation()

  • stops the coroutine - called in the previously mentioned method

Vector3 GetLinearVelocityAverage()

  • gets the linear velocity average or the average rate at which the object should be moved according to the velocity calculation coroutine started upon grabbing it

Linear velocity calculation

Calculated by simply multiplying the given velocity factor with the current position of the object subtracted by It's previous position

Vector3 GetAngularVelocityAverage()

  • gets the angular velocity average or the average rate at which the object should be rotated according to the velocity calculation coroutine started upon grabbing it

Angular velocity calculation

A bit more complex than linear velocity but it basically boils down to these steps:

  • First, the delta rotation is calculated, which takes into account the multiplication of the current rotation of the object and the inverse of its previous rotation

  • Next, the theta is calculated by multiplying the cosine arc of a clamped delta rotation of w(rotation around the vector) value by two

  • The angular velocity is then stored as a vector3 of delta rotation on each axis and in the case of its square magnitude being above zero, multiplied by the set velocity factor and a normalized value of the angular velocity

  • Finally, the angular velocity is stored in an array of angular velocity samples later used by GetAngularVelocityAverage to calculate the rotation average

Last updated