Skip to content
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

Rename and move helper function #3621

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/src/lib/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ LazySets.convert(::Type{Hyperplane{N}}, ::Expr; vars::Vector{Basic}=Basic[]) whe
```@docs
sign_cadlag
minmax
arg_minmax
```

## Other functions
Expand Down
21 changes: 19 additions & 2 deletions src/ConcreteOperations/convex_hull.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function _collinear_case!(points, A, B, C, D)
# assign the points with max and min value in their second component
# to the firsts points and the extra point to the third place, then
# pop the point that was in the middle
min_y, max_y = arg_minmax(A[2], B[2], C[2])
min_y, max_y = _arg_minmax(A[2], B[2], C[2])
points[1] = _get_i(min_y, A, B, C)
points[2] = _get_i(max_y, A, B, C)
points[3] = D
Expand All @@ -265,7 +265,7 @@ function _collinear_case!(points, A, B, C, D)
# assign the points with max and min value in their first component to
# the firsts points and the extra point to the third place, then pop the
# point that was in the middle
min_x, max_x = arg_minmax(A[1], B[1], C[1])
min_x, max_x = _arg_minmax(A[1], B[1], C[1])
points[1] = _get_i(min_x, A, B, C)
points[2] = _get_i(max_x, A, B, C)
points[3] = D
Expand All @@ -274,6 +274,23 @@ function _collinear_case!(points, A, B, C, D)
return _three_points_2d!(points)
end

# return the indices of the minimum and maximum of three numbers a, b, c
function _arg_minmax(a, b, c)
if a > b
min, max = b, a
imin, imax = 2, 1
else
min, max = a, b
imin, imax = 1, 2
end
if c > max
imax = 3
elseif c < min
imin = 3
end
return imin, imax
end

function _four_points_2d!(points::AbstractVector{<:AbstractVector{N}}) where {N}
A, B, C, D = points[1], points[2], points[3], points[4]
tri_ABC = right_turn(A, B, C)
Expand Down
38 changes: 0 additions & 38 deletions src/Utils/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,3 @@ function minmax(a, b, c)
end
return min, max
end

"""
arg_minmax(a, b, c)

Compute the indices of the minimum and maximum of three numbers a, b, c.

### Input

- `a` -- first number
- `b` -- second number
- `c` -- third number

### Output

The indices of the minimum and maximum of the three given numbers.

### Examples

```jldoctest
julia> LazySets.arg_minmax(1.4, 52.4, -5.2)
(3, 2)
```
"""
function arg_minmax(a, b, c)
if a > b
min, max = b, a
imin, imax = 2, 1
else
min, max = a, b
imin, imax = 1, 2
end
if c > max
imax = 3
elseif c < min
imin = 3
end
return imin, imax
end
Loading