### Keep Constant Speed for different distances to Line.

Hey, I’m currently working on a graphics patch and stuck at this part.

I have different distance I’m sending to line.

For example from 0 to 1000 and from 0 to 10.

Now if I send both with the same duration to line the numbers will move more rapidly at the higher range as it is a longer distance.

Has anybody an idea how I could calculate the duration to send to line so the velocity is staying constant?

I have a patch for you, lemme real quick upgrade my max, since the latest osx crashes 6.1.4 constantly, hehe.

speed is defined as distance per unit time, so duration (the unit time bit) will be distance divided by speed:

<code>

**all**of the following text. Then, in Max, select

*New From Clipboard*.

```
----------begin_max5_patcher----------
809.3oc2XssbaBCD8Y3qPCO0NiKEwc5a8Gn+.Mc5H.YGkBBFgHwsYx+d0EH0
IMbwN1pYpe.aVjzt6Qmc0AeuskSdydbmC3SfuBrrt21xRYRZvZ3dKmZz9hJT
mZXNT7cM423rQ+HNdOWYlC1B1NZk1WSnUXtZFvAisHdw0D5tuyvEbsGC7b8i
1.xftda.QdxqvLWOv2FlBoTs1B+8A+vwEeaCkSQ0X0i9Lifp.eAwXM2cf2a5
4it2evp1D+msXsuc1V0f3NaF+wiNUt9cjeoFFTDYRqOXaKur40gQsnheLIL4
uHLAyBjHTRraRzL.UvIBTvo.JS.MbPEv6DoO99PWwWA9tyAKdma9ij5PnFg3
fx6.dtGK7jlpJnhijeEDMW0EL6bSZN+EUhUT36SkijFtbOFX5qjizhXhIwwr
uion7J0z8Vr+SNht6rhTEM00XAy7uJxPrcXN3VTUO9wLksKWEltiAZKC2IlM
hSZnG.jQgJ5TppWs2vkGi5ib6HPUwFkLamLX7Itc3coHcS.MgIpFyvvnyA1H
PknEYpQWPlpX7c391UTdeIHuh3MGyN1xbXPhtYWnD7hmuYWfIKykGQXxh7BT
UQeEhiKAk8LEUETSppHc3hFZY23DpHTggdJ+vLa0cCBS07SIF+Jn79d9pkIR
2aQcUbN9Ktsk8uuavjhWxOdsu5jUKoadoKImakKJtnIE99Q.z8XE8NndIXE.
T7aewKSUsdkSWKFWdkC3c8TBGzhYGVs99irZcsjuLc2xTIpNeUWzasyfEIHo
VbqNukefmTkWjJ4GN4dBhUv+G5AmnpTxol50JBVVQcjhCEFO6QsWhW5ZUXiZ
LpT7Y+6FpLRZ+o.VWSOqXzKiuGM3OIUItiSnpiAObPdOYPWSJKwzC2kKIcxM
dEh7xacqMdjR9VNdBMV77LWMQ7DX13AtP7Datsqr0BOPy.Odq.dfla2xaEvi
4Bm30DMliKmrhvI1nQyZJrLCQdMskSdaQbxLWWm0DNomX3nORE01dKl0Mrlp
HQn13lFl713M1ZIZ5aUhvbX3aIiiOTYAwDhJ3BEE8Lshf8owN1R+7f8uA76q
3tD
-----------end_max5_patcher-----------
```

</code>

<code>

**all**of the following text. Then, in Max, select

*New From Clipboard*.

```
----------begin_max5_patcher----------
850.3ocyYt0bhBCE.9Y7WACOtiqStPPbea+crSmNbIZSWH3.wt1sS+uu4BnT
Kzlp.KuHlSBwy4iysfurvwKt3Hsxy8Gt+x0w4kENNZQJAN0ic7xiNljEUoWl
WNspJZG0aoYNA8nPKGrpQDKUKnH9wuiPMB2VvE7nbpdpeVxhxZlgeHmwynB8
1ipEVbPHEIddO0naddt2cd8lY02.r09Ww9qd4PzJPs38QhjGX7c2WRSDlsZ8
Z4rt3M9pKDf5SX3Jf6cp630EKTer7lgAhzEN.yObDnI.IHPCB+M2DORJxyob
w63wSzrhDl34Sle4tX0DfSZVKJAC+hTB1IJ.eYTfT18YVX7MPfqjEb5ejVy6
PQTbkamwJvfqzremyw1rhHwv4g.M7fnWkqOdLnx26gIjgJfYbXhen9BFshL7
LQ3t0caWPAMrNJK+D5ftZ5P1L.zoubJU6ozTqRnr9+T9D+05HFb.dDymrOJ4
2Rytm3G+4WAGjoxqOQ6iDbioSNjGSK6xxwCUPBiqCQhi36FtHjFWi1cgXfvo
6oTpyBZ48TdTbldKASQUH3LsJDFqKN6CviWUnu4B6jIfYZUnFlf1LdUg5ox7
l4MRvqISeg4v4dc45TuML51fSem8AB.cvlf4WgHLwWdLMIAv3y3XvOJHrKZP
lgz.uwPCX3XRitxkLCaRAip8M.iouQmYVwyPZ.L9Fvvgv2nmrpYLNsmdR9hD
A2KQV1OUt5S4zTDNnyNRz+ZZa6h2xldCUxeKopJNTlznu0Fu641BSoUBFORv
J3sVirXrK7zZdfklR4sOxRRQVQoY8fUgx8aEjPBI5uoNYRq9NyYo6Kjs7Vqs
PYcTh5HL0WflCzHGcVkXUpFTS6uCUaM0v2XF8apfOvTGNsYiEfGBmL0wF+.0
qa8CcDFN0Aag5DNYvweVoMjYk1DLqzlPahp7mtnJa7b9rf7KxYhk8LPTuFYc
xRDBYdoxsGoZuPk3sN6pZzHjOEZyid0+IwDkyvlTXpWt4T8r2l3zKX3npOHa
zGxz83BYQ83Kf3npO1TyANgtyPa0mIhO.aysdM7wzHaz98OQKqp2SspHat+Q
S2kAK0CYbyP84L7JoOwZVuuVRTorSZgrM5CklN4OFF3sP8675h+Ak1Y5K.
-----------end_max5_patcher-----------
```

</code>

ah, nice to see a different take on it. FPs is simpler, and I guess uses proper "units" (no idea if mine does, coincidentally, it probably does?), whereas mine is situationally aware in a sense.

Thanks Wetterberg and Floating Point for providing your thoughts on this.

Two great solutions and both work perfectly for my purpose!

Hey, I ran into another problem in trying to adapt the patch to my needs.

I’m using the constant line velocity to make points move to different positions in a 2D Space. For this I interpolate one X/Y to the next X/Y values via two line objects.

The constant velocity works great but now I realized that I need to calculate different speeds for the X and the Y Movement so that X1,Y1 arrive at the same point in time at X2,Y2.

For Example if X1 to X2 is 20 distance and Y1 to Y2 is 10 distance the speed of X would have to be twice the speed of Y.

Does anybody have an idea how to adapt the pacthes above for that problem? It’s completely twisting my mind..

Hey, I ran into another problem in trying to adapt the patch to my needs.

I’m using the constant line velocity to make points move to different positions in a 2D Space. For this I interpolate one X/Y to the next X/Y values via two line objects.

The constant velocity works great but now I realized that I need to calculate different speeds for the X and the Y Movement so that X1,Y1 arrive at the same point in time at X2,Y2.

For Example if X1 to X2 is 20 distance and Y1 to Y2 is 10 distance the speed of X would have to be twice the speed of Y.

Does anybody have an idea how to adapt the pacthes above for that problem? It’s completely twisting my mind..

Forums > MaxMSP