I have a very simply tracking task in which people track a ball with their mouse. Currently the ball bounces off the edges of the screen, however I would like it to follow along a smooth curve (basically so that accuracy is not impeded by the bounce movement. Any help would be much appreciated!

This is the tracking task:

PrintWriter out;
void setup() {
fullScreen();
//size(640, 360);
noStroke();
frameRate(30);
fill(0,0,400);
ellipseMode(RADIUS);
// Set the starting position of the shape
xpos = width/2;
ypos = height/2;
out = createWriter("M:\\Tracking_Taskworking\\accuracy.csv");
}
int rad = 12; // Width of the shape
//float xpos, ypos; // Starting position of shape
float xpos, ypos; // Starting position of shape
float xspeed = 3; // Speed of the shape
float yspeed = 3; // Speed of the shape
int xdirection = 1; // Left or Right
int ydirection = 1; // Top to Bottom
double dist; //distance between cursor and moving target
void draw()
{
background(1);
// Update the position of the shape
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
// Test to see if the shape exceeds the boundaries of the screen
// If it does, reverse its direction by multiplying by -1
if (xpos > width-rad || xpos < rad) {
xdirection *= -1;
}
if (ypos > height-rad || ypos < rad) {
ydirection *= -1;
}
// Draw the shape
ellipse(xpos, ypos, rad, rad);
// Calculate distance between cursor and moving target
dist = (Math.sqrt((xpos-mouseX)*(xpos-mouseX) + ((ypos-mouseY)*(ypos-mouseY))));
out.println((int)dist+","+(int)millis());
out.flush();
}

If you have defined your motion path as a curve then you can use bezierPoint or curvePoint to evaluate a position on the path over time. Is the target following a curved or segmented path, and should the speed of the motion target be constant over time, or can its rate of speed change?

Check out the bundled Processing PDE examples “MovingOnCurves” and, if you need a continuous fixed speed, “ArcLengthParametization.”