com.perisic.function
Class LinearFunction

java.lang.Object
  extended by com.perisic.function.AnyFunction
      extended by com.perisic.function.LinearFunction

public class LinearFunction
extends AnyFunction

A linear function. Nice means here roughly mostly continuous (only a small number of jumps) where the pieces are either constants or defined by cubic polynomials.

Copyright:(c) Marc Conrad, Tim French 2010; Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Author:
Marc Conrad

Constructor Summary
LinearFunction(double valueAt0, double valueAt1)
          Generates the linear functions through the points (0,valueAt0) and (1,valueAt1).
LinearFunction(double x1, double y1, double x2, double y2)
          Computes the linear function y = ax + b through the points (x1,y1) and (x2,y2).
 
Method Summary
 double eval(double x)
          Evaluates the linear function at x.
 
Methods inherited from class com.perisic.function.AnyFunction
addToImage, addToImage, getImage, getImage, main, normalizeResult
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearFunction

public LinearFunction(double valueAt0,
                      double valueAt1)
Generates the linear functions through the points (0,valueAt0) and (1,valueAt1).

Parameters:
valueAt0 - the value at 0.
valueAt1 - the value at 1.

LinearFunction

public LinearFunction(double x1,
                      double y1,
                      double x2,
                      double y2)
Computes the linear function y = ax + b through the points (x1,y1) and (x2,y2). if a is in the interval [-999999999,+999999999]. Any value outside this interval including infinity will be adjusted to -999999999 or +999999999. Values y < 0 will be adjusted to y = 0, values y > 1 will be adjusted to y = 1.

Parameters:
x1 - x-coordinate of (x1,y1).
y1 - y-coordinate of (x1,y1).
x2 - x-coordinate of (x2,y2).
y2 - y-coordinate of (x2,y2).
Method Detail

eval

public double eval(double x)
Evaluates the linear function at x. The result is normalised.

Specified by:
eval in class AnyFunction
Parameters:
x - The value against which the function is evaluated.
Returns:
f(x) where f is this object.