public static bool CreateCircumscribed(Vector2 v0, Vector2 v1, Vector2 v2, out Circle2 circle) { Vector2 vector = v1 - v0; Vector2 vector2 = v2 - v0; float[,] array = new float[2, 2]; array[0, 0] = vector.x; array[0, 1] = vector.y; array[1, 0] = vector2.x; array[1, 1] = vector2.y; float[,] a = array; float[] b = new float[] { 0.5f * vector.sqrMagnitude, 0.5f * vector2.sqrMagnitude }; Vector2 b2; if (LinearSystem.Solve2(a, b, out b2, 1E-05f)) { circle.Center = v0 + b2; circle.Radius = b2.magnitude; return(true); } circle = default(Circle2); return(false); }
public static bool Solve2(float[,] A, float[] B, out Vector2 X, float zeroTolerance = 1E-05f) { float[] array; bool flag = LinearSystem.Solve2(A, B, out array, zeroTolerance); if (flag) { X.x = array[0]; X.y = array[1]; } else { X = Vector2ex.Zero; } return(flag); }
internal static bool HeightLineFit2(IList <Vector2> points, out float a, out float b) { float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; int count = points.Count; for (int i = 0; i < count; i++) { num += points[i].x; num2 += points[i].y; num3 += points[i].x * points[i].x; num4 += points[i].x * points[i].y; } float[,] array = new float[2, 2]; array[0, 0] = num3; array[0, 1] = num; array[1, 0] = num; array[1, 1] = (float)count; float[,] a2 = array; float[] b2 = new float[] { num4, num2 }; float[] array2; bool flag = LinearSystem.Solve2(a2, b2, out array2, 1E-05f); if (flag) { a = array2[0]; b = array2[1]; } else { a = 3.40282347E+38f; b = 3.40282347E+38f; } return(flag); }