Gg and algorithms for 3d computation

I see that the gg package has some support for quaternions and 3d rotation matrices. I’m working to put together some code to work with these, and also Euler-angle rotations. I wondered if there’s a good source for a … “mechanical” explanation of the various conversions among these types – specifically Euler-angle <-> either rotation-matrix or quaternion ? that is to say, sure I ca work thru all the math, but really, this is just a tiny step in a much longer path, and I’d like to just get past this as quickly as I can, so I can get to the “main event” (so to speak).

Anybody have any good pointers?

1 Like

Not exactly sure what you are asking for but:

The translations to/from euler angles is provided in the respective modules, e.g. for quaternions here and here.

Regarding quaternions, just use them either as a compact way to to store orientations or as a magical device if you need to interpolate between orientations and avoid the problems you get in doing so on euler angles (like losing of a degree of liberty, a.k.a gimbal lock).

If you really want an intuition about quaternions then I suggest looking into geometrical algebra (a.k.a clifford algebra) where all the magic suddenly takes beautiful geometric intuitions. This website has information about geometrical algebra more oriented towards practitioners.

3 Likes

Not really what you asked, but I thought I’d shamelessly plug OCADml (available on opam) which provides tools for working in 3d also, and might get you closer to your main event. It’s pretty focused on paths and mesh generation since it was originally part of my OpenSCAD DSL efforts before I decided I should break it out to allow for other CAD backends (working on C and OCaml bindings for the Manifold library currently).

I do regret the duplication that exists vs @dbuenzli 's Gg, and I saw recently that he’s now adding 2d booleans in one of the companion libraries which I’m tempted to depend on despite the type conversions that I’d have to eat (not that they’d be expensive compared to the operations themselves).

2 Likes

I’m looking to cover to other Euler-angle representations, e.g. Z-X-Z. This is all for quantum computing, and I’m … a newbie there, so still feeling along blindfolded. I am using gg, and it’s very nice, btw.

There used to be a tutorial on IBM’s quantum computing website which went through some of the theory, and allowed you to build quantum circuits in their simulator and run it on their 5,7-bit quantum computer for free (there are paid tiers for more qubits). It didn’t go too deeply into the theory, but I think there was enough there to understand the basic concepts.
It all worked from a browser, there are now various IDE extensions you can install as well, but be careful what you install, in the past one of the quantum extensions for VScode got some malware shipped due to an infected npm package. These days there are some opam packages for QASM and qiskit support too, I haven’t tried using them.

If you are new to quantum computing I’d suggest to try out some of the existing documentation and code (whether in OCaml or another language first), and once you have an intuitive understanding of how all the algebra works you can attempt to write some OCaml code to simulate or build quantum circuits.

Heh, I worked at IBM in their QC unit for 5mos. Quit b/c while the “learn QC” part was fine, the “do some work to pay the bills” part involved using IBM Cloud, which … well, I spent 19yr at IBM and learned a fine, fine contempt for all IBM software and services, internal support being the worst. Truly Mordac the Denier. But I digress: I’m trying to build a quantum circuit transpiler, and while most of that doesn’t require knowledge of the linear algebra and quantum mechanics, some part of it does. And so I’m working thru one of the bits that does require that knowledge, is all.

I eventually did find what I needed: there’s a techreport by Henderson ( https://ntrs.nasa.gov/api/citations/19770019231/downloads/19770019231.pdf ) that lays it all out.

1 Like