NanoSim

Jump to navigation Jump to search
Revision as of 14 September 2012 at 21:38.
This is the thread's initial revision.

Hi. Not sure if this is still in progress, but i touched it a little and came up with this (128 byte and max user velocity) :

class NanoSim
{
    public static double	x, y, h, v;
    public static void simulate(double att, double d, double maxv) {
      if (d == 0) d = -Math.signum(v);
      if (v * d < 0) d *= 2;
      if (((d = v + d) * v) < 0) d /= 2.0;
      x += Math.sin(h = Utils.normalNearAbsoluteAngle(h + limit(Rules.getTurnRateRadians(v), att))) * (v = limit(maxv, d));
      y += Math.cos(h) * v;
    }

    private static double limit(double minmax, double value) {
      return Math.max(-minmax, Math.min(value, minmax));
    }
}

At least it makes the same as the old NanoSim. Not sure if it is sound i have to check it later a little more seriously. But eventually it helps a little and shows the direction.

    Wompi22:38, 14 September 2012