1 package org.djutils.draw.curve;
2
3 import org.djutils.draw.Direction3d;
4 import org.djutils.draw.curve.Flattener.FlattableCurve;
5 import org.djutils.draw.line.PolyLine3d;
6 import org.djutils.draw.point.DirectedPoint3d;
7 import org.djutils.draw.point.Point3d;
8
9
10
11
12
13
14
15
16
17
18
19 interface Curve3d
20 extends Curve<DirectedPoint3d, Direction3d, Point3d, Flattener3d, PolyLine3d>, FlattableCurve<Point3d, Direction3d>
21 {
22
23 @Override
24 default DirectedPoint3d getStartPoint()
25 {
26 return new DirectedPoint3d(getPoint(0.0), getDirection(0.0));
27 }
28
29 @Override
30 default DirectedPoint3d getEndPoint()
31 {
32 return new DirectedPoint3d(getPoint(1.0), getDirection(1.0));
33 }
34
35 @Override
36 default Direction3d getStartDirection()
37 {
38 return getStartPoint().getDir();
39 }
40
41 @Override
42 default Direction3d getEndDirection()
43 {
44 return getEndPoint().getDir();
45 }
46
47 @Override
48 default Direction3d getDirection(final double fraction)
49 {
50 Point3d p1, p2;
51 if (fraction < 0.5)
52 {
53 p1 = getPoint(fraction);
54 p2 = getPoint(fraction + 1e-6);
55 }
56 else
57 {
58 p1 = getPoint(fraction - 1e-6);
59 p2 = getPoint(fraction);
60 }
61 return p1.directionTo(p2);
62 }
63
64 }