Skip to content

Commit

Permalink
PolyhedralGeometry: One-based indexing and julia like format for tria…
Browse files Browse the repository at this point in the history
…ngulations
  • Loading branch information
lkastner committed Jan 27, 2022
1 parent 7c17150 commit 36ec94f
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions src/PolyhedralGeometry/triangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ julia> V = vertices(c)
[1, 1]
julia> all_triangulations(point_matrix(V))
pm::Array<pm::Array<pm::Set<long, pm::operations::cmp>>>
<{0 1 2}
{1 2 3}
>
<{0 1 3}
{0 2 3}
>
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]
```
"""
function all_triangulations(pts::AnyVecOrMat)
input = homogenize(matrix_for_polymake(pts))
input = homogenize(pts)
PC = Polymake.polytope.PointConfiguration(POINTS=input)
return Polymake.polytope.topcom_all_triangulations(PC)
triangs = Polymake.polytope.topcom_all_triangulations(PC)
result = [[[e for e in simplex] for simplex in triang] for triang in triangs]
return Polymake.to_one_based_indexing(result)
end


Expand All @@ -44,13 +42,9 @@ julia> c = cube(2,0,1)
A polyhedron in ambient dimension 2
julia> all_triangulations(c)
pm::Array<pm::Array<pm::Set<long, pm::operations::cmp>>>
<{0 1 2}
{1 2 3}
>
<{0 1 3}
{0 2 3}
>
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]
```
"""
all_triangulations(P::Polyhedron) = all_triangulations(point_matrix(vertices(P)))
Expand Down Expand Up @@ -79,19 +73,17 @@ julia> V = vertices(c)
[1, 1]
julia> regular_triangulations(point_matrix(V))
pm::Array<pm::Array<pm::Set<long, pm::operations::cmp>>>
<{0 1 2}
{1 2 3}
>
<{0 1 3}
{0 2 3}
>
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 3, 4], [1, 2, 4]]
```
"""
function regular_triangulations(pts::AnyVecOrMat)
input = homogenize(matrix_for_polymake(pts))
input = homogenize(pts)
PC = Polymake.polytope.PointConfiguration(POINTS=input)
return Polymake.polytope.topcom_regular_triangulations(PC)
triangs = Polymake.polytope.topcom_regular_triangulations(PC)
result = [[[e for e in simplex] for simplex in triang] for triang in triangs]
return Polymake.to_one_based_indexing(result)
end


Expand All @@ -112,13 +104,9 @@ julia> c = cube(2,0,1)
A polyhedron in ambient dimension 2
julia> regular_triangulations(c)
pm::Array<pm::Array<pm::Set<long, pm::operations::cmp>>>
<{0 1 2}
{1 2 3}
>
<{0 1 3}
{0 2 3}
>
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 3, 4], [1, 2, 4]]
```
"""
regular_triangulations(P::Polyhedron) = regular_triangulations(point_matrix(vertices(P)))
Expand Down

0 comments on commit 36ec94f

Please sign in to comment.