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

Don't restrict transformed point dim to input point dim in poly_convert #4584

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

asinghvi17
Copy link
Member

Description

Fixes MakieOrg/GeoMakie.jl#282

Previously, if you had 2D polygon and a 2D -> 3D transform func, the points would be transformed, and the resulting Point3 would be coerced back down to Point2. This is likely also why a lot of the triangulation was wrong.

This PR removes the element type constraint on the array returned from apply_transform, thus allowing 3D points to stay 3D.

I have a suspicion that if we merge this, it will break plotting polygons in 3d. It might need a very basic generic overload of GeometryBasics.earcut_triangulate for arbitrary dimensions, to restrict to 2D - at least for now.

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@asinghvi17
Copy link
Member Author

If this makes sense, I'll go ahead and add tests etc.

@MakieBot
Copy link
Collaborator

MakieBot commented Nov 11, 2024

Benchmark Results

SHA: cdc40be318608531d84ae9c9f326777bc0db9035

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

points = Vector{PT}[apply_transform(transform_func, outer)]
# Note that this should not be coerced to be a `Vector{PT}`,
# since `apply_transform` can change points from e.g 2D to 3D.
points = [apply_transform(transform_func, outer)]
points_flat = PT[outer;]
for inner in polygon.interiors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests would be nice.
What about the PT[outer;]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine, since points_flat contains the original points.

Will add some tests!

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

Successfully merging this pull request may close these issues.

Empty/deformed Polygons with LScene
3 participants