Shortest distance from point to Catmull-Rom spline

AI Thread Summary
To project a point onto a Catmull-Rom spline, the spline is calculated using a cubic polynomial based on control points. The discussion suggests using a method that involves drawing multiple lines from the point to the spline to find the closest intersection, balancing speed and accuracy. Acknowledging the complexity of solving a fifth-degree polynomial, the approach favors a practical solution over mathematical precision. The emphasis is on achieving a quick approximation rather than an exact solution. This method is particularly useful when performance is prioritized over pinpoint accuracy.
Lantz
If I have a point P, how do I project it onto a Catmull-Rom spline (ie. get the point on the spline closest to P)?

This is how I calculate the spline, t goes from 0 to 1 (C++):
Code:
float t2 = t * t;
float t3 = t2 * t;
out.x = 0.5f * ( ( 2.0f * p1.x ) +
	( -p0.x + p2.x ) * t +
	( 2.0f * p0.x - 5.0f * p1.x + 4 * p2.x - p3.x ) * t2 +
	( -p0.x + 3.0f * p1.x - 3.0f * p2.x + p3.x ) * t3 );
out.y = 0.5f * ( ( 2.0f * p1.y ) +
	( -p0.y + p2.y ) * t +
	( 2.0f * p0.y - 5.0f * p1.y + 4 * p2.y - p3.y ) * t2 +
	( -p0.y + 3.0f * p1.y - 3.0f * p2.y + p3.y ) * t3 );
out.z = 0.5f * ( ( 2.0f * p1.z ) +
  	( -p0.z + p2.z ) * t +
 	( 2.0f * p0.z - 5.0f * p1.z + 4 * p2.z - p3.z ) * t2 +
 	( -p0.z + 3.0f * p1.z - 3.0f * p2.z + p3.z ) * t3 );

Which I derived from the forumla on this page. Should I use the, what's it called, the smallest square solution or something? My math skills does not go beyond one variable calculus and linear algebra so I have no clue whatsoever.

Regards,
Lantz
 
Mathematics news on Phys.org
I tried looking into the actual solution but it quickly became bloated and even with mathematica on my side i ran into a 5th degree polynomial i needed to solve.

But I bet you need speed more than pinpoint accuracy. I suggest you draw lines that "emanate" out from the source of the point and see what the distance is for each line to intersect with the curve and then simply choose the smallest as the direction you want to head. By adjusting the number of lines you use you can trade-off speed for accuracy.
 
Yea you're right, speed is more important than accuracy in my case. And that sounds like a way to do it. I'll give it a shot and see if I come up with anything, thanks dude.

/me scratches his head
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Thread 'Imaginary Pythagoras'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top