Fix commit from revision 953 which reverted a bunch of changes related to Froyo compa...
[debian/openrocket] / core / src / net / sf / openrocket / util / LinearInterpolator.java
index 6a9a308b6f11e3b8cde69e4a223080d8b11ea548..e16726bb52e136ca273c59fa6d7dab788e762d67 100644 (file)
@@ -1,6 +1,7 @@
 package net.sf.openrocket.util;
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -28,6 +29,9 @@ public class LinearInterpolator implements Cloneable {
                addPoints(x,y);
        }
 
+       public LinearInterpolator(List<Double> x, List<Double> y) {
+               addPoints(x,y);
+       }
 
        /**
         * Add the point to the linear interpolation.
@@ -57,6 +61,15 @@ public class LinearInterpolator implements Cloneable {
                }
        }
 
+       public void addPoints(List<Double> x, List<Double> y){
+               if (x.size() != y.size()) {
+                       throw new IllegalArgumentException("Array lengths do not match, x="+x.size() +
+                                       " y="+y.size());
+               }
+               for (int i=0; i < x.size(); i++) {
+                       sortMap.put( (Double) x.toArray()[i], (Double) y.toArray()[i]);
+               }
+       }
 
 
        public double getValue(double x) {