public static Extent <double> Aspect(this Extent <double> extent, double targetAspect) { var currentAspect = extent.Aspect(); if (Math.Abs(currentAspect) < Math.Abs(targetAspect)) { var width = extent.Width(); var diff = width * (targetAspect / currentAspect - 1) / 2; return(Create(extent.S.X - diff, extent.S.Y, extent.E.X + diff, extent.E.Y)); } else { var height = extent.Height(); var diff = height * (currentAspect / targetAspect - 1) / 2; return(Create(extent.S.X, extent.S.Y - diff, extent.E.X, extent.E.Y + diff)); } }
public static double Aspect(this Extent <int> extent) => extent.Width() * 1.0 / extent.Height();
public static double Area(this Extent <int> extent) => Math.Abs(extent.Width() * extent.Height());
public static double Aspect(this Extent <double> extent) => extent.Width() / extent.Height();