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

Domain range of ContinuousPiecewiseLinearFunction #63

Open
Peter-Knoppers opened this issue Nov 17, 2024 · 2 comments
Open

Domain range of ContinuousPiecewiseLinearFunction #63

Peter-Knoppers opened this issue Nov 17, 2024 · 2 comments
Assignees
Labels
djutils-draw djutils-draw project djutils-math djutils-math project question Further information is requested

Comments

@Peter-Knoppers
Copy link
Collaborator

Currently, the ContinuousPieceWiseLinearFunction limits domain values to the interval [0.0, 1.0]. This is well suited for catching errors in the original use of these functions (offset-functions for Arc, Bezier, and other Curves that are generated as a function of a t-value that runs from 0.0 to 1.0).

Other than that particular use, I see no reason for limiting the domain to [0.0, 1.0]. In fact, the entire range covered by double could be permitted (except for NaN, and infinity values).

As these functions will be enhanced with various operators (plus, minus, times, etc.), shall we drop the domain range restriction?
The only immediate problem would be the proposed reverse operator. This can easily be handled by a way more general operation that does any linear remapping of the domain. The proposed reverse operation could than be written as remapDomain(from, to, scale) with parameters 0, 1, -1.

N.B. the reason for ruling out infinity values is that interpolating between a finite domain value and an infinite domain value would be problematic.

@Peter-Knoppers Peter-Knoppers added question Further information is requested djutils-draw djutils-draw project djutils-math djutils-math project labels Nov 17, 2024
@averbraeck
Copy link
Owner

@WJSchakel : what are your thoughts on this?

@WJSchakel
Copy link
Collaborator

I agree with dropping the limitation. There is one other use-case that will change. Currently the idea of the sub(double, double) method is to rescale that to the [0...1] domain. That would then need to become a chained call: sub(from, to).remapDomain(from, to, 1.0 / (to - from)). We might opt to instead provide a normalizeDomain(from, to) which does exactly that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
djutils-draw djutils-draw project djutils-math djutils-math project question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants