# Moving points into different directions

**URL:** <https://discourse.processing.org/t/moving-points-into-different-directions/4041>\
**Category:** Coding Questions\
**Created:** [October 2, 2018, 10:20am UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041 "2018-10-02T10:20:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saotome](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@saotome](https://discourse.processing.org/u/saotome)\
**Post date:** [October 2, 2018, 10:20am UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041/1 "2018-10-02T10:20:33Z")

</div>

Good morning

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

Image it’s like this

![2018-10-02_121733](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/daeb6ecfc077735c4c8f6eee4ed845b550969af5.png)

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

```auto
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

---

<div class="post-metadata">

**Author:** ![Sarah](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarah/32/1675_2.png) [@Sarah](https://discourse.processing.org/u/Sarah)\
**Post date:** [October 2, 2018, 11:04am UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041/2 "2018-10-02T11:04:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [October 2, 2018, 12:50pm UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041/3 "2018-10-02T12:50:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![saotome](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@saotome](https://discourse.processing.org/u/saotome)\
**Post date:** [October 3, 2018, 2:34pm UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041/4 "2018-10-03T14:34:58Z")

</div>

Like this

```auto
//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
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [October 3, 2018, 3:53pm UTC](https://discourse.processing.org/t/moving-points-into-different-directions/4041/5 "2018-10-03T15:53:46Z")

</div>

So what is your problem exactly? Everything seems to work fine no?
