Projects

News about projects

A new project published - the 4D Labyrinth

I published another one of my projects today. I mentioned in the title that it is new, but that's not entirely true.

The history

The 4D Labyrinth is a program that I initially wrote about 10 years ago. My high-school friend had then an idea that a 4-dimensional shooter game could be quite funny. In his vision, the world would be 4-dimensional, but out of the 4 coordinates only 3 would be chosen to render a 3-dimensional scene. The player could change this set of coordinates at any moment, leading to strange situation like a 2-dimensional slice of another player moving towards you, briefly becoming 3-dimensional (as he would temporarily "jump" into the same space), kills you and becomes flat again. I decided to create a proof-of-concept of something like that, but I resolved to use continuous rotations of the visible slice instead of discrete coordinate set switching.

(more…)

Making fun with Ithkuil easier

During the last few days I've been improving a tool I created a long time ago, which was supposed to make it easier to have fun with Ithkuil. But let's start at the beginning

Ithkuil

Ithkuil is a constructed language created by John Quijada. Constructed languages (or "conlangs") are usually associated with children (I myself was creating my own languages when I was 10-12), but in this case you couldn't be further from the truth. Even though Ithkuil doesn't really have practical applications, I think it is unusually interesting.

Ithkuil emphasizes conveying as much information as possible, as concisely as possible. As a result, it has 45 consonants and 13 vowels, and almost every sound in a word carries a separate bit of information. How was this achieved?

In Ithkuil there are two main classes of words - formatives and adjuncts. Formatives function as nouns or verbs, adjuncts convey additional information about formatives and sometimes mimic the personal pronouns. Let's focus on formatives: each one consists of a root, which carries main information about the meaning of the word (like, for example, "oral sound"), which then can be inflected by over 20 different grammatical categories using numerous affixes. For example, the root for "oral sound" (-l-) can be inflected by adding "e-" in front -> "el-", making it "spoken utterance". To get the smallest possible word, we need another vowel and a consonant -> "elal". "a" marks the Oblique case, which is pretty neutral. "-l" on the other hand means that we are speaking of a single object, functioning as a separate whole, we mean it in its entirety and as a concrete object and not its mental representation. This way, "elal" can be translated just as "spoken utterance".

(more…)

Differential geometry in Rust

During the last few weeks I've been working on a library that would let the user do some differential-geometric calculations in Rust. By differential geometry I mean mostly the tensor calculus in curved spaces or space-times. I've already created something like that in C++, but I wanted to try and use some of the Rust features to create an improved version.

What could Rust do better?

The most convenient representation of tensors for doing calculations is in the form of arrays of numbers. The problem is that representing a tensor numerically requires choosing a coordinate system. Various operations, like for example addition of two tensors, only make sens when the tensors involved are expressed in the same coordinate system. The only possibility of enforcing this rule in C++ was to encode the coordinate system as a property of the tensor object and checking for compatibility in the operator code. This way any errors will be detected at runtime.

Ok, so the errors were detectable, so what could be done better? Well, for examples the tensors expressed in different coordinate systems could not only have a different value of some property, but be objects of different types. This way the error can be detected at compile time, before the program is even translated into an executable form. It wouldn't be very practical in C++, but the Rust type system allows to do it quite interestingly.
EDIT: It has been brought to my attention that C++'s templates also allow for this kind of thing. Nevertheless, doing it in Rust was a fun experiment :)

(more…)

Rust version has caught up to the C one

It took a while, but the Rust version of the code generating the positions of galaxies has finally reached the level of functionality of the C version. Meanwhile, I have gathered quite a bit of interesting experience, which I'm now going to share.

Rust vs other languages

Programming in Rust is nothing like programming in any other language I've had contact with (which means mainly the C family and Python). One remotely similar experience was experimenting with Haskell, but even that generally due to incompatibility between my intuition and the language (although Rust has many functional features, but as will be mentioned later, one shouldn't overuse them...).

(more…)

Progress of the Universe project

I made some progress in rewriting the Universe project in Rust during the last few days.

Before I started with the project itself, I had to make some preparations. The order of magnitude of the numbers appearing in the program caused the need for the GMP and MPFR libraries, allowing for calculations on arbitrarily big numbers. I also used the xxhash algorithm. The problem? All 3 pieces of code were written in C.

It's not actually that big of a problem, since one of the advantages of Rust is the ease of using it with C libraries. The only thing to do was to find or create modules (or, in Rust terms - crates) which would make it more straightforward, so I started searching.

I focused on GMP and MPFR first. There were 2 crates for GMP and one for MPFR, created by the author of one of the GMP crates. After having a look at them I decided that the GMP module without corresponding MPFR one is more straightforward to use, which left me with the task of writing my own crate for MPFR. Moreover, the GMP module was old and didn't even compile with the latest version of the language.

I started working. Fixing the GMP crate turned out to be tedious, but not very hard. Writing the MPFR module was similar, but needed a bit more work (like writing many similar functions that only served to call their C counterparts...). Both modules are available on GitHub (click, click). I created a pull request for the author of the GMP crate, but he turned out not to be interested in maintaining the project any longer.

Then it was time for xxhash. Here, like with GMP, a crate existed, but it didn't compile. A few hours of work later everything was fixed and the library worked.

So, now I have working dependencies for the project. I also started to rewrite the code of the project itself, but for now only a small part of it is done. More news about the project progress - (hopefully) soon.

Thoughts about light bending

I had a sudden moment of clarity recently when thinking about how to remove a graphical artifact from the Black Hole Simulator.

The problem

artifact

The current simulator has one ugly aspect of the rendered image. Exactly 90 degrees from the direction to the black hole a graphical artifact appears - a strip of smudged, incorrectly calculated pixels (see the picture to the right). The reason is hidden deeply in the rendering mechanism.

In short, it looks like this - you can't efficiently calculate the color of every pixel by raytracing. Taking advantage of the symmetry of the Schwarzschild black hole, I created a table of angles of light deflection. Thanks to the symmetry, I can describe each ray of light by only one parameter - simply put, the minimal distance from the black hole along its path (actually, the impact parameter). To calculate the deflection, I need one more thing, and that is the distance from the black hole at which I send/receive it - the greater part of the whole path the ray has to travel, the greater the deflection.

Such a table was being sent to the graphics card. Then, during rendering, a direction of the ray was calculated for each pixel, and this was converted into the impact parameter. The distance was known independently. Appropriate deflection was being read from the table and this was used to calculate the color of the pixel.

In theory everything is fine, but one problem appeared - the light rays sent in directions close to 90 degrees from the black hole have very similar impact parameters. This gives nearly identical deflection angles, which makes many pixels the same color. An ugly strip appears.

(more…)