function adjustRawSteeringForce (out, boid, force) {

    const maxAdjustedSpeed = 0.2 * boid.rigidBody.maxSpeed

    const speed = vec2.length(boid.rigidBody.velocity)

    if ((speed > maxAdjustedSpeed) || (vec2.length(force) == 0)) {
        return vec2.copy(out, force)

    } else {
        const range = speed / maxAdjustedSpeed
        // const float cosine = interpolate (pow (range, 6), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 10), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 100), 1.0f, -1.0f);
        // const float cosine = interpolate (pow (range, 50), 1.0f, -1.0f);
        const t = Math.pow(range, 20)

        const cosine = lerp(1.0, -1.0, t)
        const forward = (vec2.length(boid.rigidBody.velocity) === 0) ? [ 1, 0 ] : vec2.normalize([ 0, 0 ], boid.rigidBody.velocity)
        const insideCone = true

        return limitDeviationAngle(out, insideCone, force, cosine, forward)
    }
}
// default is to disallow backward-facing steering at low speed.
default is to disallow backward-facing steering at low speed.
default is to disallow backward - facing steering at low speed .
function adjustRawSteeringForce (out, boid, force) {
    const maxAdjustedSpeed = 0.2 * boid.rigidBody.maxSpeed
    const speed = vec2.length(boid.rigidBody.velocity)
    if ((speed > maxAdjustedSpeed) || (vec2.length(force) == 0)) {
        return vec2.copy(out, force)
    } else {
        const range = speed / maxAdjustedSpeed
        const t = Math.pow(range, 20)
        const cosine = lerp(1.0, -1.0, t)
        const forward = (vec2.length(boid.rigidBody.velocity) === 0) ? [ 1, 0 ] : vec2.normalize([ 0, 0 ], boid.rigidBody.velocity)
        const insideCone = true
        return limitDeviationAngle(out, insideCone, force, cosine, forward)
    }
}
function adjustRawSteeringForce ( out , boid , force ) { const maxAdjustedSpeed = 0.2 * boid . rigidBody . maxSpeed const speed = vec2 . length ( boid . rigidBody . velocity ) if ( ( speed > maxAdjustedSpeed ) || ( vec2 . length ( force ) == 0 ) ) { return vec2 . copy ( out , force ) } else { const range = speed / maxAdjustedSpeed const t = Math . pow ( range , 20 ) const cosine = lerp ( 1.0 , - 1.0 , t ) const forward = ( vec2 . length ( boid . rigidBody . velocity ) === 0 ) ? [ 1 , 0 ] : vec2 . normalize ( [ 0 , 0 ] , boid . rigidBody . velocity ) const insideCone = true return limitDeviationAngle ( out , insideCone , force , cosine , forward ) } }
default is to disallow backward-facing steering at low speed.
default is to disallow backward - facing steering at low speed .
// const float cosine = interpolate (pow (range, 6), 1.0f, -1.0f); // const float cosine = interpolate (pow (range, 10), 1.0f, -1.0f); // const float cosine = interpolate (pow (range, 20), 1.0f, -1.0f); // const float cosine = interpolate (pow (range, 100), 1.0f, -1.0f); // const float cosine = interpolate (pow (range, 50), 1.0f, -1.0f);