JuliaGeometry / JuliaGeometry/GeometryBasics.jl

Consider changing internal representation of Rect for more float safety

Open
#256 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
215
Forks
64
Avg merge
3d 18h
Merged PRs (30d)
2

Description

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: https://github.com/MakieOrg/Makie.jl/pull/4911

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Rect representation and the coordinates(Rect2f) behavior shown in the issue, then reproduce the Point2f Float32 example. Compare candidate representations against the -1f10-to-500 case; done means Rect vertices retain the intended values without the reported precision loss.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-graphics
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.