# Mathematically applying quaternion, octonion, and other alternative algebras to objects (to transform them) using geometry nodes

Mathematically applying quaternion, octonion, and other alternative algebras to objects (to transform them) using geometry nodes. I'm trying to take different 4D meshes/objects that are generated mathematically and project them "down" from 4D space onto 3D space while making it interactive.

An example of what I'm very loosely trying to reproduce when changing values: Note: I'm trying to be mathematically accurate I'm not just trying to produce a visual effect, hence the calculations.

1. Calculate the points/vertices of a 4D object using quaternions, in this case a sphere (using geometry nodes) https://eater.net/quaternions https://eater.net/quaternions/video/rotation

2. Take a 4D sphere and project it into 3D space see example. I'm having issues with mathematically transforming the objects using geometry nodes. I'm not sure how to apply my quaternion calculations to the objects / vertices / edges / faces to create the transformation. I was thinking of using the set position node but it only has a spot for x,y,z, I seem to be missing a step

My ultimate goal is to make these interactive like https://eater.net/quaternions/video/rotation then 3D print these 3D objects that are projected from 4D space showing the various 4D projected stages of "rotation" in 3D.

I created the quaternion math nodes using geometry nodes from "scratch" to have full control over the calculations, This is because I would also like to test out octonions along with other alternative algebras. I'm testing / verifying the images using https://eater.net/quaternions/video/rotation. My question is how does one connect the geometry vertexes of the sphere (x,y,z) or any object and apply quaternion calculations using geometry nodes.

PS: I used ChatGPT to create the formula and WannesMalfait Math Formula free add-on to enter them video.

My attached Blender file is below.

• One way would be to create a volume, and set its density by sampling 4D object at same coordinates with the 4th coordinate $W$ being some arbitrary (iterated on each frame) constant. I won't write an answer because it would take quite some time to render an animation but here's the 3D version: blender.stackexchange.com/a/300876/60486 - the principle in 4D is the same, but frame/time becomes the 4th coordinate. Dec 17, 2023 at 20:51

You're on the right path of applying quaternion transformations to the sphere. The visual you referred to is a stereographic projection of the sphere where the sphere more naturally exists in $$\mathbb{R}^4$$. This projection down to $$\mathbb{R}^3$$ is what causes everything to distort and stretch out to infinity.

Technically, you have some $$S^2$$, which naturally exists in $$S^2 \subset S^3 \subset \mathbb{R}^4$$, and you want it to exist down in $$S^2 \subset S^3 \subseteq \mathbb{R}^3 \cup \{\infty\}$$, via stereographic projection of quaternion elements of $$S^3$$

After your quaternion multiply, feed the four coordinates into the stereographic projection function of which maps the quaternion points from the hypersphere, $$S^3$$, down to $$\mathbb{R}^3$$, defined as $$f(p_1, p_2, p_3, p_4) = (\dfrac{p_1}{1 - p_4}, \dfrac{p_2}{1 - p_4}, \dfrac{p_3}{1 - p_4})$$

I don't think you need to normalize the quaternions after the multiplication function because they are already normalized. You just need to project them instead.

You may also want to add a switch to delete the point that shoots off to a large distance. When the fed in angle is a multiple of $$180^\circ$$, you should end up with a flat plane. A sphere cannot be topologically the same as a plane unless you puncture it somewhere. I took a generic approach and delete the vertex of maximum distance from the origin during these cases. Going into the truncated modulos is the angle that's passed into geo nodes.

If you're interested in exploring the $$\mathbb{C}^2$$ Hopf Fibration interpretation, I made the following file:

A pair of complex vectors can define a 4-dimensional point similar to how a quaternion does.

• Thanks! Now to "wrap" my head around Octonions. I'm looking forward to trying your Hopf file. Dec 21, 2023 at 4:41