# Rotation direction

**URL:** <https://discussions.unity.com/t/rotation-direction/400651>\
**Category:** Mobile\
**Tags:** iOS\
**Created:** [November 1, 2009, 6:55pm UTC](https://discussions.unity.com/t/rotation-direction/400651 "2009-11-01T18:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![friendlydev](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@friendlydev](https://discussions.unity.com/u/friendlydev)\
**Post date:** [November 1, 2009, 6:55pm UTC](https://discussions.unity.com/t/rotation-direction/400651/1 "2009-11-01T18:55:40Z")

</div>

Hello,

in my current game project I need to rotate the camera around a certain spot.

Let’s say, my camera is currently rotated to (0,0,0) and I want to rotate it to (0,72,0). Normally I’d use somthing like:

```auto
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0,72,0), Time.deltaTime);

```

This works just fine, but now I’d also like to decide, whether the camera will rotate to this position clockwise or counter clockwise. Is there a way to make sure the camera will only rotate to the right or to the left?

I guess I need to come up with a method, which takes care of this, so any help will be greatly apprecated.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![andeeeee](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@andeeeee](https://discussions.unity.com/u/andeeeee)\
**Post date:** [November 2, 2009, 10:50pm UTC](https://discussions.unity.com/t/rotation-direction/400651/2 "2009-11-02T22:50:44Z")

</div>

The slerp operation rotates in the direction that will get to the target rotation most directly. This is usually what you want, but if you need to rotate through a reflex angle (ie, \> 180º) then you need to break the rotation down into two angular steps, each less than 180º.

You can detect whether a slerp will rotate to the left or the right using the [cross product](http://unity3d.com/support/documentation/ScriptReference/Vector3.Cross.html) of the two direction vectors. An example of how to do it is in [this thread](http://forum.unity3d.com/viewtopic.php?t=33313).

---

<div class="post-metadata">

**Author:** ![friendlydev](https://avatars.discourse-cdn.com/v4/letter/f/e0b2c6/32.png) [@friendlydev](https://discussions.unity.com/u/friendlydev)\
**Post date:** [November 4, 2009, 12:55am UTC](https://discussions.unity.com/t/rotation-direction/400651/3 "2009-11-04T00:55:55Z")

</div>

Thank you very much!
