X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Futil%2FArrayUtils.java;h=8e504a55e7ea37abe45c114eef7002367b51b28b;hb=cbfd370eecee19979823b7a1953ae1ee55633369;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..8e504a55 100644 --- a/core/src/net/sf/openrocket/util/ArrayUtils.java +++ b/core/src/net/sf/openrocket/util/ArrayUtils.java @@ -4,6 +4,141 @@ 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 step before stop is reached. + */ + public static double[] range(double start, double stop, double step){ + + int size = 0 ; + if ( stop <= start ) { + size = 0; + } else { + size = (int) Math.ceil(((stop - start) / step)); + } + + //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