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

Unexpected behavior PointAtNormalized for polylines #1006

Open
pederlh opened this issue Aug 1, 2023 · 0 comments
Open

Unexpected behavior PointAtNormalized for polylines #1006

pederlh opened this issue Aug 1, 2023 · 0 comments

Comments

@pederlh
Copy link
Contributor

pederlh commented Aug 1, 2023

Describe the bug
Starting with Hypar.Elements 2.0.0, polylines are parametrized 0 -> # vertices - 1, which changed the behavior of methods such as PointAt. In order to facilitate simple library updates, the convenience method PointAtNormalized using the old parametrization 0 -> 1 was introduced. However, even though this method deceptively appears to be linear, it is not. Should this behavior change or be clarified better?

To Reproduce
An sample polyline with three vertices is initialized below:

Polyline perimeter = new(new List<Vector3>()
{
    new Vector3(x: 0.0, y: 0.0),
    new Vector3(x: 8.0,  y: 0.0),
    new Vector3(x: 10.0, y: 0.0), 
}
);

Vector3 point0 = perimeter.PointAtNormalized(0.25);
Vector3 point1 = perimeter.PointAtNormalized(0.50);

Expected behavior
point0 is located at x=2.5 and point1 at x=5.0.

What happens
point0 is located at x=4.0 and point1 at x=8.0.

Bonus
Is there an elegant way of changing from old to new parametrization? The procedure seems to involve finding the length of each individual line + the total polyline length, and calculating the parametrization variable for each vertex.

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

1 participant