Geometry from Another Universe

47
Geometry from Another Universe

Post by James Cook [home]

January 17, 2022

In which I show you a demo I had a lot of fun making.

If you follow this link, you’ll be taken to an unusual house.

You start on an enclosed lawn, surrounded by four walls with a doorway in one of them.
If you go in and explore, you might begin to feel trapped.
You’ll find you can visit five different rooms in the house, or go back outside to the lawn, but there’s no way to go anywhere else.
It’s not because there are walls stopping you from leaving.
The house, and the little yard, are the whole universe.
There’s nothing else.
If you keep going forward long enough, you end up back where you started.
(Try to find a clear path in the house where you can do this without running into a wall.)

Some other things to notice:

  • Objects in the distance seem to get smaller and then bigger again as you approach.
    The floor seems to curve upward, but every line you see is perfectly straight.
    If you press the “Go down” button until you’re below the floor, the floor seems to curve downward instead.
  • The lines on the floor appear parallel in some rooms, but in other rooms, you can see that they radiate out of one spot on the floor and then meet at another.
    They are all perfectly straight.
  • If you make three right turns, you’ll end up back in the room you started in.

What’s going on?

This house exists in a geometric world called a 3-sphere, which is higher-dimensional version of a sphere (aka 2-sphere).
It’s easiest to explain with an analogy.
Suppose you took a two-dimensional person from a two-dimensional universe and put them on the surface of a sphere.







Everything in this new universe is confined to the sphere, including light.
This flatlander would experience many of the same things you did in the 3-sphere house:

  • A collection of straight lines radiating out of one point will meet again at the opposite point.
    Lines of longitude behave this way: they meet at both the poles.
    A “straight line” in this universe means a line that splits the sphere exactly in half, like the Earth’s equator, or a line of longitude.
  • Because of that, and because light follows straight lines, an object that’s as far away from you as possible — at the opposite point of the sphere — will fill your whole field of view.
    If you move closer to it, it will become smaller, taking up less and less of your field of view, until it’s halfway around the sphere from you, and then it will get bigger and bigger until you’re right next to it.
  • If you wanted to, you could draw lines to separate the surface of the sphere into six cells, like the faces of a cube.
    Our flatlander would find that even though each room seems square-shaped, they can get back where they started by taking three right turns.

The 3-sphere you’re exploring is a three-dimensional analogue to the 2-sphere we put the flatlander into.
The rooms are arranged as the faces of a cube.
The floor, although perfectly flat, has the geometry of a 2-sphere, which allows the lines painted on it to meet at two points, like lines of longitude.

Some Coordinates

If you’re familiar with the definition of a 3-sphere as 4-D points (x,y,z,w) with magnitude 1, the six rooms of the house are each centred on one of the axes: the yard is at (0,0,-1,0), the next room is at (0,0,0,1), and the next room forward is centred at (0,0,1,0). The floor is the plane y=0, the point (0,1,0,0) sits directly above all of the rooms, and if you check “hide floor” and look straight down, the red box you see is at (0,-1,0,0).

What this is not

The inside of a ball

It may seem like you’re just walking on the inside of a big balloon with stripes drawn on it.
That’s close to the truth, but there are a couple of differences:

  • It doesn’t explain how objects sometimes get smaller as you get closer.
  • If you press “Go down” until you’re below the floor, the floor will appear to curve the other way.
    It’s as if the floor splits the universe into two balls.

A torus

A torus is another shape which wraps around: if you keep going far enough, you’ll get back where you started.

The 3-sphere is different from a torus, though.
Here’s one way to see.
Go and look for a place in the house where you can walk forward forever without running into a wall.
If you were to draw a line on the floor while you did that (there’s an idea for a feature…), that line would split the house into two parts.
Each part would have one room (or the yard) at its centre, and there would be no way to walk from one part to the other without crossing the line you drew.
If you tried the same thing on the torus, the floor would still be in one piece.

Why did you make this?

I’ve been interested in non-Euclidean geometry for a long time.
I wanted to get some intuition for it, and I think the best way is to put myself inside and explore.

WebGL has no problem with non-Euclidean geometry

This is done using WebGL, an API for drawing 3D graphics in a browser.
You might think it’s only designed to draw ordinary, Euclidean things, but it turns out it’s perfectly suited to rendering this world as well.
WebGL (and OpenGL) works with four-dimensional coordinates (x,y,z,w).
Normally, you’ll be advised to just set that w coordinate to 1 all the time.
If you do that, the x, y and z coordinates will behave like ordinary 3-D geometry.
I just ignored that rule and used the coordinates to represent points on the 3-sphere instead.
It all works out.
(You have to be a bit careful if you want to put textures on things without seeing seams between the triangles, but it can be done. The key is to make sure every flat surface is still a flat surface in 4-D.)

Source, including a constructive solid geometry library

Here’s a link the the source code.
It’s written in Idris2, an experimental language with a powerful type system, and uses the idris2-dom library to interact with your browser.
I had a lot of fun with it, but spent a lot of time learning to appease the typechecker, and also had to submit some patches in order to get my demo to run without overflowing the stack.

The code actually includes a constructive solid geometry library, in the src/SolidGeometry directory.
I used it to build the walls (a big block minus smaller blocks for the doors and windows) and some of the furniture around the house.
It doesn’t always work, and it’s quite slow, and if you read the code while knowing anything about computational geometry, I can only assume you’ll quickly realize I made it up as I went along.
But I had fun making it!
The input is a bunch of planes which split the world into cells, and a rule saying which cells are “inside” or “outside”; and the output is a bunch of triangles separating inside from outside.

Stuff I’d like to do if I have time

  • It turns out it’s posible to embed a torus in the 3-sphere so that the inside and outside of the torus are exactly the same shape.
    It would be fun to explore that.
    (An earlier version of this project that I made a long time ago has that, but it doesn’t run in a web browser.)
  • I’d like to make a game that takes place in this universe. Ideas welcome!

See also

  • Hyperrogue. A game played on the hyperbolic plane, which is in a sense the opposite of a sphere.
  • Hyperbolic text. Has lots of links. I think I found it via the Dragonfly BSD Digest.
  • Non-Euclidean Worlds Engine.
    This one stitches together flat Euclidean geometry instead of making the whole universe curved.





NOW WITH OVER +8500 USERS. people can Join Knowasiak for free. Sign up on Knowasiak.com
Read More

Vanic
WRITTEN BY

Vanic

“Simplicity, patience, compassion.
These three are your greatest treasures.
Simple in actions and thoughts, you return to the source of being.
Patient with both friends and enemies,
you accord with the way things are.
Compassionate toward yourself,
you reconcile all beings in the world.”
― Lao Tzu, Tao Te Ching