This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The output y is the area under a line given by two points p1, p2 which are assumed to be either both above or both below the abscissa, i.e., the ordinates of the points have the same sign.
Functions.areaLineSegment(p1, p2);
y := abs((p2[1] - p1[1]) * (p1[2] + p2[2]) / 2);
areaLineSegment({1,1},{2,1}); // 1.0 areaLineSegment({1,1},{2,2}); // 1.5
encapsulated function areaLineSegment import BusinessSimulation.Icons.Function; extends Function; input Real[2] p1, p2 "Points whose ordinates have the same sign"; output Real y "Area between the abscissa and the line within the closed interval [p1[1], p2[1]]"; end areaLineSegment;