Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // credit: https://en.wikipedia.org/wiki/Vector_projection
- var bUnit = onto.getThisWithLength(1);
- var a = this.getDotProductOf(bUnit);
- var a1Scalar = a.getLength() * Math.cos(a.getAng()-bUnit.getAng());
- // correct line: var a1Scalar = this.getLength() * Math.cos(this.getAng() - bUnit.getAng());
- var a1 = bUnit.getDot(a1Scalar);
- //if(mouseIsPressed) console.log(a1);
- if(shouldDraw) {
- a1.draw(2, [0, 255, 0]);
- }
- return a1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement