annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearFunction.java @ 788:e8a9e84a0328

Corrected JavaDoc errors in Chart Package. gnv-artifacts/trunk@870 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 31 Mar 2010 08:01:56 +0000
parents c4156275c1e1
children bb7afd783321
rev   line source
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.math;
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import org.apache.commons.math.FunctionEvaluationException;
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
433
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
5 import org.apache.commons.math.analysis.UnivariateRealFunction;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
6
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
7 import org.apache.commons.math.optimization.fitting.ParametricRealFunction;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
8
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 /**
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
10 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 */
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 public class LinearFunction
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 implements ParametricRealFunction
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 {
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 public static final LinearFunction INSTANCE = new LinearFunction();
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
17 public static class Univariate
433
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
18 implements UnivariateRealFunction
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
19 {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
20 protected double m;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
21 protected double b;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
22
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
23 public Univariate() {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
24 }
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
25
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
26 public Univariate(double x1, double y1, double x2, double y2) {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
27 if (y1 == y2) {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
28 m = 0d;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
29 b = (x1 + x2)*0.5d;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
30 }
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
31 else {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
32 m = (x1 - x2)/(y1 - y2);
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
33 b = y1 - m*x1;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
34 }
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
35 }
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
36
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
37 public double value(double x) {
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
38 return m*x + b;
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
39 }
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
40 } // class Univariate
828df3ddb758 Added interpolation capabilities along z axis to XYColumns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 357
diff changeset
41
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 public LinearFunction() {
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public double value(double x, double [] parameters)
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
46 throws FunctionEvaluationException
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 {
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 return x*parameters[0] + parameters[1];
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
51 public double [] gradient(double x, double [] parameters)
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
52 throws FunctionEvaluationException
357
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 {
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 return new double [] { x, 1f };
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
25e4724aa504 Fill (i, j)-gaps when building index buffer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 433
diff changeset
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org