The Pyramid immutable in GeometryTypes.jl


#1

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

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.


#2

My process for figuring this out was:

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.


#3

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.


#4

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.


#5

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.

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

  A rectangle in 3D space.

#6

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


#7

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