private static IQuantity CalculateAngular(this IQuantity dimensionless, IPlanarAngle desiredUnit,
                                                  Func <double, double> trigonometry)
        {
            dimensionless.VerifyDimensionless();

            var radian = SiTheta.Radian;

            desiredUnit = desiredUnit ?? radian;

            IQuantity result = new Quantity(trigonometry(dimensionless.Value), radian);

            if (desiredUnit is SiTheta)
            {
                return(result);
            }

            return(result.ConvertTo(desiredUnit));
        }
 /// <summary>
 /// Returns the angle whose tangent is the quotient of two specified numbers.
 /// </summary>
 /// <param name="x">The x coordinate of a point.</param>
 /// <param name="y">The y coordinate of a point.</param>
 /// <param name="desiredUnit"></param>
 /// <returns></returns>
 /// <a href="!:http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx" />
 public static IQuantity Atan2(this IQuantity x, IQuantity y, IPlanarAngle desiredUnit = null)
 {
     return CalculateAngular(x, y, desiredUnit, Math.Atan2);
 }
 /// <summary>
 /// Returns the angle whose tangent is the specified number.
 /// </summary>
 /// <param name="d">A quantity representing a tangent.</param>
 /// <param name="desiredUnit"></param>
 /// <returns></returns>
 /// <a href="!:http://msdn.microsoft.com/en-us/library/system.math.atan.aspx" />
 public static IQuantity Atan(this IQuantity d, IPlanarAngle desiredUnit = null)
 {
     return CalculateAngular(d, desiredUnit, Math.Atan);
 }
        private static IQuantity CalculateAngular(IQuantity x, IQuantity y, IPlanarAngle desiredUnit,
            Func<double, double, double> trigonometry)
        {
            //TODO: just dimensionless?
            x.VerifyDimensionless();
            y.VerifyDimensionless();

            var radian = SiTheta.Radian;

            desiredUnit = desiredUnit ?? radian;

            IQuantity result = new Quantity(trigonometry(x.Value, y.Value), radian);

            if (desiredUnit is SiTheta) return result;

            return result.ConvertTo(desiredUnit);
        }
 /// <summary>
 /// Returns the angle whose tangent is the quotient of two specified numbers.
 /// </summary>
 /// <param name="x">The x coordinate of a point.</param>
 /// <param name="y">The y coordinate of a point.</param>
 /// <param name="desiredUnit"></param>
 /// <returns></returns>
 /// <a href="!:http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx" />
 public static IQuantity Atan2(this IQuantity x, IQuantity y, IPlanarAngle desiredUnit = null)
 {
     return(CalculateAngular(x, y, desiredUnit, Math.Atan2));
 }
 /// <summary>
 /// Returns the angle whose tangent is the specified number.
 /// </summary>
 /// <param name="d">A quantity representing a tangent.</param>
 /// <param name="desiredUnit"></param>
 /// <returns></returns>
 /// <a href="!:http://msdn.microsoft.com/en-us/library/system.math.atan.aspx" />
 public static IQuantity Atan(this IQuantity d, IPlanarAngle desiredUnit = null)
 {
     return(CalculateAngular(d, desiredUnit, Math.Atan));
 }