67 lines
1.6 KiB
Java

package ru.ulstu.method.ftransform;
/**
* Базисная функция
*/
public class AComponent {
private double start; // левая граница треугольника
private double end; // правая граница треугольника
private double top; // вершина треугольника
public double getStart() {
return start;
}
public AComponent() {
}
public AComponent(double start, double top, double end) {
this.start = start;
this.top = top;
this.end = end;
}
public void setStart(int start) {
this.start = start;
}
public double getEnd() {
return end;
}
public void setEnd(double end) {
this.end = end;
}
public double getTop() {
return top;
}
public int getTopInt() {
return (int) Math.round(top);
}
public void setTop(double top) {
this.top = top;
}
public double getValueAtPoint(int pointIndex) {
if (pointIndex == this.getTop()) {
return 1;
} else if ((pointIndex >= this.getEnd()) || (pointIndex <= this.getStart())) {
return 0;
} else if (pointIndex < this.getTop()) {
return (double) (pointIndex - this.getStart()) / (this.getTop() - this.getStart());
} else if (pointIndex > this.getTop()) {
return (double) -(pointIndex - this.getEnd()) / (this.getEnd() - this.getTop());
}
return 0;
}
@Override
public String toString() {
return "start=" + start;
}
}