Example usage for com.badlogic.gdx.math Interpolation apply

List of usage examples for com.badlogic.gdx.math Interpolation apply

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Interpolation apply.

Prototype

abstract public float apply(float a);

Source Link

Usage

From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Autopilot.java

License:Apache License

/** calculates the force to continuously {@link Body#applyForce(Vector2, Vector2, boolean) apply} to reach the given {@code destination} and interpolates it based on distance
 *  @param destination the destination to go to
 *  @param force the force to apply//from w ww  .j av  a  2 s  . c o  m
 *  @param distanceScalar the distance at which the given force should be fully applied
 *  @param interpolation the interpolation used to interpolate the given {@code force} based on the {@code distanceScalar}
 *  @return the force to {@link Body#applyForce(Vector2, Vector2, boolean) apply} to navigate to the given {@code destination}
 *  @see #calculateForce(Vector2, Vector2) */
public static Vector2 calculateForce(Vector2 destination, Vector2 force, float distanceScalar,
        Interpolation interpolation) {
    return calculateForce(destination, force).scl(interpolation.apply(destination.len() / distanceScalar));
}

From source file:de.brainstormsoftworks.taloonerrl.math.IntVector2.java

License:Open Source License

@Override
public IntVector2 interpolate(final IntVector2 target, final float alpha, final Interpolation interpolator) {
    return lerp(target, interpolator.apply(alpha));
}