Loading assets, please wait...
Trying to understand how to move objects in 3D space
MOVING OBJECTS IN 3D SPACE
tap/click the right side of the screen to go forward →
Okay… probably not, right?
But one morning, this question popped into my head.
It stuck with me long enough that I ended up diving into a few articles about it.
From there, it spiraled into lots of explorations, trying to figure out how to move objects in 3D space.
From a simple circle...
...to a spiral...
...to this complex, chaotic path.
All these explorations made me want to share what I learned with you.
I hope you enjoy this as much as I did.
Let’s start!
A helix is a shape that loops around and around, like a spring.
How do we do this?
We'll get there! But first, let’s see how to position and move objects in 3D space.
In 3D space, we position objects by setting its coordinates along three axes: x,y, and z.
The x-axis typically represents horizontal movement—left or right.
The y-axis typically represents vertical movement—up or down.
The z-axis typically represents depth—forward or backward
To move an object in 3D space, we can use mathematical functions to set its position over time.
For example, this cube's x position is set to 10 * cos(πt/2), where t is time (in seconds).
x-label
The result? It oscillates from 10 to -10 along the x-axis every 2 seconds, following a cosine wave.
x-label
Similarly, setting the y position to 10 * cos(πt/2) makes the cube oscillates vertically, from 10 to -10 every 2 seconds.
y-label
We can create a two-dimensional path by setting the x and y positions to different functions.
For example, a circle.
For this circle, the x position is set to 10 * cos(πt/2).
The cube starts at x = 10, moves to -10 in 2 seconds, then back to 10, and so on.
x-label
Meanwhile, the y position is set to 10 * sin(πt/2).
y-label
The movement for x and y may look similar, but they are actually out of phase.
When x = 10, y = 0; when x = 0, y = 10; and so on.
x-label
y-label
Together, these two functions create a circular path for the cube.
x-label
y-label
Now we can get creative with functions to create even more complex paths.
For example, let's multiply the x function by 0.03 * t.
It would make the cube oscillates farther on the x-axis over time.
x-label
Do the same for y...
y-label
..and we will have a circular path whose radius grows over time.
A spiral!
x-label
y-label
It has a z component that changes over time.
This cube's z position is set as 10 * cos(0.02 * πt).
It will start from z = 10 then slowly move to -10.
z-label
Second, unlike the previous spiral, the x and y positions don’t grow indefinitely.
They grow at first, then shrink halfway through.
This is because the x function is multiplied by another sine function: sin(0.02 * πt)
which makes the radius larger in the middle and smaller at the ends.
x-label
The same is also done to the y function.
y-label
x-label
y-label
z-label
That's all!
In summary, we can move objects in 3D space by defining their x, y, z coordinates as functions of time.
These functions, which express x, y, z coordinates as a function of another variable (in this case, time), are called parametric equations.
Check out the Wikipedia article for more on parametric equations.
Now that we know this, we can get creative and move objects along any path we want!
From a simple circle...
...to a spiral...
...to this complex, chaotic path...
...which we know now isn't actually chaotic.
It's just a path defined by mathematical functions.
Thanks for sticking with me, I hope you enjoyed it!
__________________
visualrambling.space is a personal project by Damar, someone who loves to learn about different topics and rambling about them visually.
If you like this, please consider following me on Twitter and sharing this with your friends.
I'm planning to write more articles like this, so stay tuned!
https://twitter.com/damarberlari
_blank
Topics covered: Three.js, WebGL, 3D mathematics, spherical coordinates, helix geometry, parametric equations, mathematical visualization, interactive learning