What practical choices do I have in order to rotate a camera in 4D space? I would like to make it as intuitive as possible.

A camera in 3D space can be represented by

  • a point where it is located
  • the forward vector (movement using the [w] and [s] buttons)
  • the left (movement using the [a] and [d] buttons)
  • the up vector (eg. [space] and [ctrl])

In 4D space, the an additional axis is added:

  • the fourth axis vector (eg. [q] and [e])

All of the vectors remain orthogonal to eachother. So the movement is trivial.

  • \$\begingroup\$ what exactly do you mean by camera in 4D space? Its going to visualize time or did you mean 3D ? \$\endgroup\$ – Uri Popov Aug 21 '16 at 10:14
  • \$\begingroup\$ Not time, but an additional spacial dimension. \$\endgroup\$ – Limeth Aug 21 '16 at 10:22
  • \$\begingroup\$ @UriPopov Updated the question with an explanation. \$\endgroup\$ – Limeth Aug 21 '16 at 10:29
  • \$\begingroup\$ do you mean tilting the camera like for example looking around a corner ? \$\endgroup\$ – Uri Popov Aug 21 '16 at 10:31
  • \$\begingroup\$ No, I literally mean rotation in 4D space. \$\endgroup\$ – Limeth Aug 21 '16 at 10:47

First of all you have to understand some basics. Rotations are usually given around some axis, but thinking like this wont help here. Rather you should think of a rotation happening on a plane. 2 and 3 dimensions are easy to visualize and the fourth one you should get use to with some time. So in 2D there is one plane of rotation, 3D there's 3 and in 4D there is 6.

If we label the axises x, y, z and w the planes of rotations could be labeled as xy, xz, xw, yz, yw and zw. Id recommend using 5 or 6 buttons. 4 for defing a plane (combination of 2 buttons) and 2 for choosing rotation direction or 1 for simply reversing the direction. This is the most intuitive interface I can think of.

For how to apply these rotations In linear algebra, a rotation matrix is a matrix that is used to perform a rotation in Euclidean space. For example the matrix

       |  cos(θ)   -sin(θ)     0    0 |
       |  sin(θ)    cos(θ)     0    0 |
       |       0         0     1    0 |
       |       0         0     0    1 |

rotates points in the xy plane counter-clockwise through an angle θ about the origin of the coordinate system. You can reverse the direction by changing the sign of the sine functions.

For the other planes:

        | 1         0          0    0 |
        | 0    cos(θ)    -sin(θ)    0 |
        | 0    sin(θ)     cos(θ)    0 |
        | 0         0          0    1 |

        | 1    0         0          0 |
        | 0    1         0          0 |
        | 0    0    cos(θ)    -sin(θ) |
        | 0    0    sin(θ)     cos(θ) |

        |  cos(θ)    0    0    sin(θ) |
        |       0    1    0         0 |
        |       0    0    1         0 |
        | -sin(θ)    0    0    cos(θ) |

        | cos(θ)    0    -sin(θ)    0 |
        |      0    1          0    0 |
        | sin(θ)    0     cos(θ)    0 |
        |      0    0          0    1 |

        | 1         0    0          0 |
        | 0    cos(θ)    0    -sin(θ) |
        | 0         0    1          0 |
        | 0    sin(θ)    0     cos(θ) |

I am not certain if the last two rotations are what you could call counter-clockwise, but that does not really carry any meaning as far as I understand(because there are no cross-products in 4 dimensions).

Now that we can rotate objects we need a way to collapse it into a nice 2D picture. For this we won't look at the w component and proceed as if everything was regular 3D. Now there are two things you can actually do with the w component. You can just leave it be and do nothing with it or you can assign a w value to your view frustums near and far plane and only render coordinates in between effectively taking a slice of that dimension(more realistic). I'd also suggest using transparency for better conveying the w dimension (make objects that are between the w dimension clipping values more opaque than those at the edges).

Now the best practice would be to leave the camera at the origin and only translate and rotate the objects. (This can be inferred from what I've established previously)

P.S. I am quite interested about what you intend to do. Do you mind telling me?

  • \$\begingroup\$ Thank you very much for such an extensive answer! It has definetly pushed me forward. As for what I am intending to do with it; I am writing a non-euclidean ray tracer prototype, I built it with the intention to add n-dimensional universes and now I am at the stage where I just have to implement the camera movement. Cheers! \$\endgroup\$ – Limeth Aug 21 '16 at 19:16
  • \$\begingroup\$ The logic provided here can be applied for n-dimensions. I really like what you are doing and if you want you can add me to a chat room if you have any questions. I am a physics student and game development is currently my hobby. I have, for the lack of a more accurate expression, half-assedly made a game engine. \$\endgroup\$ – Andreas Aug 21 '16 at 20:31
  • \$\begingroup\$ I've created the chatroom, feel free to join. I'm not sure how often I will be there, since I use stackexchange sites (and similar) almost only when I'm looking for answers. If you'd like to contact me in another way too, you can reach me at the #rust channel on moznet, I have the same username. \$\endgroup\$ – Limeth Aug 21 '16 at 21:49
  • \$\begingroup\$ I created another question at math.stackexchange.com. \$\endgroup\$ – Limeth Aug 26 '16 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.