Help with rotation of a moving object

I’m having a lot of difficulties with the rotation of an object that is moving. The way I calculate the rotation is by taking the angle between point n and point n+1 like so

angle = math.atan2( (point[1] - pointprev[1]) , (point[0] - pointprev[0]))

I then add a keyframe of that angle into the fcurve. This gives the correct angle for the object. However the problem I’m having is that the interpolation of the fcurve causes my object to make a priouette around its axis when it moves from some quadrant to another (see screenshot). How can I fix this?

We need to know both WHAT it’s doing (which you seem to have more-or-less covered) and what you EXPECT it to do. More info, please.

In fact, give a real-world example of the type of behaviour you’re trying to emulate. Might help.

Sorry I wasn’t clear enough. It’s going to be a boat that follows a path generated from a list of coordinates seperated by identical time intervals. The path you see on screen is the path it takes, but it’s not constrained to it, the path is just there as a visual aid. The way it follows the path is by adding an x,y fcurve point for each coordinate in my data set. The narrow end of the object you see in the screenshot should point in the direction of the path, which it does with the method I posted previously, however not in the cases where the direction moves to a different quadrant. I hope this is enough info.

Sorry, corpus, math is not my strong suit, but…

It seems to me you’ve got to allow somehow for a negative number in your tuple changing to a positive and vice versa. Perhaps you need to work with absolute values and put in some ‘if’ statements to cover those times when you cross from one quadrant to another. This is assuming that by ‘quadrant’ you mean crossing a mid-point on the xy graph.

On the negative side of the x axis, add instead of subtract. That kind of thing.

Best I can give you; hope it at least gets the synapses firing.