In flash, I use lineTo to draw a line between two points. This is working well, but I’m finding that on slower computers, the line is jagged because not as many mouse events are firing.
I want to ‘smooth’ the line out, to add more points in between each point that the mouse registers:

The black lines show the result, the green ones are what I want. The red dots are actual points, and the green ones are interpolated.
I have tried to code this myself but I can’t seem to get it right, here is the code anyway:
var interX:Number = lastMouseX+(lastMouseSpeed.x/2);
var interY:Number = lastMouseY+(lastMouseSpeed.y/2);
//Also tried: lastMouseX+(this.mouseX-lastMouseX)/2;
// also jittery
graphics.lineTo(interX, interY);
graphics.lineTo(this.mouseX, this.mouseY);
lastMouseSpeed.x = this.mouseX-lastMouseX;
lastMouseSpeed.y = this.mouseY-lastMouseY;
lastMouseX = this.mouseX;
lastMouseY = this.mouseY;
the result is much more jagged than the normal one.
Sorry, but I can’t give screenshots (for some reason it copies my screen as black)
You probably want something like spline interpolation, though other approaches are possible.
The reason your current approach isn’t working is that what you want to do for the point between red points 1 and 2 depends on red point 3, but you’re equations don’t account for this. Accounting for it makes it possible to appropriately consider the curvature, but it’s more complicated though.