- java.lang.Object
-
- spice.basic.SpiceWindow
-
public class SpiceWindow extends java.lang.Object
Class SpiceWindow represents unions of disjoint intervals on the real line. SpiceWindows are frequently used to represent time periods, for example periods when a specified geometric condition occurs.SpiceWindows are used in JNISpice where the abstract data type Window is used in SPICELIB, or where the SpiceCell structure is used to represent windows in CSPICE.
Each SpiceWindow instance contains a one-dimensional array of interval endpoints; the endpoints are arranged in increasing order. Unlike windows in SPICELIB and CSPICE, SpiceWindow objects don't have separate cardinality and size values: all of the elements of the array of endpoints are considered to be valid data.
Version 1.0.1 20-DEC-2016 (NJB)
Updated class description and constructor documentation.Version 1.0.0 02-JAN-2010 (NJB)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double[]
endpoints
-
Constructor Summary
Constructors Constructor Description SpiceWindow()
Default constructor.SpiceWindow(double[] endpoints)
Construct a SpiceWindow from a one-dimensional array of double precision endpoints.SpiceWindow(double[][] intervals)
Construct a SpiceWindow from an array of double precision endpoint intervals.SpiceWindow(SpiceWindow s)
Copy constructor.This creates a deep copy.
-
Method Summary
Modifier and Type Method Description int
card()
Get the cardinality (number of intervals) of a SpiceWindow.SpiceWindow
complement(double left, double right)
Complement a SpiceWindow with respect to a specified interval.void
contract(double left, double right)
Contract a SpiceWindow using specified inset values.void
expand(double left, double right)
Expand a SpiceWindow using specified inset values.void
fill(double small)
Fill in gaps shorter than a specified in from a SpiceWindow.void
filter(double small)
Filter intervals shorter than a specified length from a SpiceWindow.double[]
getInterval(int index)
Fetch an interval, specified by index, from a SpiceWindow.double
getMeasure()
Get the measure of this SpiceWindow.SpiceWindow
insert(double left, double right)
Insert an interval into a SpiceWindow.SpiceWindow
intersect(SpiceWindow b)
Compute the intersection of two SpiceWindows.SpiceWindow
sub(SpiceWindow b)
Compute the difference of two SpiceWindows: subtract a specified SpiceWindow from another.double[]
toArray()
Get an array of endpoints from a SpiceWindow.java.lang.String
toString()
Override Object's toString method.SpiceWindow
union(SpiceWindow b)
Compute the union of two SpiceWindows.
-
-
-
Constructor Detail
-
SpiceWindow
public SpiceWindow()
Default constructor.
-
SpiceWindow
public SpiceWindow(SpiceWindow s)
Copy constructor.This creates a deep copy.- Parameters:
s
- SpiceWindow
-
SpiceWindow
public SpiceWindow(double[] endpoints) throws SpiceErrorException
Construct a SpiceWindow from a one-dimensional array of double precision endpoints.All of the elements of the array are considered to be valid data. The cardinality of the SpiceWindow is one half of the array length.
- Parameters:
endpoints
- double[]- Throws:
SpiceErrorException
- exception
-
SpiceWindow
public SpiceWindow(double[][] intervals) throws SpiceErrorException
Construct a SpiceWindow from an array of double precision endpoint intervals.All of the elements of the array are considered to be valid data. The cardinality of the SpiceWindow is the length of the array `intervals'.
- Parameters:
intervals
- double[][]- Throws:
SpiceErrorException
- exception
-
-
Method Detail
-
card
public int card()
Get the cardinality (number of intervals) of a SpiceWindow.- Returns:
- int
-
toArray
public double[] toArray()
Get an array of endpoints from a SpiceWindow.- Returns:
- double[]
-
getInterval
public double[] getInterval(int index) throws SpiceErrorException
Fetch an interval, specified by index, from a SpiceWindow.- Parameters:
index
- int- Returns:
- double[]
- Throws:
SpiceErrorException
- exception
-
union
public SpiceWindow union(SpiceWindow b) throws SpiceErrorException
Compute the union of two SpiceWindows.- Parameters:
b
- SpiceWindow- Returns:
- SpiceWindow
- Throws:
SpiceErrorException
- exception
-
intersect
public SpiceWindow intersect(SpiceWindow b) throws SpiceErrorException
Compute the intersection of two SpiceWindows.- Parameters:
b
- SpiceWindow- Returns:
- SpiceWindow
- Throws:
SpiceErrorException
- exception
-
sub
public SpiceWindow sub(SpiceWindow b) throws SpiceErrorException
Compute the difference of two SpiceWindows: subtract a specified SpiceWindow from another.- Parameters:
b
- SpiceWindow- Returns:
- SpiceWindow
- Throws:
SpiceErrorException
- exception
-
insert
public SpiceWindow insert(double left, double right) throws SpiceErrorException
Insert an interval into a SpiceWindow.Unlike windows in SPICELIB and CSPICE, SpiceWindows don't need to contain empty space to accommodate inserted intervals; in fact they don't contain empty space at all. The data array of a SpiceWindow is re-allocated as necessary to accommodate insertions. Thus the following code fragment is valid:
SpiceWindow w = new SpiceWindow(); w.insert( 1.0, 2.0 );
This method updates the SpiceWindow's endpoint array and returns a reference to the window.
- Parameters:
left
- doubleright
- double- Returns:
- SpiceWindow
- Throws:
SpiceErrorException
- exception
-
complement
public SpiceWindow complement(double left, double right) throws SpiceErrorException
Complement a SpiceWindow with respect to a specified interval.- Parameters:
left
- doubleright
- double- Returns:
- SpiceWindow
- Throws:
SpiceErrorException
- exception
-
contract
public void contract(double left, double right) throws SpiceErrorException
Contract a SpiceWindow using specified inset values.- Parameters:
left
- doubleright
- double- Throws:
SpiceErrorException
- exception
-
expand
public void expand(double left, double right) throws SpiceErrorException
Expand a SpiceWindow using specified inset values.- Parameters:
left
- doubleright
- double- Throws:
SpiceErrorException
- exception
-
fill
public void fill(double small) throws SpiceErrorException
Fill in gaps shorter than a specified in from a SpiceWindow.- Parameters:
small
- double- Throws:
SpiceErrorException
- exception
-
filter
public void filter(double small) throws SpiceErrorException
Filter intervals shorter than a specified length from a SpiceWindow.- Parameters:
small
- double- Throws:
SpiceErrorException
- exception
-
getMeasure
public double getMeasure()
Get the measure of this SpiceWindow.- Returns:
- double
-
toString
public java.lang.String toString()
Override Object's toString method.- Overrides:
toString
in classjava.lang.Object
- Returns:
- String
-
-