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

triangulate on transformed points #3402

Merged
merged 2 commits into from
Nov 23, 2023
Merged

Conversation

SimonDanisch
Copy link
Member

@SimonDanisch SimonDanisch commented Nov 23, 2023

This finally fixes the long standing issue of GeoMakie plotting broken polygons for non affine transforms, since it gets triangulated before transformation.
Sadly, Makie isn't ready yet for the best solution:

  1. transforming in the poly recipe and handing through the transformed points doesn't work, since axis and limits will not work for e.g. log10, since it will apply the transform again.
  2. leaving the transformation + triangulation entirely to the backend. This will need a larger refactor to make polygon a backend primitive.

To still finally have correct polygons, this PR applies the transformation before triangulation, but still forwards the untransformed points to the backend, which will lead to transforming two times, only if transform_func != identity.

With this PR:

image

Master:
image

@MakieBot
Copy link
Collaborator

MakieBot commented Nov 23, 2023

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 3.45s (3.40, 3.48) 0.03+- 529.48ms (511.20, 549.62) 15.26+- 484.92ms (475.85, 491.75) 5.74+- 7.77ms (7.52, 8.13) 0.22+- 26.03ms (25.84, 26.43) 0.20+-
master 3.46s (3.42, 3.52) 0.03+- 531.81ms (517.88, 550.02) 10.92+- 496.51ms (485.57, 527.01) 14.09+- 7.82ms (7.62, 8.19) 0.20+- 26.06ms (25.80, 26.33) 0.19+-
evaluation 1.00x invariant, -0.01s (-0.32d, 0.56p, 0.03std) 1.00x invariant, -2.33ms (-0.18d, 0.75p, 13.09std) 1.02x invariant, -11.59ms (-1.08d, 0.08p, 9.91std) 1.01x invariant, -0.06ms (-0.27d, 0.62p, 0.21std) 1.00x invariant, -0.03ms (-0.18d, 0.75p, 0.19std)
CairoMakie 2.87s (2.83, 2.95) 0.05+- 315.77ms (310.34, 327.99) 5.79+- 142.09ms (139.11, 147.97) 3.03+- 7.34ms (7.19, 7.49) 0.10+- 602.75μs (594.06, 610.70) 6.76+-
master 2.79s (2.75, 2.83) 0.03+- 316.90ms (313.31, 320.24) 2.95+- 141.51ms (139.85, 142.66) 1.10+- 7.41ms (7.30, 7.52) 0.07+- 597.74μs (593.98, 603.25) 3.03+-
evaluation 0.97x slower X, 0.09s (2.30d, 0.00p, 0.04std) 1.00x invariant, -1.13ms (-0.25d, 0.66p, 4.37std) 1.00x invariant, 0.58ms (0.25d, 0.65p, 2.06std) 1.01x invariant, -0.07ms (-0.74d, 0.20p, 0.09std) 0.99x invariant, 5.01μs (0.96d, 0.11p, 4.90std)
WGLMakie 3.63s (3.53, 3.72) 0.07+- 543.67ms (521.97, 560.69) 15.77+- 8.86s (8.63, 9.02) 0.15+- 9.75ms (9.42, 10.50) 0.36+- 72.07ms (67.02, 80.36) 4.31+-
master 3.56s (3.52, 3.65) 0.05+- 532.12ms (522.96, 546.91) 9.10+- 8.71s (8.60, 8.99) 0.15+- 9.60ms (9.43, 9.90) 0.16+- 71.07ms (67.66, 81.48) 4.86+-
evaluation 0.98x invariant, 0.07s (1.05d, 0.08p, 0.06std) 0.98x invariant, 11.55ms (0.90d, 0.13p, 12.43std) 0.98x invariant, 0.15s (1.01d, 0.08p, 0.15std) 0.99x invariant, 0.15ms (0.52d, 0.36p, 0.26std) 0.99x invariant, 1.0ms (0.22d, 0.69p, 4.59std)

@SimonDanisch SimonDanisch merged commit 77e9fd1 into master Nov 23, 2023
15 checks passed
@SimonDanisch SimonDanisch deleted the sd/triangulate-after-transform branch November 23, 2023 14:45
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

Successfully merging this pull request may close these issues.

2 participants