Advertisement
Nexeon

Untitled

Feb 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. template <typename T> sf::Vector2<T> TripleBezierLerp(sf::Vector2<T> p1, sf::Vector2<T> p2, sf::Vector2<T> p3, T t) {
  2.     T x = (std::pow(1.f-t, 2) * p1.x) + 2 * ((1.f - t) * t * p2.x) + (std::pow(t, 2) * p3.x);
  3.     T y = (std::pow(1.f - t, 2) * p1.y) + 2 * ((1.f - t) * t * p2.y) + (std::pow(t, 2) * p3.y);
  4.     return sf::Vector2<T>(x, y);
  5. }
  6.  
  7. for (float t = 0.f; t <= 1.f; t += 0.1f) {
  8.         m_Corner.append(sf::Vertex(TripleBezierLerp(v1, v2, v3, t)));
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement