1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.probfunction.math.util; |
5 | |
6 | /** |
7 | * @author Ihssane |
8 | * |
9 | */ |
10 | public class Line { |
11 | |
12 | private double a; |
13 | private double b; |
14 | |
15 | /** |
16 | * @param x1 |
17 | * @param y1 |
18 | * @param x2 |
19 | * @param y2 |
20 | */ |
21 | public Line(double x1, double y1, double x2, double y2) { |
22 | if (x2-x1 == 0.0) { |
23 | throw new RuntimeException("Two samples of the PDF have the same value. Note that an initial sample with value 0 is assumed, so you must not specify another one with value 0. Values: "+x1+" and "+x2); |
24 | } |
25 | a = (y2 - y1) / (x2 - x1); |
26 | b = y1 - (a * x1); |
27 | } |
28 | |
29 | /** |
30 | * @param y |
31 | * @return |
32 | */ |
33 | public double getX(double y) { |
34 | double result = (y-b)/a; |
35 | return result; |
36 | } |
37 | } |