Advertisement
kingtide44

Untitled

Oct 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // credit: https://en.wikipedia.org/wiki/Vector_projection
  2. var bUnit = onto.getThisWithLength(1);
  3.  
  4. var a = this.getDotProductOf(bUnit);
  5. var a1Scalar = a.getLength() * Math.cos(a.getAng()-bUnit.getAng());
  6. // correct line: var a1Scalar = this.getLength() * Math.cos(this.getAng() - bUnit.getAng());
  7. var a1 = bUnit.getDot(a1Scalar);
  8. //if(mouseIsPressed) console.log(a1);
  9. if(shouldDraw) {
  10. a1.draw(2, [0, 255, 0]);
  11. }
  12.  
  13. return a1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement