# Best way to compare X/Y input to a 360-degree rotation?

**URL:** <https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [October 21, 2014, 9:09pm UTC](https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718 "2014-10-21T21:09:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arcade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arcade](https://forums.unrealengine.com/u/Arcade)\
**Post date:** [October 21, 2014, 9:09pm UTC](https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718/1 "2014-10-21T21:09:57Z")

</div>

Hi,

- I have an object (Wind) that rotates (only yaw/Z) in the world. Currently, I’m getting its rotation as -180 to +180.
- I have an object (Ship) that gets X input between -1 and 1, and Y input between -1 and 1.

What I would like to do is check how close the “direction” of my X/Y object is to the first one.

Example: If the Wind direction is 0, Ship-X is +1 and Ship-Y is 0 - The “Match” would be 1.

What is the best way to do that?  
I’m having a hard time since they’re in different forms.

Thanks,

---

<div class="post-metadata">

**Author:** ![Lowkeygamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lowkeygamedev/32/1112663_2.png) [@Lowkeygamedev](https://forums.unrealengine.com/u/Lowkeygamedev)\
**Post date:** [October 22, 2014, 10:52am UTC](https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718/2 "2014-10-22T10:52:31Z")

</div>

if you want to compare the direction of the two vectors, you need to do an inverse cosine calculation (ACos node) between the dot product of the two directional vectors.

Id suggest getting the forward vector of your craft, and the forward vector of your wind, and comparing them with this formula:

![61c3ded767b8d1d7cca3d974d4fd2188f8682501.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Good Luck.

---

<div class="post-metadata">

**Author:** ![starseeker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@starseeker](https://forums.unrealengine.com/u/starseeker)\
**Post date:** [October 22, 2014, 10:56am UTC](https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718/3 "2014-10-22T10:56:34Z")

</div>

I am not sure what you wanted, but if you wanted the angle between 2 vectors, you can always do a Dot Product (Normalise), & it will return angle between 2 vector.

NormaliseVector1 . Normalisevector2=x ("." is dot product)  
AngleBetweenvectors= Cos-1(x)

All of the above operation nodes are available in blueprint.

Edit:RennJan was faster than me, haha, but we have same solution. I only saw his post asfter I posted.

---

<div class="post-metadata">

**Author:** ![Arcade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arcade](https://forums.unrealengine.com/u/Arcade)\
**Post date:** [October 28, 2014, 7:41pm UTC](https://forums.unrealengine.com/t/best-way-to-compare-x-y-input-to-a-360-degree-rotation/13718/4 "2014-10-28T19:41:29Z")

</div>

Took a while for me to get back to this. That worked beautifully! Thanks a lot!
