q5xjs: Bug in Vector.lerp() implementation
There seems to be a bug with the implementation of Vector.lerp() function
$.Vector.lerp= function(v,u,t){return new $.Vector(v.x * (1-t) + u.x * t,
v.y = v.y * (1-t) + u.y * t,
v.z = v.z * (1-t) + u.z * t);}
The function change the value of y and z coordinate of the first param vector, which don’t seems to be intended (it should not modify any value of the first param vector)
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 15
It doesn’t seem correct to me! How is such an independent class now able to use Q5 instance functions like $.cos(), $.sin(), $.tan(), $.atan2()?
Okay I think it’s good now: https://github.com/quinton-ashley/q5.js/blob/39c3662c454519c932c29544384cd3bf42dd75f3/q5.js#L372
Actually I’m doing it right now. 😆 Just starting though: 👲
My solution to this was just to do this, ha! This is technically faster than what @LingDong- had before as well, creating new objects takes longer than just calling the function on the first vector inputted.
The lerp implementation in the Vector class looks correct to me.
https://github.com/quinton-ashley/q5js
p5js’ lerp() reference: https://p5js.org/reference/#/p5.Vector/lerp
My Processing Pjs-based implementation: