probiner

MPC spam#1

Mar 15th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. float angle180(vector a, b){
  2. return cos(clamp(dot(normalize(a), normalize(b)),-1,1)) ;
  3. }
  4. vector crossM(vector a, b){
  5. return {1,0,0} * lookat(0,-a,b) ;
  6. }
  7. vector alignrot(vector pos, a, b ; float lerp){
  8. return qrotate(quaternion(angle180(a,b) * lerp, crossM(a,b)), pos);
  9. }
  10.  
  11. http://www.rhinohouse.com
  12.  
  13. vector b = {1,0,0} ;
  14. vector e = {-1,0,0} ;
  15.  
  16.  
  17. vector axis = {1,0,0} * lookat(0,-b,e) ;
  18. float angle = acos(clamp(dot(normalize(b), normalize(e)),-1,1)) ;
  19. vector4 quat = quaternion(angle*ch("blend"), axis) ;
  20.  
  21. vector pos = @P ;
  22. pos = qrotate(quat, pos) ;
  23.  
  24. @P = pos ;
Advertisement
Add Comment
Please, Sign In to add comment