Mesh / GeometryBasics Rotate function

I would have thought I could find this easier.
I have loaded up and OBJ file with FileIO/MeshIO and am able to plot it in Makie with mesh.
Is there a function already that will allow me to apply translations and rotations to the mesh as an object either by multiplying by a rotation matrix or a quaterion?

I would have thought this existed, but haven’t found it yet. About to make one for my purposes, but thought I would check.

Best Regards,
Allan Baker

3 Likes

This is something you could try with Grassmann.jl, where you can import a GeometryBasics.Mesh and manipulate it with the multivector generalization of quaternions (geometric algebra). It also specifically has Makie plotting compatibility for meshes. The design is still a work in progrees and not documented, but a mesh rotation feature would be interesting to do with it.

I was able to implement one fairly easily with my home grown quarternion class’s rotate function it was fairly simple once I realized the “coordinates” function on the mesh object dumped an array of points that just needed to be rotated or translated and then the whole things is the first argument to the Mesh constructor with the “faces” function on the original function as the second argument. There may be a little more to catch attributes but I don’t think my mesh OBJ has any attributes.

Makie offers a rotate! and a translate! function on a Scene that takes a quaternion. Does that not work?

2 Likes

I think there was talk of more fully implementing CoordinateTransformations.jl at one point directly in GeometryBasics.jl. It would be pretty trivial to do.