Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Spring overshoots even when clamping has been enabled #20

Open
richardscarrott opened this issue Jun 22, 2015 · 0 comments
Open

Spring overshoots even when clamping has been enabled #20

richardscarrott opened this issue Jun 22, 2015 · 0 comments

Comments

@richardscarrott
Copy link

I'm not 100% sure if this is as expected but the impression I got was that by enabling overshoot clamping with Spring.prototype.setOvershootClampingEnabled the spring would never go beyond the end value. I however am experiencing the spring overshooting when setting the velocity of a spring which is already at rest, e.g.

var springSystem = new rebound.SpringSystem();
var spring = window.spring = springSystem.createSpring();

spring.setOvershootClampingEnabled(true);
spring.addListener({
    onSpringUpdate: function(spring) {
        console.log(spring.getCurrentValue());
    }
});

spring.setVelocity(-0.1);

// Console
// -0.00009908567306149528
// -0.0013381384439321623
// ... more negative numbers ...
// -0.000002966453601728263
// 0.00004496495274462767
// 0.00008388667615449482
// 0

Whereas I had expected it would remain at 0?

Great library btw!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant