Skip to content

Consider changing internal representation of Rect for more float safety #256

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

Open
ffreyer opened this issue Apr 5, 2025 · 0 comments
Open

Comments

@ffreyer
Copy link
Collaborator

ffreyer commented Apr 5, 2025

Using origins and widths means that all the vertices except for origin have (potential for) float precision issues. For example, if we wanted a (Float32) Rect from -1f10 to 500 we would instead get:

julia> Point2f(-1f10) + (Point2f(500) - Point2f(-1f10))
2-element Point{2, Float32} with indices SOneTo(2):
 0.0
 0.0

julia> coordinates(Rect2f([Point2f(-1f10), Point2f(500)]))
4-element Vector{Point{2, Float32}}:
 [-1.0f10, -1.0f10]
 [0.0, -1.0f10]
 [0.0, 0.0]
 [-1.0f10, 0.0]

because eps(-1f10) = 1024f0 can not resolve 500.

For reference, I hit this here: MakieOrg/Makie.jl#4911

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