Skip to content

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

Open
@ffreyer

Description

@ffreyer

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ffreyer

        Issue actions

          Consider changing internal representation of Rect for more float safety · Issue #256 · JuliaGeometry/GeometryBasics.jl