Algorithm to follow a point
pow(x,2) is less efficient than simply multiplying with itself:

static double mj_distance(double x, double y, double x2, double y2) {
    double dx = x - x2;
    double dy = y - y2;
    return sqrt(dx*dx + dy*dy);
}


However because you just compare it against a distance you can do away with the square root and compare it against the square of the distance:

double d = speed * seconds;
if (d*d &gt;= mj_distance_squared(this-&gt;x, this-&gt;y, x, y)) {


there is a atan2 function which takes a delta y and delta x to return the correct angle.

void mj_dot_rotate(struct mj_dot *this, double x, double y) {
    double dx = x - this-&gt;x;
    double dy = y - this-&gt;y;
    this-&gt;th = atan2(dy, dx);
}