diff --git a/PeyrSharp.Core/Maths/Geometry/Rectangle.cs b/PeyrSharp.Core/Maths/Geometry/Rectangle.cs new file mode 100644 index 0000000..c2bfebf --- /dev/null +++ b/PeyrSharp.Core/Maths/Geometry/Rectangle.cs @@ -0,0 +1,73 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace PeyrSharp.Core.Maths.Geometry +{ + /// + /// A class that represents a rectangle. + /// + public class Rectangle + { + /// + /// The Width of the rectangle. + /// + public double Width { get; init; } + + /// + /// The Height/Length of the rectangle. + /// + public double Height { get; init; } + + /// + /// Creates a from a specific width and height. + /// + /// The width of the rectangle. + /// The height/length of the rectangle. + public Rectangle(double width, double height) + { + // Assign properties to their values + Width = width; + Height = height; + } + + /// + /// Gets the area of this from its and . + /// + public double Area => Width * Height; + + /// + /// Gets the perimeter of this from its and . + /// + public double Perimeter => 2 * (Width + Height); + + /// + /// Gets the diagonal of this from its and . + /// + public double Diagonal => Math.Sqrt(Math.Pow(Width, 2) + Math.Pow(Height, 2)); + } +}