/** * Returns a curve based on an underlying curve with a fixed amount added to the Y values. * * @param curve the underlying curve * @param shiftAmount the amount added to the Y values of the curve * @return a curve based on an underlying curve with a fixed amount added to the Y values. */ public static ParallelShiftedCurve absolute(Curve curve, double shiftAmount) { return new ParallelShiftedCurve(curve, ShiftType.ABSOLUTE, shiftAmount); }
/** * Returns a curve based on an underlying curve with a parallel shift applied to the Y values. * * @param curve the underlying curve * @param shiftType the type of shift which specifies how the shift amount is applied to the Y values * @param shiftAmount the magnitude of the shift * @return a curve based on an underlying curve with a parallel shift applied to the Y values */ public static ParallelShiftedCurve of(Curve curve, ShiftType shiftType, double shiftAmount) { return new ParallelShiftedCurve(curve, shiftType, shiftAmount); }
@Override public ParallelShiftedCurve build() { return new ParallelShiftedCurve( underlyingCurve, shiftType, shiftAmount); }
/** * Returns a curve based on an underlying curve with a scaling applied to the Y values. * <p> * The shift amount is interpreted as a percentage. For example, a shift amount of 0.1 is a * shift of +10% which multiplies the value by 1.1. A shift amount of -0.2 is a shift of -20% * which multiplies the value by 0.8 * * @param curve the underlying curve * @param shiftAmount the percentage by which the Y values are scaled * @return a curve based on an underlying curve with a scaling applied to the Y values. */ public static ParallelShiftedCurve relative(Curve curve, double shiftAmount) { return new ParallelShiftedCurve(curve, ShiftType.RELATIVE, shiftAmount); }
@Override public ParallelShiftedCurve withParameter(int parameterIndex, double newValue) { if (parameterIndex == underlyingCurve.getParameterCount()) { return new ParallelShiftedCurve(underlyingCurve, shiftType, newValue); } return new ParallelShiftedCurve(underlyingCurve.withParameter(parameterIndex, newValue), shiftType, shiftAmount); }
@Override public ParallelShiftedCurve withMetadata(CurveMetadata metadata) { return new ParallelShiftedCurve(underlyingCurve.withMetadata(metadata), shiftType, shiftAmount); }
@Override public ParallelShiftedCurve withPerturbation(ParameterPerturbation perturbation) { Curve bumpedCurve = underlyingCurve.withPerturbation(perturbation); int shiftIndex = underlyingCurve.getParameterCount(); double bumpedShift = perturbation.perturbParameter(shiftIndex, shiftAmount, getParameterMetadata(shiftIndex)); return new ParallelShiftedCurve(bumpedCurve, shiftType, bumpedShift); }