# The Pyramid immutable in GeometryTypes.jl

**URL:** <https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885>\
**Category:** Visualization\
**Created:** [May 23, 2017, 8:25pm UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885 "2017-05-23T20:25:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [May 23, 2017, 8:25pm UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/1 "2017-05-23T20:25:44Z")

</div>

I was going through types.jl from the GeometryTypes module, and I found the following is the definition of the Pyramid immutable:

```julia
immutable Pyramid{T} <: GeometryPrimitive{3, T}
    middle::Point{3, T}
    length::T
    width ::T
end

```

This was the only test example using Pyramid in the test folder:

`@test Pyramid(Point(0,0,0),1,2) == Pyramid{Int}(Point{3,Int}((0,0,0)),1,2)`

Can someone help me figure out what ‘middle’ refers to, assuming length and width refer to the base’s length and width? Also there seems to be no restriction for T to be a Number, so does that mean it can be an arbitrary vector in 3D without violating any other function’s assumption of length and width? If so, I assume the vectors can have any angle between them. Someone please let me know if I am missing a thing or two. Thank you.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [May 23, 2017, 8:49pm UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/2 "2017-05-23T20:49:27Z")

</div>

My process for figuring this out was:

```julia
unique(decompose(Point{3, Float64}, Pyramid(Point(0., 0, 0), 3.0, 4.0)))
5-element Array{FixedSizeArrays.Point{3,Float64},1}:
 Point(0.0,0.0,3.0)
 Point(2.0,-2.0,0.0)
 Point(2.0,2.0,0.0)
 Point(-2.0,2.0,0.0)
 Point(-2.0,-2.0,0.0)

```

`decompose(Point, p)` will decompose the geometry `p` into a list of points, which in this case are the vertices of the pyramid. You can see from that result that `length` is the height of the pyramid and `width` is the width of the (square) base. The `middle` appears to be the center of the base.

`T` is the scalar type of the pyramid, so it should be a scalar not a vector. The definition you quoted above doesn’t specifically enforce this, but non-scalar `T` will probably cause errors somewhere.

> I assume the vectors can have any angle between them.

Sorry, I don’t know what you mean by this.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [May 23, 2017, 8:53pm UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/3 "2017-05-23T20:53:49Z")

</div>

Thank you for your comment.

The angle comment was assuming length and width can be any vectors in space. Nevermind though, the process is more important.

---

<div class="post-metadata">

**Author:** ![Loic\_Chappaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loic_chappaz/32/1121_2.png) [@Loic\_Chappaz](https://discourse.julialang.org/u/Loic_Chappaz)\
**Post date:** [June 6, 2017, 10:17pm UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/4 "2017-06-06T22:17:49Z")

</div>

I had the same issue and I concur that middle is the center of the base. Not sure why this is the adopted nomenclature as it is in mind not-intuitive.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [June 7, 2017, 1:48am UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/5 "2017-06-07T01:48:38Z")

</div>

I think there is a problem with a number of primitive types in GeometryTypes. For example, Quad is supposed to stand for quadrilateral, but can only represent parallelograms in 3D space, and the help says it is a rectangle in 3D space!!! That is some severe inconsistency.

```julia
help?> Quad
search: Quad quadgk GLQuad quantile quantile! isequal sequential_palette

  A rectangle in 3D space.

```

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [June 7, 2017, 9:35am UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/6 "2017-06-07T09:35:44Z")

</div>

The fastest way to get this fixed is to open a PR to update the docs. We’d be thrilled to have your help.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [June 7, 2017, 9:41am UTC](https://discourse.julialang.org/t/the-pyramid-immutable-in-geometrytypes-jl/3885/7 "2017-06-07T09:41:26Z")

</div>

I will be glad to help when I start integrating the module I am working on now with GeometryTypes and GLVisualize.
