How to calculate a point along a curve?

I am writing custom animations for wpf and as a non-mathematician, I have a couple of questions ...

If I have been given two Point3Ds, From and To, and if the origin is 0,0,0, how can I calculate the curve between two points?

And as soon as I have a β€œplotted” curve and I know its length (how to do this?), How can I calculate the x, y, z coordinates at some given distance along the line?

Thanks!

+7
math animation wpf curve
source share
3 answers

To get a straight line vector from point A to point B:

B - A

which translates to:

vector.x = bx - ax; vector.y = by - ay; vector.z = bz - az; 

Length:

 length = Math.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); 

To get a point at some distance along the vector, you need to make the vector a unit vector (length 1):

  vector.x = vector.x / length; ... 

and then multiply them by the distance:

  vector.x = distance * vector.x; ... 

This is all from memory, so you cannot immediately compile.

Here is the Vector type for C # in CodeProject that will do this for you.

If you need a curve, you will need:

a) to determine what type of curve you want (arc, spline, etc.)

b) more points (centers, control points, etc.)

+5
source share

You probably want to express your curve as a set of parametric functions of some other variable:

 x = f(t) y = g(t) z = h(t) where 0 <= t <= 1, and f(0) = from.x, f(1) = to.x g(0) = from.y, g(1) = to.y h(0) = from.z, h(1) = to.z 

There are an infinite number of curves connecting any two points, so you need more information to decide which shape f (t), g (t) and h (t) should take. To move a point along a curve, you simply let t vary from 0 to 1 and calculate the x, y, and z coordinates. One approach is to determine the set of control points that you want to use the curve to pass (or side by side), then express your parametric equations in terms of the spline function . For this you do not need to know the length of the arc of the curve.

0
source share

So, I just wanted to continue my decision, although it is true that there are an infinite number of curves. My (poorly formulated) question was how to construct the shortest distance between two points of the curve, assuming the origin from 0,0,0 and two three-dimensional points. What I did was convert my points from Cartesian to polar, calculate a spherical point at a given point in time, and then convert this point back to Cartesian. If anyone wants me to post the actual C # code, let me know.

0
source share

All Articles