# Find direction vector is in

**URL:** <https://discourse.processing.org/t/find-direction-vector-is-in/30161>\
**Category:** Coding Questions\
**Created:** [May 18, 2021, 8:39pm UTC](https://discourse.processing.org/t/find-direction-vector-is-in/30161 "2021-05-18T20:39:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fede4961](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fede4961/32/13303_2.png) [@fede4961](https://discourse.processing.org/u/fede4961)\
**Post date:** [May 18, 2021, 8:39pm UTC](https://discourse.processing.org/t/find-direction-vector-is-in/30161/1 "2021-05-18T20:39:32Z")

</div>

I currently have 2 vectors:

```auto
PVector a = new PVector ( 100, 100 );
PVector b = new PVector ( 500, 500 );

```

I need to set a’s heading so that it lines up with b. I’ve been struggling with this for a few days: I tried using `atan2 ()` but it kept giving me a 45 degree angle for some reason. Any ideas?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 18, 2021, 9:00pm UTC](https://discourse.processing.org/t/find-direction-vector-is-in/30161/2 "2021-05-18T21:00:08Z")

</div>

Hello,

They are both heading in the same direction.

Take a look here for some resources:

- [PVector \ Processing.org](https://processing.org/tutorials/pvector/)
- [PVector \ Language (API) \ Processing 3+](https://processing.org/reference/PVector.html)
- [The Nature of Code](https://natureofcode.com/book/)

It helps to draw vectors when working with them:

```auto
void setup() 
  {
  size(300, 300);
  background(255);
  PVector a = new PVector (50, 50);
  PVector b = new PVector (250, 250);
  stroke(255, 0, 0);
  strokeWeight(5);
  line(0, 0, a.x, a.y);
  stroke(0, 255, 0);
  strokeWeight(2);
  line(0, 0, b.x, b.y);
  }

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/34111cb91c22cff99aa9c9e06b299d0c7de2a139.png)

`:)`

---

<div class="post-metadata">

**Author:** ![fede4961](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fede4961/32/13303_2.png) [@fede4961](https://discourse.processing.org/u/fede4961)\
**Post date:** [May 18, 2021, 9:12pm UTC](https://discourse.processing.org/t/find-direction-vector-is-in/30161/3 "2021-05-18T21:12:48Z")

</div>

Yeah after 2 hours of scouring the old forums and Processing documentation I created this post, and I kid you not literally 5 minutes later on youtube the exact tutorial on steering by Daniel Shiffman popped up lol.
