# Moving the objects in 3D space...

## Recommended Posts

ehsan2004    178
Hi I want to move an object in 3d space. The object should move on a curve with a constant velocity. My problem is that if i use from the following function: R(t) = x(t) i + y(t) j + z(t) k = sin(t) i + j + 2*t k Then the vector function is: v(t) = d R(t) / dt = dx(t)/dt i + dy(t)/ dt j + dz(t) / dt k = cos(t) i + 0 j + 2 k So | v | is: sqrt( cos^2(t) + 0 + 4 ) = sqrt( 4 + cos^2(t) ). As you see, | v | is not constant--it changes with time.... This is an example. There are many example that | v | is not a constant value. So what should i do?How the programmers solve such a problem? Regards -Ehsan-

##### Share on other sites
Guest Anonymous Poster
My opinion (without testing your code):

I think your vector MUST be non-constant. Thats is the only way you get a 'CURVE' otherwise you get a linear motion. The fact that |v| changes over time does not mean you are getting different 'speeds'.

##### Share on other sites
ury    476
Moving along a curve with a constant speed means that magnitude of the velocity vector is constant but it certainly doesn't mean that the direction is constant.
In fact, the direction must change all the time (unless your curve is a straight line).

Ehsan, your R(t) is simply wrong. How did you come up with this formula?

An example for a "good" R(t) is:
R(t) = Sin(t)i + Cos(t)j + tk
v(t) = dR(t)/dt = Cos(t)i - Sin(t)j + k
||v|| = Sqrt(2)

##### Share on other sites
Guest Anonymous Poster
Parameterization is arbitrary. The complete curve can be specified by replacing the t with f(t) where the range of f(t) is positive and negative infinity. So you can reparameterize the curve such that (t[2] - t[1]) is the arc length along the curve from f(t[1]) to f(t[2]). Regretably arc length is the integral of a square root so it isn't always possible to do it in closed form and most often is not. If you do reparameterize the curve in such a manner then the rate you change the parameter over time cooresponds directly to the speed along the curve. It's been awhile, but I believe you find a function for the arc length as a function of the parameter, then find the inverse of that function and substitute that function for the parameter in the equation.

On a more generally practical basis you approximate the curve with a polyline. You can use the curviture to adaptively subdivide intervals until you have a reasonable approximation of the curve. You then find your distance along the line segments. Once you find the line segment that the end point is within you interpolate between the parameter values of the end points of that line segment.

##### Share on other sites
ehsan2004    178
OK. let me give another example. assume that i want to move a car on the path y = 2 * x + 3. |V| is 2. But i want to move this object with |V| = 1. So how can i solve this problem?
Regards
-Ehsan-