# Get degree direction from point to point

**URL:** https://discourse.processing.org/t/get-degree-direction-from-point-to-point/5464
**Category:** Coding Questions
**Created:** [November 12, 2018, 7:12am UTC](https://discourse.processing.org/t/get-degree-direction-from-point-to-point/5464 "2018-11-12T07:12:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Darkar25](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Darkar25](https://discourse.processing.org/u/Darkar25)
#### Post date: [November 12, 2018, 7:12am UTC](https://discourse.processing.org/t/get-degree-direction-from-point-to-point/5464/1 "2018-11-12T07:12:42Z")

</div>

How can i get the degree direction from x1 y1 to x2 y2?example…  
x1 = 0 y1 = 0  
x2 = 100 y2 = 100  
Its equals 45°…  
I tried to make it myself but it not 100% accurate method…its showing 10-15 more degrees than needed…

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [November 12, 2018, 7:30am UTC](https://discourse.processing.org/t/get-degree-direction-from-point-to-point/5464/2 "2018-11-12T07:30:48Z")

</div>

Example:

```auto
float x1, y1, x2, y2;

void setup(){
  size(800,800);
  x1 = 400;
  y1 = 400;

}

void draw(){
  x2 = mouseX;
  y2 = mouseY;
  background(0);
  stroke(255);
  line(x1,y1,x2,y2);
  line(x1, y1, x1+100, y1);
  noFill();
  float a = atan2(y2-y1,x2-x1);
  arc(x1,y1,80,80, min(0,a), max(0,a) );
  text( degrees(a), mouseX, mouseY-20 );
}
  
void mousePressed(){
  x1 = mouseX;
  y1 = mouseY;
}

```
