Rotating a GUI Object Based on Mouse Position with Locked Mouse

So, I’ve been working on this problem for a few days. I have a GUI object on screen that represents where the mouse position is. Not directly, but based on it’s angle to the x-axis . I am able to calculate the angle decently well using Mathf.Atan2, however I’m having some issues. The cursor itself is locked to the center of the screen, so I’ve created variables mouseX and mouseY which are updated to track the mouse cursor using this code:

if (Input.GetAxis ("Mouse Y") > 0) {
   mouseY += 1;
}
else if (Input.GetAxis ("Mouse Y") < 0) {
   mouseY -= 1;
}

if (Input.GetAxis ("Mouse X") > 0) {
   mouseX += 1;
}
else if (Input.GetAxis ("Mouse X") < 0) {
   mouseX -= 1;
}

It works decently well. To fix the issue of the mouse getting lost in a quadrant I clamped both variables between -1 and 1. This works, except this causes the tracking to be confined in a square. What I would like to do is confine the mouse to a circle (the unit circle specifically.) While I know generally I could use the angle to do this, I’m attempting to find the angle, so I don’t have it.

I initially tried to only record mouseY and then calculate mouseX using the formula for the unit circle. The issue with this, is it only allows rotations to occur in the first and fourth quadrant. I’m at a loss for how to do this and any advice would be appreciated. I didn’t include additional code as all of its problems stem from this mouse issue.

So @Slev. I’m not quite sure about what’s exactly the problem, so I created a simple code so you can see if this is what you’re looking for. Create any C# class and replace the contents. If you’re working with JS, it’s a simple code to port in a few seconds.

	public float angle;
	public Texture2D arrow;
	
	private bool initialized = false;
	private GameObject plane;
	
	void Start () {
		plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
		plane.transform.parent = Camera.mainCamera.transform;
		plane.transform.localPosition = new Vector3(0,0,1);
		plane.transform.localScale = Vector3.one * 0.02f;
		plane.transform.eulerAngles = new Vector3(0,270,90);
		
		StartCoroutine(LoadTexture());
	}
	
	IEnumerator LoadTexture()
	{
		WWW loader = new WWW("http://upload.wikimedia.org/wikipedia/en/7/72/Dark_Green_Arrow_Up.png");
		while(!loader.isDone)
		{
			yield return new WaitForSeconds(0.5f);
		}
		
		arrow = new Texture2D(512,512,TextureFormat.PVRTC_RGBA4, false);
		loader.LoadImageIntoTexture(arrow);
		
		plane.renderer.material = new Material(Shader.Find("Transparent/Diffuse"));
		plane.renderer.material.mainTexture = arrow;
		
		initialized = true;
	}
	
	void FixedUpdate()
	{
		if(!initialized)
		{
			return;
		}
		
		Vector2 normalizedPositions = new Vector2((Input.mousePosition.x/Camera.mainCamera.GetScreenWidth()-0.5f), ((Input.mousePosition.y/Camera.mainCamera.GetScreenHeight())-0.5f));
		angle = Mathf.Atan2(normalizedPositions.y, normalizedPositions.x)*Mathf.Rad2Deg;
		
		plane.transform.eulerAngles = new Vector3(angle, 270,90);
	}