# Controlling the curvature of a Bézier curve

Hey guys,

I’ve been working on a curve generator for my game. I’m using it to plot a course for a ship.

First a little background; our ships have a maximum rotation of x and can move a maximum range of y per turn. They apply this range and rotation over a number of time segments, using either, neither or both types of transformation in each time segment.

While they can turn on their centre, it is optimal if they move and rotate at the same time where ever possible, however moving and rotating enforces a turning circle. With that in mind, I would like to control the curvature of my Bézier curve in order to find the optimal route from A to B while maintaining a specfic heading at both the start and end of the route.

I realised that the vector between the first point and the second point represents the starting heading and that the vector between the penultimate point and the last point control the end heading. I’ve also noticed that the distance between P0/P1 and P2/P3 controls the curvature (the closer the distance, the tighter the turn).

Taking into account all of the above, I have created a generator which creates a path between two points forcing a specified start and end heading and which (by use of colour) tells me if the curvature is to steep for a particular ship’s turn ratio.

In this case, both the start and end heading are 315 (or -45).

I’ve been experimenting with changing the curve by adding in extra control points in between P1 and p2. This allows me to manually widen the curve reducing the tightness of the turn but I need to find some formula/algorithm for placing these extra control points which allows these curves be loosened/tightened automatically.

I was hoping someone could point me in the direction of some maths that might help?

In general it is not an easy task to control the curvature of a Bezier curve. If you look into the Bezier curvature formula you get, `k(t) = (px_d py_dd - py_d px_dd)/(px_d^2 + py_d^2)3/2.`