using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.Visuals.Components
{
internal class PolarPoint
{
///
/// Initializes a new instance of the class.
///
/// The radius.
/// Angle expressed in degrees.
///
/// Radius must be non-negative
/// or
/// Angle must be in range [0,360)
///
public PolarPoint(double radius, double angleDeg)
{
if (radius < 0.0)
throw new ArgumentException("Radius must be non-negative");
if ((angleDeg < 0) || (angleDeg >= 360.0))
throw new ArgumentException("Angle must be in range [0,360)");
Radius = radius;
AngleDeg = angleDeg;
}
///
/// Gets or sets the Polar coordinates.
///
///
/// The radius.
///
public double Radius { get; set; }
///
/// Gets or sets the angle degree.
///
///
/// The angle deg.
///
public double AngleDeg { get; set; }
///
/// Cartesian X Coordinate.
///
///
/// The x.
///
public double X
{
get { return Radius * Math.Cos(AngleDeg * Math.PI / 180.0); }
}
///
/// Cartesian Y Coordinate.
///
///
/// The y.
///
public double Y
{
get { return Radius * Math.Sin(AngleDeg * Math.PI / 180.0); }
}
///
/// Returns a that represents this instance.
///
///
/// A that represents this instance.
///
public override string ToString()
{
return string.Format("({0},{1})", X, Y);
}
}
}