This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Convert Decimal Degree To Radian Snippet (ArcObjects .NET 10.4 SDK) |
Convert a Decimal Degree to a Radian.
/// <summary> /// Convert a Decimal Degree to a Radian. /// </summary> /// <param name="double_DecimalDegree">A System.Double that is a Decimal Degree value. Example: 180</param> /// <returns>A System.Double that is a Radina value. Example: 3.14</returns> /// <remarks></remarks> public System.Double ConvertDecimalDegreeToRadian(System.Double double_DecimalDegree) { // Create an AngleFormat object and set AngleFormat options through the IAngleFormat interface ESRI.ArcGIS.esriSystem.IAngleFormat angleFormat=new ESRI.ArcGIS.esriSystem.AngleFormatClass(); ESRI.ArcGIS.esriSystem.INumberFormat numberFormat=(ESRI.ArcGIS.esriSystem.INumberFormat)angleFormat; // Explicit Cast // Display radian values. A degree-to-radian conversion takes place in the ValueToString method. angleFormat.AngleInDegrees=true; //Input values are in degrees angleFormat.DisplayDegrees=false; //Display Value in Radians System.String string_Radian=numberFormat.ValueToString(double_DecimalDegree); System.Double double_Radian=System.Convert.ToDouble(string_Radian); return double_Radian; }
''' <summary> ''' Convert a Decimal Degree to a Radian. ''' </summary> ''' <param name="double_DecimalDegree">A System.Double that is a Decimal Degree value. Example: 180</param> ''' <returns>A System.Double that is a Radina value. Example: 3.14</returns> ''' <remarks></remarks> Public Function ConvertDecimalDegreeToRadian(ByVal double_DecimalDegree As System.Double) As System.Double ' Create an AngleFormat object and set AngleFormat options through the IAngleFormat interface Dim angleFormat As ESRI.ArcGIS.esriSystem.IAngleFormat=New ESRI.ArcGIS.esriSystem.AngleFormatClass Dim numberFormat As ESRI.ArcGIS.esriSystem.INumberFormat=CType(angleFormat, ESRI.ArcGIS.esriSystem.INumberFormat) 'Explicit Cast ' Display radian values. A degree-to-radian conversion takes place in the ValueToString method. angleFormat.AngleInDegrees=True 'Input values are in degrees angleFormat.DisplayDegrees=False 'Display Value in Radians Dim string_Radian As System.String=numberFormat.ValueToString(double_DecimalDegree) Dim double_Radian As System.Double=CDbl(string_Radian) Return double_Radian End Function