Guest User

Untitled

a guest
Jan 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. //hit_axis is vector of axis which object collided with
  2. std::vector<sf::Vector2f>::iterator it;
  3.     for(it = hit_axes.begin();it != hit_axes.end();it++){
  4.         sf::Vector2f n = *it;
  5.         sf::Vector2f comp_u = sf::Vector2f(0,0);
  6.  
  7.         if(n != sf::Vector2f(0,0)){ //because -0 * (0 / 0) = undefined
  8.             comp_u = n * (maths::dot(dir,n) / maths::dot(n,n)); //component of hit axis in dir
  9.         }
  10.         sf::Vector2f comp_w = dir - comp_u;
  11.  
  12.         dir = comp_w;
  13.     }
Add Comment
Please, Sign In to add comment