# Using a Catmul Rom spline for steering assist

This topic is 2615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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? :-)

##### Share on other sites
Gotta wonder if this isn't better suited to the Math forum.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013754
×