| 16 | } |
| 17 | |
| 18 | glm::vec3 HermiteCurve::getPointAt(float t) { |
| 19 | float point = (points.size() - 1) * t; |
| 20 | int intPoint = (int) point; |
| 21 | |
| 22 | float weight = point - intPoint; |
| 23 | |
| 24 | glm::vec3 point0 = points[intPoint == 0 ? intPoint : intPoint - 1]; |
| 25 | glm::vec3 point1 = points[intPoint]; |
| 26 | glm::vec3 point2 = points[intPoint > points.size() - 2 ? points.size() - 1 : intPoint + 1]; |
| 27 | glm::vec3 point3 = points[intPoint > points.size() - 3 ? points.size() - 1 : intPoint + 2]; |
| 28 | |
| 29 | return Interpolate(point0, point1, point2, point3, weight, tension, bias); |
| 30 | } |
| 31 | |
| 32 | float HermiteCurve::Interpolate(float p0, float p1, float p2, float p3, float t, float tension, float bias) { |
| 33 | float m0 = (p1 - p0) * (1 + bias) * (1 - tension) / 2 |