(Demo) Illusion: When a Linear Motion Produces a Circular Motion

GeeXLab demo - Illusion: When Linear Motion Produces a Circular Motion

Here is a demo based on this tweet:

Each ball is traveling in a straight line but together they circulating

The GeeXLab demo should run on any OpenGL 2 capable system: Windows, Linux, macOS and Raspberry Pi. The demo is coded in Lua and all interesting code is in the frame.lua file.

When you run thew demo, 10 discs are progressively displayed, one after the other, so you can see the construction of the illusion.

This 2D demo has three objects: one big disc (red), one small disc (white) and one black line.

The principle of the animation is simple: a white disc moves along an horizontal line according to a sine wave:

x0 = radius * math.cos(time + offset)
y0 = 0

and a 2D rotation is applied with:

x1 = x0 * math.cos(a) – y0 * math.sin(a)
y1 = x0 * math.sin(a) + y0 * math.cos(a)

where a is the angle around Z axis.

The disc is finally rendered with:

gh_object.set_position(disc, x1, y1, 0)

Complete source code is available in the demo archive.

Leave a Comment

Your email address will not be published. Required fields are marked *