RSSAmplifier

Blog

Guillaume Chereau Website

Recent content on Guillaume Chereau Website

gcher.comRSS feed ↗49 posts

Latest posts

How did John von Neumann solved the fly and bicycles puzzle?

This famous puzzle goes like this: Two bicycles are traveling toward each other at the same speed until they collide; Meanwhile a fly is traveling back and forth between them, also at a constant speed. The bicycles start 20 miles apart, and travel at 10 miles per hour, and the fly travels at 15 miles per hour. How far does the fly travel in total? If you don’t know this puzzle I suggest that…

Would you accept to have an AI manager?

In the not so distant future, we might have AIs intelligent enough to replace managers in companies. I imagine a company having an AI agent, complete with a personalized avatar, voice, and personality. This AI would be able to perform daily video call with employees and CEOs, oversee projects progress, write emails, make suggestions, etc. I feel like this could actually happen before AI just…

BASIC was not just a programming language

BASIC is often dismissed as an inferior language compared to its successors. Common complaints are its use of line numbers, its heavy reliance on GOTO for execution flow, and its lack of a stack for local variables. What many critics overlook is that at the time of its use (during the first wave of home computers), BASIC was not just a programming language; it was a full development environment,…

Abel's theorem

The Abel-Ruffini theorem states that there is no solution to the general polynomial equation of degree five (quintic equation) that can be expressed with the common operations: (+, -, x, %), plus √ (radical of any degree). In this post I’ll try to give my quick understanding of the proof, without explicitly relying on group theory or Riemann surface. As usual on this blog, this is all hand…

Some command line tools I use

In this post I am going to present a few of my favorite command line tools that might be of interest to programmers who prefer to work directly from the terminal. (Note: since I didn’t want to put screenshots or html, I removed the colors from the examples. Most of those tools actually make use of ANSI escaping to colorize their outputs) ag – The Silver Searcher $ ag LookAdjust…

Auto function binding in C

Let say you want to add some script support to a C program, like lua or maybe even something simpler where all you can do is call a function with some given arguments: #include <stdio.h> void my_func(int x, const char *s) { printf('my_func called with x=%d, s=%s\n', x, s); } int main() { // Will call my_func with 2 and 'hello'. script_call('my_func', 2, 'hello''); } Since C does not support…

The Circles of Hell of C Libraries Integration

There is spectrum on how easy it is to integrate a C (or C++ for that matter) library into a project. The issue is that the C ecosystem does not have a standard dependency manager, so each project big enough to require the use of external libraries needs to find a way to integrate them, and it is usually a significant source of problem just to get them to compile. Note that I am not even talking…

My Solution to the Newcomb Paradox

The Newcomb paradox is stated as a fictional situation where a player enters a room with two opaque boxes, A and B. A always contains a small amount of money (let say $100), and B contains either nothing, either a larger amount of money (let say $110) 1. The player gets to pick one or both boxes and leave the room with them. The catch is that before the player enters the room, an &lsquo;all…

Why I don&#39;t like C23 &#34;auto&#34; keyword

The next version of the C standard (C23) brings two new features that I am not enthusiastic about. One of them is the nullptr constant, the other one is the &ldquo;new&rdquo; auto keyword1. I will try to explain why I don&rsquo;t like it. The new proposed auto keyword will work basically like in C++. You will for example be able to write: auto x = 10; auto ret = function(); Instead of:

Python Simulation of the Blue Eyes Island Puzzle

The blue eyes island is a tricky logic puzzle that has several variations. The one I was first told was: A group of people live in an island with no contact with the outside world. Eyes color is big taboo for them and they strictly follow this rule: if anybody figures out the color of their own eyes, they will commit suicide the following night. Everybody knows the eyes color of all the other…

An Intuitive Explanation of Quantum Field Theory

This post will be my attempt to explain intuitively what is Quantum Field Theory. This idea came to me after reading two books: &ldquo;QED: The Strange Theory of Light and Matter&rdquo; by Richard Feynman, and &ldquo;Quantum Field Theory in a Nutshell&rdquo;, by A. Zee (that I only started). Both books use path integrals, but in a very different way: Feynman tells us that the particles can move…

C&#43;&#43; is not cross platform anymore

As of 2019, C and C++ are the only programming languages that are supported by virtually any platforms on the market. For example both iOS and android support compiling C and C++ directly as part of their official IDEs. This is one of the reason why I decided to write my voxel editor Goxel in C99: I wanted to be able to run it on Linux, Mac, Windows, iOS, and now I am working on a Android port as…

Lua vs Duktape for embedded scripting language

I recently started to see how to integrate a generic script language into my voxel editor Goxel. I want to use something light and easily embeddable into a C application. One obvious choice for this is to use Lua, but I also wanted to try Duktape, a lightweight JavaScript interpreter. In this post I&rsquo;ll give some of my conclusions after trying both. 1. SIMPLICITY TO EMBED Both Lua and Duktape…

Creating application icons with inkscape

Yesterday I tried to improve the style of my voxel editor goxel. One thing I wanted to do in particual is have better looking icons in the UI. The current icons looked like that on my non retina screen: This is what I came up with: It&rsquo;s interesting to work on art for computer screen because for such small size images, the pixels aliasing quality becomes primordial. For example in goxel on a…

Porting Goxel to iOS

I just made the first release of my voxel editor project goxel for iOS, and I wanted to write a bit about the process. It&rsquo;s not the first time I work on a mobile port of C/C++ application, so the process was quite easy. The only new challenge this time is that I used swift on the platform code (instead of objective-C). The global structure of the code consists of a core written in C (or…

Generating the dodecahedron rotation group with python

I was wondering how to compute the rotations for all the faces of the regular dodecahedron (polyhedron with 12 faces). You can find many resources online about the symmetry group of the dodecahedron, but not much practical information about how you would use it in you code, this is specially annoying for non mathematicians like me who don&rsquo;t want to go too far down the rabbit hole of group…

Goxel Voxel Editor Internals - Part 2: voxel data structure

In this second part of my series about goxel voxel editor internals, I will talk about the way voxel data is stored in memory. As usual, all the code is open source and accessible on the github repo. The voxel models are composed of many individual voxel, each of them having a color. For the structure of the voxel I wanted: Optimized memory usage: if a model is large but composed of few voxels I…

Goxel Voxel Editor Internals - Part 1: voxels and pixels

This is the first in a series of posts I want to write about the technical aspect of writing a voxel engine / editor. I wrote a free and open source voxel editor available on github, and I wanted to share the things I learned in the process. Today&rsquo;s post is just an introduction, where I am going to talk about the evolution of computer graphics and the advent of voxels.

Introducing Noctua Sky

I just released Noctua Sky, a new project I am working on. This is an online planetarium (or sky map) software similar to the open source project Stellarium made by my brother. The goal of the project is ultimately to provide a set of tools and API for amateur astronomers to share their observations online. The first step toward this is to create a JavaScript planetarium that can run directly on…

Swift vs C&#43;&#43;: lambda functions

Recently I got interested in the new Apple language Swift, that will probably replace objective-c as the language of choice for native iOS and OSX applications. There are many things I like in Swift, and also other things I don&rsquo;t like. But one thing that I really enjoy is the support for lambdas, specially compared to the way it works in C++. Why do I think the lambdas in swift are better?

Hacking Doom code for transparent POV display

Doom (the original version), is not only one of the best game ever made, but it&rsquo;s also a great example of C code. Thanks to id Software decision to release the code as open source in 1999, anybody can have a look and modify it. I had this project of changing the rendering of doom, to add a border effect to the walls, or cel shading. You can check the video at the end of this post to see why…

Unit Tests in C with the constructor attribute

In one of my project, I used GNU constructor attribute to add some simple unit tests to any C file. I liked this approach, but I don&rsquo;t see many open source projects using anything similar, so I though I&rsquo;ll describe it here. Here is an example of a C file containing a function: ... // Test if a string ends with an other string. // If any of the string if NULL, return false.

Keeping notes in unformatted text files

For years I have been looking for the best way to keep organized notes on my computer(s). I tried a lot of different approaches, from web based tools to emacs org mode and desktop wiki. Now I think I can say that I found the best way (for my personal case) to do it: I keep all my notes as unformatted text files, in a single flat directory. Here is how it works: I have a directory Notes in my…

Goxel 0.3 Released

I just released the version 0.3.0 of my open source voxel editor Goxel. This release brings: Import/Export support for the popular editor Magica Voxel. Render shadows. Better shapes support, specially when we use marching cube rendering. Multiple palettes. Better UI, with new tools icons. Here is a video of the laser tool:

OpenCV Camera to OpenGL Projection

I am sure some people are hitting their heads trying to solve this simple problem when doing augmented reality with OpenCV and OpenGL: How to get the proper OpenGL projection matrix from the OpenCV camera calibration values? For the simple common case where the OpenCV camera matrix has the form: |fx 0 cx| |0 fy cy| |0 0 1| The corresponding OpenGL projection matrix can be computed like this:

Goxel 3D procedural rendering

In this post I introduce a new experimental feature I am adding to goxel: procedural voxel generation. For this I created a mini language specifically designed to describe drawing operations. Think of it as the logo language, but in 3D. Note: this is still experimental at this point, so anything in the language could change in the future. I will try to keep this page up to date as a reference…

Lambda expressions in C

C does not have built-in support for lambda expressions, but if you are using gcc, it is actually quite easy to implement them using a simple macro. This trick relies on two C extensions: nested functions and statement expressions. Both are available in gcc (but not in clang!) Here is a small program that could benefit from lambda expressions, written in conventional C: // A function taking a…

How I made my parallel self win the lottery

While I was in France recently I decided to make one of my parallel self a millionaire. It&rsquo;s very easy and you too can do it if you want. How to do it? First you have to check how the national lottery of the country where you are works. In France, a lotto ticket costs 2 euro, you have to pick five different numbers from 1 to 49 (included), and one &rsquo;lucky&rsquo; number from 1 to 10…

Goxel, an open source 3D voxel editor

Goxel is a new project I have been working on since last month. It&rsquo;s an open source 3D editor to create voxel images (in the style of minecraft, or crossy road). It works on Linux and Windows. Features: 24 bits RGB colors. Unlimited scene size. Unlimited undo buffer. Layers. Smooth rendering mode. Export to obj and pyl.

Voxel Snake 3D

I just released a small game on google play: Voxel Snake 3D. This is basically a snake game played on a 3D cube, using voxel rendering. Let me know what you think!

Blowfish Rescue 1.0 Released

Just a small post to announce the release of my new video game: Blowfish Rescue. This is a 2d action/puzzle game using a fluid simulation solver. Most of the graphics are procedurally generated. The game is available for free on google play and iTune. Here is a promo video I did: In the following week I will open source the procedural generation code, as I think this is an interesting part of the…

Procedural graphics generation in C

I introduce noc_turtle, a small MIT licence C library to create procedural graphics in plain C. I release it in the hope that some people will use it in their own project, and also to promote my video game Blowfish Rescue for which I wrote it. The library allows to write procedural rules directly in C, so it is very simple to embed it in a project and to mix it with custom code.

Comparison of Doom 1, Quake, and Doom 3 entity references system

The architecture of a video game code is usually based around a list of entities that represent all the game elements: players, enemies, etc. The engine iterates over this list and call the appropriate methods to update or render the entities. Since game elements get constantly created and destroyed, the list is not static but need to be updated at each iteration. The problem is that some entities…

10 C99 tricks

Here are ten interesting patterns and tricks I sometime use in my C code, some are well known, some not so much. I am sure all of them work with clang and gcc (after fixing the evetual typos). I didn&rsquo;t try with MSVC, but except for no 1 and 5, I think it should also work. [edit]: Here is a link to the hacker news thread. [edit]: Maybe the title is a bit misleading, this is not strictly about…

Procedural colors for video games

Recently I have been spending a lot of time thinking about how to use procedural colors in my -still unnamed- incoming video game. [edit]: The game is done now, it is called Blowfish Rescue, and you can play it for free on Android of iOS. This is a problem that I am sure many other indie game developers have been thinking about, and there are not so many resources about it online, so I though I…

Named parameters in C

C99 introduced the concept of designated initializers, that allows to initialize a structure using the name of the fields, like this: struct MyStruct {int x; float y;}; struct MyStruct a = { .x = 10, .y = 3.6, }; Here is a C macro that extends this syntax to function calls. I present it as a curiosity, and I really wouldn&rsquo;t advise anybody to actually use it in a project (except maybe for…

C&#43;&#43; patterns using plain C

So that&rsquo;s it, you read this article, and this post, and this, and this, and you spent too many time trying to debug 8 pages long compilation error messages, and you also spent hours trying to follow your code path involving operator overloading, copy constructors, and virtual class methods called from constructors or whatnot. You have had enough of it. Yout think it&rsquo;s time for you to…

Automatic object factory in C&#43;&#43;

Unlike other object oriented languages like java, C++ does not have much support for introspection. So for example it is not possible to request the list of subclasses of a given class. In this post I am going to talk about a little trick that I found very useful when dealing with a lot of subclasses of a single base class. This is typically what we see in video game, where we have a base Object…

How our ads based game makes more revenue than our paid version

For more than one year, our game voxel invaders was present on google play as both a free demo version and a full paid version. Recently we decided to remove the demo version and replace it with a free full version with ads. To make it simple, we just updated our demo package with a new package incorporating the admob SDK. In order to boost the new version, we also cooperated with app of the day…

How to deal with spaghetti legacy code

At least three times in my career as a programmer, I had to work on huge, complicated code written by other people. In one case I was specifically hired to replace the original maintainer who -as I later learned- left the company from a burnout caused by the frustration of having to maintain his own code. Inheriting legacy code is common, and few people enjoy it. Here I put down a few ideas that I…

ARM assembly for iOS with XCode

This week-end I spent a lot of time trying to optimize the code of my incoming video game. The game engine features a fluid simulation algorithm based on this excellent paper by Jos Stam. The algorithm is CPU intensive, and so I tried my best to make the code as fast as possible, which eventually means having to write the code in assembly. Since I couldn&rsquo;t find much information about how to…

Procedural rendering test 1

For my incoming video game project I wrote a small procedural rendering engine. So now I can do all kind of creepy animations. Here is an example, compiled to javascript using emscripten.

Vocabulary learning wallpaper with python and gnome

Here is a simple way to customize your gnome desktop to show random text taken from a file. I use it to learn Chinese, but it can be easily modified for any other kind of textual information. This is how I did it: Using inkscape, I made a template SVG file for the background. I started from the default gnome 3 wallpaper, and I added three text elements: one for the Chinese characters, one for the…

Bash script to compress pdf files

Since I work as a freelance, I have to deal with a lot of pdf files I receive from clients. Some of them contain uncompressed images that make the files bigger than they need to be. On this stackexchange question, a user named Marco gives us a nice way to use ghostscript to compress any pdf file. There is a loss of quality in the compression, but most of the time it is acceptable.

My personal calendar using Remind

I made a cool &ldquo;getting things done&rdquo; script on my computer: any time I type the &lsquo;rem1&rsquo; command, I see a nicely formatted calendar of the current and following three weeks. It also prints out the most urgent things I need to do. It looks like that: In the past I tried several different note tracking tools, most notably the great org-mode. I like the concept of keeping all my…

Image color wheel generator

Here is a little side project I did, that allows to quickly get an idea of the color distribution of an image in the Hue / Luminosity color wheel. This can be used by designer to check if an image follows some specific color scheme, like using only complementary colors. I wrote the code in C, and compiled it in JavaScript with emscripten. I am planning to write a following post to show how I…

Linus subsurface funny commits

Linus Torvald is mostly famous for being the creator of the Linux Kernel and git. He is also the author of a diving application: subsurface. What I like about subsurface is that we can see how Linus works on a small scale project, similar to the kind of things most developers like me work on. I really recommend reading the git logs of Linus: not only are they perfectly written and formatted (check…

My new blog

This is the first post on my new blog. I decided to stop using blogspot (here is a link to my previous blog) for a few reasons: Blogspot does not allow to write the posts in a markup language like markdown or reStructuredText. Instead you have to use either the &ldquo;user friendly&rdquo; interface that seems to never render things the way you want to, or directly type the post in html.

About

Hello I am a software engineer living in Taiwan, currently mostly working on Stellarium Mobile and sometimes on Goxel. If you have any questions or suggestion, write to guillaume@noctua-software.com.