using System;
using System.Collections.Generic;
using System.Text;

namespace Vortex.Drawing {

	/// <summary>
	/// Object which contains information about 2D rotation around the origin point
	/// </summary>
	public class Rotation : ITransform {
		private Vector2 _origin;
		private float _angle;

		/// <summary>
		/// Initializes a new instance of the <see cref="Rotation"/> class.
		/// </summary>
		/// <param name="angle">The rotation angle in radian.</param>
		public Rotation(float angle) {
			_angle = angle;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Rotation"/> class.
		/// </summary>
		/// <param name="angle">The rotation angle in radian.</param>
		/// <param name="origin">The origin for rotation.</param>
		public Rotation(float angle, Vector2 origin) {
			_origin = origin;
			_angle = angle;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Rotation"/> class.
		/// </summary>
		/// <param name="angle">The rotation angle in radian.</param>
		/// <param name="originX">The origin X for rotation.</param>
		/// <param name="originY">The origin Y for rotation.</param>
		public Rotation(float angle, float originX, float originY) {
			_origin = new Vector2(originX, originY);
			_angle = angle;
		}

		/// <summary>
		/// Gets or sets the rotation angle in radians.
		/// </summary>
		/// <value>The rotation angle in radians.</value>
		public float Angle {
			get { return _angle; }
			set { _angle = value; }
		}

		/// <summary>
		/// Gets or sets the rotation origin.
		/// </summary>
		/// <value>The rotation origin.</value>
		public Vector2 Origin {
			get { return _origin; }
			set { _origin = value; }
		}

		/// <summary>
		/// Gets or sets the X coordinate of origin.
		/// </summary>
		/// <value>The X origin coord.</value>
		public float OriginX {
			get { return _origin.X; }
			set { _origin.X = value; }
		}

		/// <summary>
		/// Gets or sets the Y coordinate of origin.
		/// </summary>
		/// <value>The Y origin coord.</value>
		public float OriginY {
			get { return _origin.Y; }
			set { _origin.Y = value; }
		}

		/// <summary>
		/// Empty rotation value
		/// </summary>
		/// <value>The empty rotation.</value>
		public static Rotation Empty {
			get { return new Rotation(0); }
		}	

		#region ITransform Members

		/// <summary>
		/// Gets the transform which represents this rotation.
		/// </summary>
		/// <param name="transform">The transform represented by this rotation.</param>
		public void GetTransform(out Transform2D transform) {
			Transform2D.CreateRotation(_angle, ref _origin, out transform);
		}

		#endregion
	}
}
