title: Rotate object around world origin
body: <p>I am currently trying to rotate a positionVector (0,0,1) around the world's x-axis and then rotate it back to its original position (just trying to get it to work). I read into rotation matrixes and got it working (sorta) but i am pretty stuck now.</p>
  
  <p>As the image and code shows i create a cube at the starting point (0,0,1) and rotate it down in this case 30 degrees. But it seems to rotate more than 30 degrees when rotating clockwise. However when i rotate it back counterclockwise (30 degrees) it does rotate the proper amount. Which results in it not ending up at its starting point as it should (0,0,1).</p>
  
  <p><img src="https://i.stack.imgur.com/sCpKX.jpg" alt="enter image description here"></p>
  
  <hr>
  
  <p>I was wondering if any of you could shed some light on why this is happening and how to fix it. Thank you guys in advance!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public float RotAngle = 330f;
  
  public GameObject cube;
  public GameObject original;
  public GameObject relocator;
  public GameObject initialTurn;
  
  void Start ()
    {
          Vector3 pixelPos = new Vector3(0f, 0f, 1f);
    
          original = GameObject.Instantiate(cube,pixelPos,Quaternion.identity) as GameObject;
          original.name = "Original";
  
  
          initialTurn = GameObject.Instantiate(cube, pixelPos, Quaternion.identity) as GameObject;
          initialTurn.name = "InitialTurn";
  
          relocator = GameObject.Instantiate(cube, pixelPos, Quaternion.identity) as GameObject;
          relocator.name = "Relocator";
    }
  void Update()
    {
          initialTurn.transform.position = RotateAroundOrigin(original.transform.position, RotAngle*Mathf.Deg2Rad);
          relocator.transform.position = RotateAroundOrigin(initialTurn.transform.position, (RotAngle * -1f) * Mathf.Deg2Rad);
    }
  
  Vector3 RotateAroundOrigin(Vector3 startPos,float angle)
      {
          startPos.Normalize();
          startPos.y = (startPos.y * Mathf.Cos(angle)) - (startPos.z * Mathf.Sin(angle));
          startPos.z = (startPos.y * Mathf.Sin(angle)) + (startPos.z * Mathf.Cos(angle));
          return startPos.normalized;
      }</code></pre>
  </div>
  </div>
  </p>