Package com.katiejergens.riemannSum
Class AbstractRiemann
- java.lang.Object
-
- com.katiejergens.riemannSum.AbstractRiemann
-
- Direct Known Subclasses:
LeftHandPlot
,RightHandPlot
,TrapezoidPlot
public abstract class AbstractRiemann extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description org.opensourcephysics.frames.PlotFrame
plotFrame
The plot frame to hold the graphsorg.dalton.polyfun.Polynomial
poly
The poly to get the area underint
subintervals
Number of slices, or subintervals, in the intervaldouble
xLower
The x-coordinate of the left side, or lower limit, of the intervaldouble
xUpper
The x-coordinate of the right side, or upper limit, of the interval
-
Constructor Summary
Constructors Constructor Description AbstractRiemann(org.dalton.polyfun.Polynomial polynomial, double xLower, double xUpper, int subintervals)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description double
calculateDeltaX()
Calculate the width of a single slice.void
configPlotFrame()
Set the properties of the plot frame such as size, visibility, default close operation, and the preferred min and max of the x axis and the y axis.void
drawRiemannSlices()
Draw all the slices for this poly that are in the interval.abstract void
drawSlice(double leftBorder, double rightBorder)
Draw a single slice, or subinterval, under the poly.double
getIntervalArea()
Estimate the area under the poly using Riemann sums.abstract double
getSubintervalArea(double leftBorder, double rightBorder)
Estimate the area under the poly for the given slice, or subinterval.void
plotAccFnc()
Draw the accumulation function.void
plotPolynomial()
Draw the the poly on the plot frame.
-
-
-
Field Detail
-
poly
public org.dalton.polyfun.Polynomial poly
The poly to get the area under
-
plotFrame
public org.opensourcephysics.frames.PlotFrame plotFrame
The plot frame to hold the graphs
-
xLower
public double xLower
The x-coordinate of the left side, or lower limit, of the interval
-
xUpper
public double xUpper
The x-coordinate of the right side, or upper limit, of the interval
-
subintervals
public int subintervals
Number of slices, or subintervals, in the interval
-
-
Constructor Detail
-
AbstractRiemann
public AbstractRiemann(org.dalton.polyfun.Polynomial polynomial, double xLower, double xUpper, int subintervals)
Constructor- Parameters:
polynomial
- The poly to get the area underxLower
- The x-coordinate of the left side, or lower limit, of the intervalxUpper
- The x-coordinate of the right side, or upper limit, of the intervalsubintervals
- The number of slices, or subintervals, in the interval
-
-
Method Detail
-
getIntervalArea
public double getIntervalArea()
Estimate the area under the poly using Riemann sums.- Returns:
- The estimated area under the curve
-
drawRiemannSlices
public void drawRiemannSlices()
Draw all the slices for this poly that are in the interval.
-
plotAccFnc
public void plotAccFnc()
Draw the accumulation function.
-
plotPolynomial
public void plotPolynomial()
Draw the the poly on the plot frame.
-
getSubintervalArea
public abstract double getSubintervalArea(double leftBorder, double rightBorder)
Estimate the area under the poly for the given slice, or subinterval. This is abstract because the implementation depends on which Riemann Rule you use.- Parameters:
leftBorder
- The left x-coordinate of the slicerightBorder
- The right x-coordinate of the slice- Returns:
- The area of this slice.
-
drawSlice
public abstract void drawSlice(double leftBorder, double rightBorder)
Draw a single slice, or subinterval, under the poly. This is abstract because the implementation depends on which Riemann Rule you use.- Parameters:
leftBorder
- The left x-coordinate of the slicerightBorder
- The right x-coordinate of the slice
-
configPlotFrame
public void configPlotFrame()
Set the properties of the plot frame such as size, visibility, default close operation, and the preferred min and max of the x axis and the y axis.
-
calculateDeltaX
public double calculateDeltaX()
Calculate the width of a single slice.- Returns:
- a double of the delta
-
-