internal override List <PolygonPoint> GetPoints(float thickness = 0) { List <PolygonPoint> points = new List <PolygonPoint>(); int arcSides = (int)Math.Round((arcDegrees / 360f) * sides, MidpointRounding.AwayFromZero); int halfArcSides = arcSides / 2; float offsetDegrees = MathUtil.RadiansToDegrees((float)Math.Tan(thickness / radius)); float degreeStep = (arcDegrees - offsetDegrees) / arcSides; float r = radius - thickness * 0.5f; float t = thickness - (thickness * (arcDegrees / 180)) / 2; points.Add(GetPoint(0, t)); for (int i = -halfArcSides; i <= halfArcSides; i++) { points.Add(GetPoint(degreeStep * i, r)); } if (!Filled) { points.Add(points[0]); } return(points); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="format">The format.</param> /// <param name="formatProvider">The format provider.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public string ToString(string format, IFormatProvider formatProvider) { if (format == null) { return(ToString(formatProvider)); } return(string.Format(formatProvider, "{0}°", MathUtil.RadiansToDegrees(radians).ToString(format, CultureInfo.CurrentCulture))); }
/// <summary> /// Returns the degrees of angle A in a triangle using the law of cosines. /// </summary> /// <param name="A">Position of A.</param> /// <param name="B">Position of B.</param> /// <param name="C">Position of C.</param> public static float Angle(Vector2 A, Vector2 B, Vector2 C) { float lenA = Vector2.Distance(B, C); float lenB = Vector2.Distance(A, C); float lenC = Vector2.Distance(A, B); float tmpAngle = ((lenB * lenB + lenC * lenC - lenA * lenA) / (2 * lenB * lenC)); float radianAngle = (float)Math.Acos(tmpAngle); return(MathUtil.RadiansToDegrees(radianAngle)); }
public string ToString(string format, IFormatProvider formatProvider) { if (format == null) { return(this.ToString(formatProvider)); } return(string.Format(formatProvider, "{0}°", new object[1] { (object)MathUtil.RadiansToDegrees(this.radians).ToString(format, (IFormatProvider)CultureInfo.CurrentCulture) })); }
public override bool Intersects(float x, float y) { float distX = x - TransformedPosition.X; float distY = y - TransformedPosition.Y; float radius = this.radius * TransformedScale.X; float distSquared = (distX * distX) + (distY * distY); float radiusSquared = radius * radius; if (thickness > 1) { float t = thickness * TransformedScale.X; float innerRadiusSquared = (radius - t) * (radius - t); if (distSquared <= radiusSquared && distSquared > innerRadiusSquared) { return(true); } } else if (distSquared <= radiusSquared) { float radians = (float)Math.Atan2(distY, distX) + MathUtil.Pi; float angle = MathUtil.RadiansToDegrees(radians) - TransformedDegrees; if (angle < 0) { angle += 360; } // TODO: Pre-compute left and right angles float leftAngle = arcDegrees * 0.5f; float rightAngle = leftAngle + arcDegrees; //Console.WriteLine("TransformedDegrees: " + TransformedDegrees); //Console.WriteLine("Angle between: " + angle); //Console.WriteLine("left: " + leftAngle + ", right: " + rightAngle); if (angle < leftAngle || angle > rightAngle) { return(false); } //Console.WriteLine("intersects"); return(true); } return(false); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="formatProvider">The format provider.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public string ToString(IFormatProvider formatProvider) { return(string.Format(formatProvider, MathUtil.RadiansToDegrees(radians).ToString("0.##°"))); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public override string ToString() { return(string.Format(CultureInfo.CurrentCulture, MathUtil.RadiansToDegrees(radians).ToString("0.##°"))); }
public string ToString(IFormatProvider formatProvider) { return(string.Format(formatProvider, MathUtil.RadiansToDegrees(this.radians).ToString("0.##°"), new object[0])); }
public override string ToString() { return(string.Format((IFormatProvider)CultureInfo.CurrentCulture, MathUtil.RadiansToDegrees(this.radians).ToString("0.##°"), new object[0])); }