« Reply #2 on: September 05, 2015, 10:00:22 PM »
Just in case you want the result as a math solution :
using System;
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
double radius = 200;
double chordLength = 200;
double circumference = Math.PI * 2.0 * radius;
double enclosedAngleRadians = AngleFromChord(radius, chordLength);
double arcLength = ArcLengthFromChord(radius, chordLength);
Console.WriteLine("Circumference: " + circumference);
Console.WriteLine("Enclosed Angle Radians: " + enclosedAngleRadians);
Console.WriteLine("Enclosed Angle Degrees: " + enclosedAngleRadians * (180.0 / Math.PI));
Console.WriteLine("Arc Length: " + arcLength);
Console.ReadKey();
}
/// <summary>
/// Get the arc length from the radius and enclosed angle
/// </summary>
public static double ArcLengthFromAngle(double radius, double radians) {
return radius * radians;
}
/// <summary>
/// Get the angle from the chordLength (only works for angles <= 180)
/// </summary>
public static double AngleFromChord(double radius, double chordLength) {
return radius != 0.0 ? 2.0 * Math.Asin(chordLength / (radius * 2.0)) : 0.0;
}
/// <summary>
///Get the arc length from the radius and chordLength
/// </summary>
public static double ArcLengthFromChord(double radius, double chordLength) {
if(radius == 0.0)
return chordLength;
return ArcLengthFromAngle(radius, AngleFromChord(radius, chordLength));
}
}
}
« Last Edit: September 05, 2015, 10:06:29 PM by Kerry »
Logged
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.