Skip to content

Implement max steering constraint #234

@netgusto

Description

@netgusto

As explained here: ByteArena/ba#15 (comment)

Pseudocode of current implementation (incorrect):

In pseudocode:

var curvelocity Vec2 = GetCurrentVelocity()
var newvelocity Vec2 = GetDesiredVelocity()

var maxSteeringForce Vec2 = GetMaxSteeringForce()

var curmag float64 = curvelocity.Mag()
var diff float64 = newvelocity.Mag() - curmag

if math.Abs(diff) > maxSteeringForce {
    if diff > 0 {
        newvelocity = newvelocity.SetMag(curmag + maxSteeringForce)
    } else {
        newvelocity = newvelocity.SetMag(curmag - maxSteeringForce)
    }
}

The current implementation is incorrect as it does not take into account the changes of direction between the two velocities.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions