saotome
October 2, 2018, 10:20am
#1
Good morning

I’m trying to move a point from one coordinate to another one.

Image it’s like this

The code I have used for the left line of points is the following

```
int ball_radius;
float ball_y;
float ball_y0;
float ball_x;
float ball_x0;
float A;
float T;
float time;
void setup() {
size(600, 600);
frameRate (70);
ball_radius = 30;
ball_y = 250.0;
ball_y0 = 300.0;
ball_x = 250.0;
ball_x0 = 300.0;
A = 200.0;
T = 20.0;
time = 0.0;
}
void draw() {
background(255, 255, 255);
color b = color(0, 255, 0);
fill (b);
ellipse (ball_x, ball_y, ball_radius, ball_radius); //line left to right
ball_x = ball_x0 + A*cos(2*PI*time/T);
ball_y = ball_y0 + A*-cos(2*PI*time/T) ;
color d = color(0, 0, 255);
fill (d);
ellipse (ball_x, ball_y, ball_radius, ball_radius); //line right to left
ball_x = 20+ball_x0 + A*cos(2*PI*time/T)*.8;
ball_y = 20+ball_y0 + A*cos(2*PI*time/T)*.8;
time = time + 0.1;
}
```

I’m changing parameters on ball_x and ball_y to have a similar image, but I’m unable to find the equation that generates the drawing.

Thanks to all

Sarah
October 2, 2018, 11:04am
#2
Hi,
From what I understand, you have one point that you want to move you an other point?
Also you might want to format you code with the `</>`

button to make it easier for others to read.

jb4x
October 2, 2018, 12:50pm
#3
Hi saotome,

Can you please format your code?

To do that, click on the pen icon in the bottom right corner of your previous post to edit it. Then select your code and hit the following icon `</>`

in the textbox toolbar.

Don’t forget to hit `ctrl+t`

in the processing IDE to properly indent every thing.

Like this

```
//Definim les variables
int ball_radius; //var sencera
float ball_y;
float ball_y0;
float ball_x;
float ball_x0;
float A;
float T;
float time;
//Initialitzem els valors de les variables
void setup() {
size(600, 600);
frameRate (70);
ball_radius = 30;
ball_y = 250.0;
ball_y0 = 300.0;
ball_x = 250.0;
ball_x0 = 300.0;
A = 200.0;
T = 20.0;
time = 0.0;
}
void draw() {
background(255, 255, 255); //fons blanc
fill (0, 0, 0); //pilota negra
ellipse (ball_x, ball_y, ball_radius, ball_radius); //dibuixem el punto
ball_x = ball_x0 + A*cos(2*PI*time/T); //ecuacions moviment rotatori
ball_y = ball_y0 + A*cos(2*PI*time/T) ;
time = time + 0.1; //incrementem el temps i tornem a dibuixar el seguent punt
}
```

jb4x
October 3, 2018, 3:53pm
#5
So what is your problem exactly? Everything seems to work fine no?