Skip to content
Snippets Groups Projects
Commit efe58626 authored by Soeren Peters's avatar Soeren Peters
Browse files

Add spline painting to exercise.

parent 069125f5
No related branches found
No related tags found
No related merge requests found
...@@ -84,4 +84,17 @@ In this exercise we need to implement this new method in the following classes: ...@@ -84,4 +84,17 @@ In this exercise we need to implement this new method in the following classes:
view/graphics/PaintableBezierCurve.java view/graphics/PaintableBezierCurve.java
### Expected behavior: ### Expected behavior:
Bezier Curve can be painted as before. Bezier Curve can be painted as before.
\ No newline at end of file
## Exercise 7
This exercise is based on the tenth lecture about the spline interpolation method.
In this exercise we need to implement this new interpolation method in the following classes:
model/Spline.java
Additionally, the following class was added to the project:
view/graphics/PaintableSpline.java
### Expected behavior:
Spline interpolation can be painted.
\ No newline at end of file
...@@ -23,9 +23,33 @@ public class PaintableSpline extends PaintableShape { ...@@ -23,9 +23,33 @@ public class PaintableSpline extends PaintableShape {
@Override @Override
public void paint(Painter painter) { public void paint(Painter painter) {
//TODO List<Point> pointList = spline.getPointList();
} int numOfPoints = 100;
painter.setColor(Color.BLACK);
// Spline zeichnen
if (pointList.size() > 2) {
for (int i = 0; i < numOfPoints - 1; i++) {
double t1 = (i) / (double) (numOfPoints - 1);
double t2 = (i + 1.0) / (double) (numOfPoints - 1);
Point p1 = spline.getPointOnSpline(t1);
Point p2 = spline.getPointOnSpline(t2);
// draw line
painter.paintLine(p1, p2);
}
}
// Kontrollpunkte zeichnen
for (int i = 0; i < pointList.size(); i++) {
Point p = pointList.get(i);
int k = 4;
Point p_view = trafo.transformToPointOnScreen(p);
painter.paintLine(p_view.getX() - k, p_view.getY() - k, p_view.getX() + k, p_view.getY() + k);
painter.paintLine(p_view.getX() + k, p_view.getY() - k, p_view.getX() - k, p_view.getY() + k);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment