Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pointOnPath wraps at 100% to 0% #425

Open
fjenett opened this issue Jun 21, 2016 · 3 comments
Open

pointOnPath wraps at 100% to 0% #425

fjenett opened this issue Jun 21, 2016 · 3 comments

Comments

@fjenett
Copy link

fjenett commented Jun 21, 2016

Currently (NodeBox 3.0.45) the point-on-path wraps at 100% to 0% which is not desirable because one might want to step up to the full 100% (think animation never reaching the final destination).

I think the problem is the modulo here:

public static Point pointOnPath(AbstractGeometry shape, double t) {

Checking > 100 and then setting to exactly 100 (same for 0) would be a better strategy:

    public static Point pointOnPath(AbstractGeometry shape, double t) {
        if (shape == null) return null;
        if ( t < 0 ) t = 0;
        else if ( t > 100 ) t = 100;
        return shape.pointAt(t / 100);
    }
@fdb
Copy link
Member

fdb commented Jun 21, 2016

Thanks! This is indeed not the desired behaviour.

There are two "correct" solutions:

  • as-is: this is useful in some cases where going over the point actually gives an interesting result (think "extrapolation", ie. http://www.enigmeta.com/codevember/18/).
  • Clamping: so values stay on the path.

I'm not sure which is the right one. I'm leaning toward the first one, and then using an extra node to clamp the value.

@fjenett
Copy link
Author

fjenett commented Jul 22, 2016

Extrapolation is fine with me and yes it is interesting. My problem is that it never reaches 100%, so it is not possible to animate between two states because the final state is never reached.

@jcartan
Copy link

jcartan commented Mar 16, 2019

This is a frequent problem for me too. My workaround is wrap a subnetwork around pointOnPath with a switch inside. If T<100 the switch returns an intermediate state based on pointOnPath; if T=100 it returns the end state instead.

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

No branches or pull requests

3 participants