pmndrs / maath

🪶 Math helpers for the rest of us
https://maath.pmnd.rs
801 stars 15 forks source link

maxSpeed in damp2, damp3, damp4 can be larger than its maxSpeed. #32

Open yomotsu opened 1 year ago

yomotsu commented 1 year ago

damp3 (for Vector3) is currently handed by 3 separated damps. https://github.com/pmndrs/maath/blob/90317077d86b6aca9a5a5708bd15007b4c89c7c9/packages/maath/src/easing.ts#L131-L148

but it can't be separated and should use the "magnitude (length) of the vector" for the maxSpeed.

e.g. If maxSpeed is 1: speed x can be 0.999 and speed y can be 0.999. It means vec3( 0.999, 0.999, 0 ), and diagonal of 0.999 x 0.999.

thus: Math.sqrt( Math.pow( 0.9999, 2 ) + Math.pow( 0.9999, 2 ) ); // = 1.4140721410168577

the result is larger than 1.