Advertisement

Using a Catmul Rom spline for steering assist

Started by October 22, 2011 03:16 PM
0 comments, last by IADaveMark 13 years, 1 month ago
I'm looking to use a Catmull Rom spline for steering assist in a driving game.

Currently I compute the spline and then use linear interpolation along the 2nd and 3rd control points to determine t.

i.e.

vector3df v2toV3 = v3 - v2;

f32 t = v2toV3.getLength();

v2toV3.normalize();

vector3df v2topos = GetTrans().GetPosition() - v2;

t = Boundval( 0.0f, v2topos.dotProduct( v2toV3 ) / t, 1.0f );


Which I then use to determine the point along the spline and I use that to feed into a pid controller

My problem is the linear interpolation to detemine t. As this value could be slightly behind or ahead of the car's position depending on the curvature of the spline.

What I really need is a way of determining the position along the spline that intersects the shortest line from the car to the line between the two control points.

If any of that makes sense? :-)

Gotta wonder if this isn't better suited to the Math forum.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

This topic is closed to new replies.

Advertisement