Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Define a Simple (2D) rectangle with 2 points or 1 point and dimension #149

Description

@s-celles

Hello,

I was looking for building a Simple (2D) rectangle with 2 points

julia> Rectangle(Point(0,0), Point(320, 200))
ERROR: MethodError: no method matching SimpleRectangle(::Point{2,Int64}, ::Point{2,Int64})
Closest candidates are:
  SimpleRectangle(::T, ::T, ::T, ::T) where T at /Users/scls/.julia/dev/GeometryTypes/src/types.jl:110
Stacktrace:
 [1] top-level scope at none:0

or

a Simple (2D) rectangle with one point and dimensions (width/height)

julia> Rectangle(Point(10,10), Vec(310, 190))
ERROR: MethodError: no method matching SimpleRectangle(::Point{2,Int64}, ::Vec{2,Int64})
Closest candidates are:
  SimpleRectangle(::Vec{2,T}, ::Vec{2,T}) where T at /Users/scls/.julia/dev/GeometryTypes/src/hyperrectangles.jl:229
  SimpleRectangle(::T, ::T, ::T, ::T) where T at /Users/scls/.julia/dev/GeometryTypes/src/types.jl:110
Stacktrace:
 [1] top-level scope at none:0

I saw

SimpleRectangle(val::Vec{2, T}) where {T} = SimpleRectangle{T}(0, 0, val...)
function SimpleRectangle(position::Vec{2,T}, width::Vec{2,T}) where T
SimpleRectangle{T}(position..., width...)
end

Maybe using Point type could help (to avoid confusion with Vec)?

Kind regards

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

      Issue actions