X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Futil%2FArrayUtils.java;h=7d373096a3cae4930e878b4f47de9521f0137628;hb=ed703c494f30cb24f14aad96d9c8ad9f8f8fd332;hp=4202c53ce8623389b872f8184e69a866b171b793;hpb=953ac8ca75bc3bdcb9db8a382c7b3d63c795b27a;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/util/ArrayUtils.java b/core/src/net/sf/openrocket/util/ArrayUtils.java index 4202c53c..7d373096 100644 --- a/core/src/net/sf/openrocket/util/ArrayUtils.java +++ b/core/src/net/sf/openrocket/util/ArrayUtils.java @@ -4,6 +4,136 @@ import java.lang.reflect.Array; public class ArrayUtils { + /** + * Returns a double array with values from start to end with given step. + * Starts exactly at start and stops at the multiple of step <= stop. + */ + public static double[] range(double start, double stop, double step){ + + int size = (int) Math.floor(((stop - start) / step)) + 1; + + //System.out.println("Range from "+start+" to "+stop+" step "+step+" has length "+size); + + double[] output = new double[size]; + int i = 0; + double x = start; + while (i