Class LinearSegment_Disco
- java.lang.Object
-
- org.networkcalculus.dnc.curves.disco.LinearSegment_Disco
-
- All Implemented Interfaces:
LinearSegment
public class LinearSegment_Disco extends java.lang.Object implements LinearSegment
Class representing linear segments of a curve. A linear segments starts at point (x0
,y0
) and continues to the right with slopegrad
. Ifleftopen
istrue
, the point (x0
,y0
) is excluded from the segment, otherwise is included.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
LinearSegment_Disco.LinearSegment_DNC_builder
-
Nested classes/interfaces inherited from interface org.networkcalculus.dnc.curves.LinearSegment
LinearSegment.Builder
-
-
Field Summary
Fields Modifier and Type Field Description protected Num
grad
The gradient of the linear segmentprotected boolean
leftopen
Whether the point (x0
,y0
) is part of the segment or not.protected Num
x
The x-coordinate of the linear segment's starting point.protected Num
y
The y-coordinate of the linear segment's starting point.
-
Constructor Summary
Constructors Modifier Constructor Description protected
LinearSegment_Disco()
The default constructor.LinearSegment_Disco(java.lang.String segment_str)
LinearSegment_Disco(LinearSegment segment)
LinearSegment_Disco(Num x, Num y, Num grad, boolean leftopen)
A convenient constructor.
-
Method Summary
Modifier and Type Method Description LinearSegment_Disco
copy()
Returns a copy of this instance.boolean
equals(java.lang.Object obj)
Num
f(Num x)
Returns the function value of this linear segment at the given x-coordinate.static LinearSegment.Builder
getBuilder()
Num
getGrad()
Num
getX()
Num
getXIntersectionWith(LinearSegment other)
Returns the x-coordinate at which a co-linear line through this segment intersects a co-linear line through the segmentother
.Num
getY()
int
hashCode()
boolean
isLeftopen()
void
setGrad(Num grad)
void
setLeftopen(boolean leftopen)
void
setX(Num x)
void
setY(Num y)
java.lang.String
toString()
Returns a string representation of this linear segment.
-
-
-
Field Detail
-
x
protected Num x
The x-coordinate of the linear segment's starting point.
-
y
protected Num y
The y-coordinate of the linear segment's starting point.
-
grad
protected Num grad
The gradient of the linear segment
-
leftopen
protected boolean leftopen
Whether the point (x0
,y0
) is part of the segment or not.
-
-
Constructor Detail
-
LinearSegment_Disco
protected LinearSegment_Disco()
The default constructor.
-
LinearSegment_Disco
public LinearSegment_Disco(Num x, Num y, Num grad, boolean leftopen)
A convenient constructor.- Parameters:
x
- The x-coordinate this segments starts at.y
- The y-coordinate this segments starts at.grad
- The segments gradient.leftopen
- Set the segment to be left-open.
-
LinearSegment_Disco
public LinearSegment_Disco(LinearSegment segment)
-
LinearSegment_Disco
public LinearSegment_Disco(java.lang.String segment_str) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
f
public Num f(Num 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.- Specified by:
f
in interfaceLinearSegment
- Parameters:
x
- the coordinate whose function value shall be returned- Returns:
- the function value
-
getX
public Num getX()
- Specified by:
getX
in interfaceLinearSegment
-
setX
public void setX(Num x)
- Specified by:
setX
in interfaceLinearSegment
-
getY
public Num getY()
- Specified by:
getY
in interfaceLinearSegment
-
setY
public void setY(Num y)
- Specified by:
setY
in interfaceLinearSegment
-
getGrad
public Num getGrad()
- Specified by:
getGrad
in interfaceLinearSegment
-
setGrad
public void setGrad(Num grad)
- Specified by:
setGrad
in interfaceLinearSegment
-
isLeftopen
public boolean isLeftopen()
- Specified by:
isLeftopen
in interfaceLinearSegment
-
setLeftopen
public void setLeftopen(boolean leftopen)
- Specified by:
setLeftopen
in interfaceLinearSegment
-
getXIntersectionWith
public Num getXIntersectionWith(LinearSegment other)
Returns the x-coordinate at which a co-linear line through this segment intersects a co-linear line through the segmentother
.- Specified by:
getXIntersectionWith
in interfaceLinearSegment
- Parameters:
other
- the other segment- Returns:
- the x-coordinate at which the segments cross or NaN of they are parallel
-
copy
public LinearSegment_Disco copy()
Returns a copy of this instance.- Specified by:
copy
in interfaceLinearSegment
- Returns:
- a copy of this instance.
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceLinearSegment
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceLinearSegment
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a string representation of this linear segment.- Specified by:
toString
in interfaceLinearSegment
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the linear segment represented as a string.
-
getBuilder
public static LinearSegment.Builder getBuilder()
-
-