Class 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 slope grad. If leftopen is true, the point (x0,y0) is excluded from the segment, otherwise is included.
    • 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 interface LinearSegment
        Parameters:
        x - the coordinate whose function value shall be returned
        Returns:
        the function value
      • 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 segment other.
        Specified by:
        getXIntersectionWith in interface LinearSegment
        Parameters:
        other - the other segment
        Returns:
        the x-coordinate at which the segments cross or NaN of they are parallel
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface LinearSegment
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface LinearSegment
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string representation of this linear segment.
        Specified by:
        toString in interface LinearSegment
        Overrides:
        toString in class java.lang.Object
        Returns:
        the linear segment represented as a string.