Skip to content

Commit

Permalink
fix direction in alternative Line constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jul 11, 2024
1 parent e744692 commit ef3fd09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Sets/Line/Line.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct Line{N,VN<:AbstractVector{N}} <: AbstractPolyhedron{N}
end

function Line(; from::AbstractVector, to::AbstractVector, normalize=false)
d = from - to
d = to - from
@assert !iszero(d) "points `$from` and `$to` should be distinct"
return Line(from, d; normalize=normalize)
end
Expand Down
4 changes: 1 addition & 3 deletions test/Sets/Line.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ for N in [Float64, Rational{Int}, Float32]
# construction
l1 = Line(; from=N[0, 1], to=N[1, 1]) # two points on the line
l2 = Line(N[0, 1], N[1, 0]) # point and direction
@test l1.p l2.p && l1.d l2.d # the lines are the same

# construction given a 2d direction and offset
ll = Line(N[0, 1], N(1)) # y == 1
Expand All @@ -17,9 +18,6 @@ for N in [Float64, Rational{Int}, Float32]
@test N[0, 0] ll && N[1, 1] ll
@test_throws ArgumentError Line(zeros(N, 2), N(0))

# the lines are the same modulo the sign of the normal vector
@test l1.p l2.p && l1.d -l2.d

# direction
@test direction(l2) == N[1, 0]

Expand Down

0 comments on commit ef3fd09

Please sign in to comment.