# Math problem! Moving objects along the Z-axis

**URL:** <https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311>\
**Category:** Questions\
**Tags:** math\
**Created:** [December 17, 2023, 4:36am UTC](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311 "2023-12-17T04:36:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prometheus3636](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Prometheus3636](https://discourse.threejs.org/u/Prometheus3636)\
**Post date:** [December 17, 2023, 4:36am UTC](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311/1 "2023-12-17T04:36:12Z")

</div>

In the following jsfiddle, I made a slider (at the bottom of the screen) that lets you move the displayed images back and forth along the z-axis:

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/Prom36/nu7qe0r3/19/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

While I purposely positioned all the images a different amount of distance from the (0, 0, 0) point, what I’d like to do is have them all converge on and arrive at this (0, 0, 0) point _ **at the same time** _.

Meaning that as you slide the Slider one way all the images will get _further away_ from the CENTER point, and as you slide it the opposite way they’ll all get closer and closer until they all arrive there at the same time.

My problem is that since they’re all positioned a different amount of distance from this CENTER point, it means they all have to travel at _ **different rates** _ so as to all converge at the same time – and I have no idea how to make this happen.

Furthermore, the larger scope of the project will have scenarios in which I’ll have to handle up to 7 different images. Which means that in one instance 5 images may appear all at once, in another 3 images will appear, or 6 images, or 2 - all the way up to 7 images.

So what I need is some sort of formula (I guess) that will:

1. figure out the initial distributed positions of the images, as a function of how many images there might be
2. figure out the rates or amount of distance they’d all have to travel so as to arrive at the Center point at the same time.

Would really any tips or guidance in trying to make this happen.

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [December 17, 2023, 6:41am UTC](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311/2 "2023-12-17T06:41:36Z")

</div>

[position.lerp](https://threejs.org/docs/index.html?q=vect#api/en/math/Vector3.lerp) is what you seek 😌🙏

---

<div class="post-metadata">

**Author:** ![Prometheus3636](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Prometheus3636](https://discourse.threejs.org/u/Prometheus3636)\
**Post date:** [December 17, 2023, 3:40pm UTC](https://discourse.threejs.org/t/math-problem-moving-objects-along-the-z-axis/59311/3 "2023-12-17T15:40:54Z")

</div>

Hmmmm…looks interesting…

If “lerp” is what I seek, than I shall indeed go and seek it!

Will report back with my findings.

Thank you! 🕵️‍♂️
