Path Following Algorithm for Entity Within my game there are many entities, where each entity has a path (Array&lt;Vector2&gt;) assigned to it. No path to follow (indicating that the entity should move at all) is indicated by an empty path (the path is never null). updateMoveAttributes is called every frame for every entity, so it is important that it is efficient.

Note that my entity's direction is in radians, ranging from - Math.PI to Math.PI, since this is what Math.atan2 returns. 

The below snippet contains updateMoveAttributes and its supporting methods. 

private final Array&lt;Vector2&gt; path = new Array&lt;&gt;();
private int pathIndex = 0;

private static final float EPSILON = 1e-3f;

private float getXDifference(Vector2 pathComponent) {
    float xDifference = pathComponent.x - getSprite().getX();

    xDifference = Math.abs(xDifference) &lt; EPSILON ? 0 : xDifference;

    return xDifference;
}

private float getYDifference(Vector2 pathComponent) {
    float yDifference = pathComponent.y - getSprite().getY();

    yDifference = Math.abs(yDifference) &lt; EPSILON ? 0 : yDifference;

    return yDifference;
}

public float orient(Vector2 pathComponent) {
    float xDiff = getXDifference(pathComponent);
    float yDiff = getYDifference(pathComponent);

    return (float) Math.atan2(yDiff, xDiff);
}

void updateMoveAttributes() {
    // No path assigned
    if (getPath().size == 0)
        return;

    // No more path to travel
    if (getPathIndex() == getPath().size) {
        setSpeed(0);

        return;
    }

    Vector2 nextPathComponent = getPath().get(getPathIndex());
    float angleToComponent = orient(nextPathComponent);

    setDirection(angleToComponent);

    float xDiff = getXDifference(nextPathComponent);
    float yDiff = getYDifference(nextPathComponent);

    boolean angleInPositiveXQuadrants = (-Math.PI / 2 &lt;= angleToComponent &amp;&amp; angleToComponent &lt;= Math.PI / 2);
    boolean pastX = angleInPositiveXQuadrants ? (xDiff &lt;= 0) : (xDiff &gt;= 0);

    boolean angleInPositiveYQuadrants = (0 &lt;= angleToComponent) &amp;&amp; (angleToComponent &lt;= Math.PI);
    boolean pastY = angleInPositiveYQuadrants ? (yDiff &lt;= 0) : (yDiff &gt;= 0);

    // Indicates that we have passed the path component we are on route to, adjust course with respect
    // to next available path component.
    if (pastY &amp;&amp; pastX)
        setPathIndex(getPathIndex() + 1);

    // In case user upgrades entity during travel of entity -&gt; movement speed changes -&gt; update required for actual speed
    setSpeed(getMovementSpeed());
}

public Array&lt;Vector2&gt; getPath() {
    return path;
}
Method getXDifference and getYDifference are very similar, you can convert this into a single method that accepts two variables. 
you could also inline the return statement as the method name is sufficient to tell what it is returning.
Instead of calculating pastX and pastY, you can write methods to return the computed value.

boolean isPastX(variables...){
    // logic to calculate pastX and return it.
}


and the if statement will turn into if( isPastX() &amp;&amp; isPastY()).
This will also help in short-circuiting the condition in case calculating pastX or pastY is very expensive(it isn't in this example, just a suggestion).
Curly braces {} should always be used after conditional statements or loops, even it's just a single line. It may avoid confusion in some scenarios.

if (getPath().size == 0){
    return;
}