/// <summary> /// Returns an angle in degrees /// </summary> /// <param name="degreeAngle">Angle in ExxxCW style</param> /// <param name="style"></param> /// <returns></returns> public static double AnglifyD(double degreeAngle, AngleStyle style) { switch (style) { case AngleStyle.E180CCW: degreeAngle = degreeAngle % 360; if (degreeAngle < -180) { degreeAngle += 360; } else if (degreeAngle >= 180) { degreeAngle -= 360; } break; default: degreeAngle = AnglifyD(degreeAngle, AngleStyle.E180CCW); degreeAngle = 90 - degreeAngle; if (degreeAngle < 0) { degreeAngle += 360; } break; } return(degreeAngle); }
public Angle(string str, AngleStyle aStyle) { double dms = 0; if (double.TryParse(str, out dms)) { _seconds = new Angle(dms, aStyle).Seconds; } }
public Angle(double dms, AngleStyle aStyle) { if (aStyle == AngleStyle.Dms) { int deg = (int)(dms + Epsilon) / 10000; int min = (int)(dms - deg * 10000 + Epsilon) / 100; double sec = dms - deg * 10000 - min * 100; _seconds = deg * 3600 + min * 60 + sec; } else if (aStyle == AngleStyle.Deg) { _seconds = dms * 3600; } else if (aStyle == AngleStyle.Rad) { _seconds = dms * Rou; } else { _seconds = dms; } }
public string ToString(AngleStyle astyle, int digits) { string res = ""; double dms = (_seconds < 0) ? -_seconds : _seconds; string sign = (_seconds < 0) ? "-" : ""; double dec = 0.0; if (astyle == AngleStyle.Dms) { int deg = (int)(dms / 3600 + Epsilon); int min = (int)(dms - deg * 3600 + Epsilon) / 60; int sec = (int)(dms - deg * 3600 - min * 60 + Epsilon); dec = dms - deg * 3600 - min * 60 - sec; res = sign + string.Format("{0}{1:00}{2:00}", deg, min, sec); } if (astyle == AngleStyle.Deg) { int deg = (int)(dms / 3600 + Epsilon); dec = dms / 3600.0 - deg; dec = Math.Round(dec, digits); res = sign + string.Format("{0}", deg); } if (astyle == AngleStyle.Rad) { int deg = (int)(dms / Rou + Epsilon); dec = dms / Rou - deg; res = sign + string.Format("{0}", deg); } System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo { NumberDecimalDigits = digits }; string str = dec.ToString("N", provider); str = str.Remove(0, 1); res += str; return(res); }
public string ToString(AngleStyle astyle) { return(ToString(astyle, 8)); }
/// <summary> /// Returns an angle in degrees /// </summary> /// <param name="vector"></param> /// <param name="style"></param> /// <returns></returns> public static double AnglifyD(PointD vector, AngleStyle style) { return(AnglifyD(ToDegrees(GetAngleR(vector)), style)); }