public void GB_BuildEllipseAxisAligned() { var builder = new EllipseBuilder(); const int majorAxis = 8; const int minorAxis = 4; var points = builder.BuildEllipse(Vector2.Zero, majorAxis, minorAxis, 0); foreach (var point in points) { // Equation for an ellipse: // (x/a)^2 + (y/b)^2 = 1 var norm = Vector2.UnitX * point.X / majorAxis + Vector2.UnitY * point.Y / minorAxis; norm.LengthSquared().Should().BeApproximately(1, 0.00001f, $"Point {point} does not satisfy the ellipse equation."); } }
public void GB_BuildEllipseBoundingBox() { var builder = new EllipseBuilder(); const int majorAxis = 8; const int minorAxis = 4; Rectangle boundingBox = new Rectangle(-majorAxis, -minorAxis, majorAxis * 2, minorAxis * 2); var points = builder.BuildEllipse((RectangleF)boundingBox); foreach (var point in points) { // Equation for an ellipse: // (x/a)^2 + (y/b)^2 = 1 var norm = Vector2.UnitX * point.X / majorAxis + Vector2.UnitY * point.Y / minorAxis; norm.LengthSquared().Should().BeApproximately(1, 0.00001f, $"Point {point} does not satisfy the ellipse equation."); } }