# Why are vertices of every LazySets.VPolygon or VPolytope given as 1 D Array and not based on the shape of the object?

**URL:** https://discourse.julialang.org/t/why-are-vertices-of-every-lazysets-vpolygon-or-vpolytope-given-as-1-d-array-and-not-based-on-the-shape-of-the-object/52719
**Category:** Visualization
**Created:** [January 2, 2021, 1:23am UTC](https://discourse.julialang.org/t/why-are-vertices-of-every-lazysets-vpolygon-or-vpolytope-given-as-1-d-array-and-not-based-on-the-shape-of-the-object/52719 "2021-01-02T01:23:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adropintheriver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adropintheriver/32/20634_2.png) [@adropintheriver](https://discourse.julialang.org/u/adropintheriver)
#### Post date: [January 2, 2021, 1:23am UTC](https://discourse.julialang.org/t/why-are-vertices-of-every-lazysets-vpolygon-or-vpolytope-given-as-1-d-array-and-not-based-on-the-shape-of-the-object/52719/1 "2021-01-02T01:23:24Z")

</div>

```julia
A = rand(HPolyhedron,dim=3)
Av = tovrep(A)
Av.vertices

```

gives an 11-element Array{Array{Float64,1},1} and not a 3 Dimensional array of 11 elements, also how can i convert these vertices to BasicGeometry.Point3d without using a loop?

---

<div class="post-metadata">

### Author: ![mforets](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mforets/32/298_2.png) [@mforets](https://discourse.julialang.org/u/mforets)
#### Post date: [January 11, 2021, 5:49pm UTC](https://discourse.julialang.org/t/why-are-vertices-of-every-lazysets-vpolygon-or-vpolytope-given-as-1-d-array-and-not-based-on-the-shape-of-the-object/52719/2 "2021-01-11T17:49:32Z")

</div>

Hi @adropintheriver,

> Why are vertices […] given as 1 D Array and not based on the shape of the object?

I guess because it is simple to reason about a polytope described in vertex representation as a one-dimensional array of “vertices”. In LazySets there is a type `VPolygon` to deal with the two-dimensional case, which is special in many ways (e.g. lots of very efficient algorithms exist only for the 2D case). I don’t think there would be a practical benefit of adding the dimension as part of the type. (Please note that you can always instantiate such sets using statically sized arrays from `StaticArrays`, which _do_ know the “shape” of the object in advance hence can benefit from lower-level optimizations.)

About the question on the shape, an array-of-arrays can be reshaped into a single array in different ways, e.g.

```julia
julia> using LazySets

julia> V = rand(VPolytope, dim=3);

julia> typeof(V)
VPolytope{Float64,Array{Float64,1}}

julia> vlist = vertices_list(V); # array of arrays

julia> typeof(vlist)
Array{Array{Float64,1},1}

julia> length(vlist) # number of vertices
12

julia> R = reduce(hcat, vlist)
3×12 Array{Float64,2}:
...

```

About the question on the package [GeometryBasics.jl](https://github.com/JuliaGeometry/GeometryBasics.jl), evaluating `GeometryBasics.Point3` on each vertex should do it? (Why wouldn’t you use a loop?).

```julia
julia> P = [Point3(x) for x in vlist]
12-element Array{Point{3,Float64},1}:
...

```

Hope this helps.
