I’m sure this has been asked before, but I was unable to find any results searching these forums. I did find some Google results, but they didn’t make much sense to me.
I have two points in 3D space, a starting point and an ending point. I want to move from starting point to ending point at a constant velocity. Below “velocity” is ACTUALLY “velocity * timeDelta” in my update frame just for the record.
startPoint = Vector3D(0, 0, 0);
endPoint = Vector3D(123, 456, 789);
Using the formula I found: L = {P + t(Q - P)}
We update our startPoint as follows:
startPoint.x += (velocity * (endPoint.x - startPoint.x))
startPoint.y += (velocity * (endPoint.y - startPoint.y))
startPoint.z += (velocity * (endPoint.z - startPoint.z))
Which works great, EXCEPT - as expected, the closer you get to the endPoint the slower you move… Which is a really cool effect (easing into the endPoint), but not what I am looking for.
I know I could do it if I kept track of the original startPoint and then added a time variable, incrementing the time by the velocity each step - but I was kind of hoping that I could do it in a simpler way without adding any additional variables?
I was thinking of extending the endPoint out in virtual space, but then that adds complexity of calculating when you actually reached your destination among other things… And the fact remains, the longer the line is, the faster the movement is at the startPoint and slower at the endPoint.
Any ideas?
—Rob