C# 弧度转角度 度分秒的代码
时间: 2023-09-05 15:11:05 浏览: 126
下面是 C# 中弧度转角度、度分秒的代码:
```csharp
public static double RadianToDegree(double angle)
{
return angle * (180.0 / Math.PI);
}
public static double DegreeToRadian(double angle)
{
return Math.PI * angle / 180.0;
}
public static string DegreeToDMS(double angle)
{
int degrees = (int)angle;
double minutes = (angle - degrees) * 60;
int seconds = (int)(minutes - (int)minutes) * 60;
return degrees + "°" + (int)minutes + "'" + seconds + "''";
}
public static double DMSToDegree(double degrees, double minutes, double seconds)
{
return degrees + minutes / 60 + seconds / 3600;
}
```
其中,`RadianToDegree` 和 `DegreeToRadian` 分别用于将弧度转换为角度和将角度转换为弧度。`DegreeToDMS` 用于将角度转换为度分秒的形式,返回字符串类型。`DMSToDegree` 用于将度分秒转换为角度,返回 double 类型。