Package pulse.math
Class Segment
- java.lang.Object
-
- pulse.math.Segment
-
- All Implemented Interfaces:
Serializable
public class Segment extends Object implements Serializable
ASegmentis simply a pair of valuesaandbsuch thata < b.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SegmentboundsFrom(NumericPropertyKeyword p)Creates a segment representing the bounds ofp, i.e.booleancontains(double x)Checks whetherxis contained inside thisSegment.doublegetMaximum()Gets thebvalue for thisSegmentdoublegetMinimum()Gets theavalue for thisSegmentdoublelength()Calculates the length(b - a)doublelengthSq()Calculates the squared lengthdoublemean()Calculates the middle point of thisSegment.doublerandomValue()Calculates a random value confined in the interval between the two ends of thisSegment.voidsetMaximum(double b)Sets the maximum value tob.voidsetMinimum(double a)Sets the minimum value toa.StringtoString()
-
-
-
Field Detail
-
UNBOUNDED
public static final Segment UNBOUNDED
-
-
Constructor Detail
-
Segment
public Segment(double a, double b)Creates aSegmentbounded byaandb.- Parameters:
a- any valueb- eitherb > aorb < a
-
Segment
public Segment(Segment segment)
Copiessegment- Parameters:
segment- aSegment
-
-
Method Detail
-
boundsFrom
public static Segment boundsFrom(NumericPropertyKeyword p)
Creates a segment representing the bounds ofp, i.e. the range in which the property value is allowed to change- Parameters:
p- a property keyword to extract default bounds- Returns:
- a
Segmentwith the bounds
-
getMinimum
public double getMinimum()
Gets theavalue for thisSegment- Returns:
- the lower end of this
Segment
-
getMaximum
public double getMaximum()
Gets thebvalue for thisSegment- Returns:
- the upper end of this
Segment
-
length
public double length()
Calculates the length(b - a)- Returns:
- the length value
-
lengthSq
public double lengthSq()
Calculates the squared length- Returns:
- the squared length value
- See Also:
length()
-
setMinimum
public void setMinimum(double a)
Sets the minimum value toa. Note it does not prevent against:a >= max.- Parameters:
a- a value, which should satisfya < max
-
setMaximum
public void setMaximum(double b)
Sets the maximum value tob. Note it does not prevent against:b <= min.- Parameters:
b- a value, which should satisfyb > min
-
mean
public double mean()
Calculates the middle point of thisSegment.- Returns:
- the mean
-
randomValue
public double randomValue()
Calculates a random value confined in the interval between the two ends of thisSegment.- Returns:
- a confined random value.
-
contains
public boolean contains(double x)
Checks whetherxis contained inside thisSegment.- Parameters:
x- a value.- Returns:
trueif .
-
-