Sender: |
|
Subject: |
|
From: |
|
Date: |
Tue, 3 Jan 2012 18:01:05 +0000 |
MIME-Version: |
1.0 |
Content-Type: |
multipart/mixed;
boundary="_004_96806F9DFDBB3044B3B202A445A9C023244E23DBHQMBX01wardrobe_" |
Reply-To: |
|
Parts/Attachments: |
|
|
Is there any reason the sim.util.Interval class doesn't have a method to test whether or not a value falls within the interval?
I went ahead and added this method to my local copy:
public boolean contains(Number val)
{
if (val.doubleValue() >= min.doubleValue() && val.doubleValue() <= max.doubleValue())
return true;
return false;
}
It makes using dom sliders and bounds testing a little nicer. For example:
public static double lambda = 1.0;
public double getLambda() { return lambda; }
public void setLambda(double val) { if (((Interval)domLambda()).contains(val)) lambda = val; }
public Object domLambda() { return new Interval(0.0, 1.0); }
Full Interval.java file also attached.
Thanks,
-Ben
Ben Axelrod
Research Scientist
iRobot Corporation
8 Crosby Drive, Mail Stop 8-1
Bedford, MA 01730
(781) 430-3315 (Tel)
(781) 960-2628 (Fax)
[log in to unmask]
|
|
|