# How to compare two rotations?

**URL:** <https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519>\
**Category:** Community & Industry Discussion\
**Tags:** how-to, value, rotation, rotation-direction, compare, unreal-engine, question\
**Created:** [June 23, 2017, 12:47am UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519 "2017-06-23T00:47:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JerichoBLT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JerichoBLT](https://forums.unrealengine.com/u/JerichoBLT)\
**Post date:** [June 23, 2017, 12:47am UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/1 "2017-06-23T00:47:48Z")

</div>

I need to return a float value that tells me just how much alike two rotations are. In other words: How accurate they are to each other.

For example: If both rotations are exactly the same, then the max float value will be returned. If both rotations are the exact opposite of one another, then the min float value will be returned. If rotator A is just a little different from rotator B, then the float value will return just a little below the max value. Etc.

Thanks in advance. ^^

---

<div class="post-metadata">

**Author:** ![veccher](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@veccher](https://forums.unrealengine.com/u/veccher)\
**Post date:** [June 23, 2017, 2:37am UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/2 "2017-06-23T02:37:26Z")

</div>

if my math is right this code should return something from 0 to 1 where 0 is opposite rotation and 1 is exactly the same rotation, you need low result for equal and high result for different, just do 1-result of the division, it will do what you want, hope it helps. Try this:

 ![201129-math.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/8/79867af3a07ed42ba48b6ef9667982cf375c8d2e.png)

---

<div class="post-metadata">

**Author:** ![JerichoBLT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JerichoBLT](https://forums.unrealengine.com/u/JerichoBLT)\
**Post date:** [June 24, 2017, 7:35pm UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/3 "2017-06-24T19:35:43Z")

</div>

Yes! That’s perfect! Thank you so much!

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [March 18, 2019, 1:53pm UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/4 "2019-03-18T13:53:01Z")

</div>

Sorry… perhaps a stupid question, but is this input to the numerator here a ‘dot product’? When I’m trying this it says ‘dot’ but I’m not sure what else it should be…

---

<div class="post-metadata">

**Author:** ![THEAETIK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/theaetik/32/1183323_2.png) [@THEAETIK](https://forums.unrealengine.com/u/THEAETIK)\
**Post date:** [October 7, 2021, 1:19am UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/5 "2021-10-07T01:19:28Z")

</div>

Thanks a lot for this. Worked like a charm, I only needed to add +0.5 since it would result -0.5 to positive 0.5.

---

<div class="post-metadata">

**Author:** ![Nodnord](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nodnord](https://forums.unrealengine.com/u/Nodnord)\
**Post date:** [May 2, 2023, 6:07am UTC](https://forums.unrealengine.com/t/how-to-compare-two-rotations/396519/6 "2023-05-02T06:07:09Z")

</div>

That’s right! It is about scalar product of two vectors.
