JuliaPolyhedra / Polyhedra.jl

Polyhedral Computation Interface
Other
172 stars 27 forks source link

Rotation of Polyhedra #245

Open anicusan opened 3 years ago

anicusan commented 3 years ago

The translate function is extremely useful for a moving object; would it also be possible to implement a rotate(p::Polyhedron, r) function, receiving a N x N rotation matrix r, where N is the dimensionality of the Polyhedron? For example, the V-representation would be quite easy to modify - just compute the dot product of the rotation matrix and each vertex.

I am willing to contribute this function myself if a more experienced Polyhedra.jl developer could give me some directions. Specfically, my mathematical background is rather different from geometric sets, so I am not entirely sure how to change the H-representation.

blegat commented 3 years ago

If r is a matrix, you can just do r * p. This will use the V-representation. I don't know of any way to get the linear image of a H-representation if the matrix is not invertible. If the matrix is invertible, you can do inv(r) \ p which uses the H-representation.