Class BezierPriceCalculation
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.product.BasePriceCalulation
-
- ch.sahits.game.openpatrician.model.product.BezierPriceCalculation
-
- All Implemented Interfaces:
IPriceCalculationV2
public class BezierPriceCalculation extends BasePriceCalulation
Price calculation if the curve is defined by a start and end point and two control points, defining the curve as a bezier curve.- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Aug 14, 2016
-
-
Constructor Summary
Constructors Constructor Description BezierPriceCalculation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.geometry.Point2DcaclulateBezierPoint(double t, javafx.geometry.Point2D start, javafx.geometry.Point2D cp1, javafx.geometry.Point2D cp2, javafx.geometry.Point2D end)Calculate the point (x,y-coordinates) on the bezier curve defined by the four control points for parametertjava.util.List<javafx.geometry.Point2D>calculateDiscreteBezierPoints(javafx.geometry.Point2D start, javafx.geometry.Point2D cp1, javafx.geometry.Point2D cp2, javafx.geometry.Point2D end)Calculate a list of points at discrete x coordinates.
PRE: The bezier curve does not bend back on itself.intcomputePrice(ITradable tradable, boolean buy, int available, int productionRate, IPopulationStructure pop, ECityState state)Compute the price for one item of the ware.-
Methods inherited from class ch.sahits.game.openpatrician.model.product.BasePriceCalulation
getMaxValue, getMinValue, getSaturation
-
-
-
-
Method Detail
-
caclulateBezierPoint
public javafx.geometry.Point2D caclulateBezierPoint(double t, javafx.geometry.Point2D start, javafx.geometry.Point2D cp1, javafx.geometry.Point2D cp2, javafx.geometry.Point2D end)Calculate the point (x,y-coordinates) on the bezier curve defined by the four control points for parametert- Parameters:
t- Value in the range [0,1] defining the fragment length on the curve.start- control point marking the start of the curvecp1- first control point defining the tangential direction of the curve leavingstartcp2- second control point defining the tangential direction of the curve going intoendend- control point marking the end of the curve.- Returns:
- Point (x,y-coordinates) at position
ton the curve.
-
calculateDiscreteBezierPoints
public java.util.List<javafx.geometry.Point2D> calculateDiscreteBezierPoints(javafx.geometry.Point2D start, javafx.geometry.Point2D cp1, javafx.geometry.Point2D cp2, javafx.geometry.Point2D end)Calculate a list of points at discrete x coordinates.
PRE: The bezier curve does not bend back on itself.- Parameters:
start- control point marking the start of the curvecp1- first control point defining the tangential direction of the curve leavingstartcp2- second control point defining the tangential direction of the curve going intoendend- control point marking the end of the curve.- Returns:
- List of points for x coordinates from start to end.
-
computePrice
public int computePrice(ITradable tradable, boolean buy, int available, int productionRate, IPopulationStructure pop, ECityState state)
Description copied from interface:IPriceCalculationV2Compute the price for one item of the ware. Though the price is only handled in further computation as integer value, this method returns its value as double so this condition can be tested:
The higher the available amount (but still below the saturation value) the smaller (strictly) the returned value.
For different starting values:
If the starting value b is below starting point a the whole curve of b is below (not necessary strictly) the curve of a. The curve is continues between 0 (inclusive) and infinity.- Parameters:
tradable- defining all the parameters specific for the ware that is traded that is required for the calculationbuy- flag indicating if the calculation should happen for buying or selling.available- amount of wares that are available in the marketproductionRate- amount the city can produce within a weekpop- population structure that may have an influence on the calculated pricestate- state of the city- Returns:
- price for one item sold
-
-