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

Fix incorrect comparison in CairoMakie line projections #4631

Merged
merged 10 commits into from
Nov 27, 2024

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Nov 26, 2024

Description

Fixes #4627

Fixes a <= that should be a <. Also removes some redundant > that could create similar issues.

More detail: After projections and truncating to Float32, p[5], p[6] both have an x value of 1, i.e. they are exactly on the clipping edge. (In clip space the x value range is always -1..1.) Clipping is checked using the distance to clip planes, effectively d = 1 - x, so for our points d = 0f0.

For the p[4] -- p[5] segment it does not detect them as both outside with d <= 0 (correct), and then also not as one outside with d < 0 (fine). In other words it detects both as inside. Neither point needs to be adjusted, and only the first is pushed. If p[5] were outside, p[5] would get translated towards p[4] until it is inside and then get pushed to finish the segment.

For the next segment p[5] -- p[6] it does detect them both as outside with d <= 0, which is an invalid state. Both points being outside implies that p[4] -- p[5] detected p[5] as outside, which would have pushed an adjusted point between the two. So this iteration believes the previous segment to be finished and pushes NaN to cut the line instead. And thus the inside -> edge segment disappears.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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.

@MakieBot
Copy link
Collaborator

MakieBot commented Nov 26, 2024

Benchmark Results

SHA: c908f8e088612ec5fb7e706d4781a060bfb8b528

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

@ffreyer ffreyer marked this pull request as ready for review November 26, 2024 17:03
@ffreyer ffreyer merged commit 573c361 into master Nov 27, 2024
22 of 23 checks passed
@ffreyer ffreyer deleted the ff/fix-line-clipping branch November 27, 2024 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

CairoMakie sometimes doesn't draw the last bin in stephist
3 participants