unikl.disco.nc
Class LinearSegment

java.lang.Object
  extended by unikl.disco.nc.LinearSegment

public class LinearSegment
extends java.lang.Object

Class representing linear segments of a curve. A linear segments starts at point (x0, y0) and continues to the right with slope grad. If leftopen is true, the point (x0,y0) is excluded from the segment, otherwise is is included.

Author:
Frank A. Zdarsky

Field Summary
 double grad
          The gradient of the linear segment
 boolean leftopen
          Whether the point (x0, y0) is part of the segment or not.
static LinearSegment X_AXIS
           
 double x0
          The x-coordinate of the linear segment's starting point.
 double y0
          The y-coordinate of the linear segment's starting point.
 
Constructor Summary
LinearSegment()
          The default constructor.
LinearSegment(double x0, double y0, double grad, boolean leftopen)
          A convenience constructor.
 
Method Summary
 LinearSegment copy()
          Returns a copy of this instance.
 double f(double x)
          Returns the function value of this linear segment at the given x-coordinate.
 double getXIntersectionWith(LinearSegment other)
          Returns the x-coordinate at which a co-linear line through this segment intersects a co-linear line through the segment other.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_AXIS

public static final LinearSegment X_AXIS

x0

public double x0
The x-coordinate of the linear segment's starting point.


y0

public double y0
The y-coordinate of the linear segment's starting point.


grad

public double grad
The gradient of the linear segment


leftopen

public boolean leftopen
Whether the point (x0, y0) is part of the segment or not.

Constructor Detail

LinearSegment

public LinearSegment()
The default constructor.


LinearSegment

public LinearSegment(double x0,
                     double y0,
                     double grad,
                     boolean leftopen)
A convenience constructor.

Parameters:
x0 -
y0 -
grad -
leftopen -
Method Detail

copy

public LinearSegment copy()
Returns a copy of this instance.

Returns:
a copy of this instance.

f

public double f(double x)
Returns the function value of this linear segment at the given x-coordinate. Note that there is no test whether the function is defined at this location, but simply returns the the value of the co-linear line.

Parameters:
x - the coorinate whose function value shall be returned
Returns:
the function value

getXIntersectionWith

public double getXIntersectionWith(LinearSegment other)
Returns the x-coordinate at which a co-linear line through this segment intersects a co-linear line through the segment other.

Parameters:
other - the other segment
Returns:
the x-coordinate at which the segments cross