diff --git a/Quik/QuikGeometry.cs b/Quik/QuikGeometry.cs index addc4fe..2d5ed26 100644 --- a/Quik/QuikGeometry.cs +++ b/Quik/QuikGeometry.cs @@ -87,6 +87,11 @@ namespace Quik { return a.X * b.X + a.Y * b.Y; } + + public override string ToString() + { + return $"({X}; {Y})"; + } } /// @@ -335,16 +340,16 @@ namespace Quik /// /// A rectangle. /// - [DebuggerDisplay("({Right}, {Top}, {Left}, {Bottom})")] + [DebuggerDisplay("({Left}, {Top}, {Right}, {Bottom})")] public struct QRectangle { /// - /// Rectangle maximum point. + /// Position maximum point. /// public QVec2 Max; /// - /// Rectangle minimum point. + /// Position minimum point. /// public QVec2 Min; @@ -362,14 +367,14 @@ namespace Quik public float Top { - get => Max.Y; - set => Max.Y = value; + get => Min.Y; + set => Min.Y = value; } public float Bottom { - get => Min.Y; - set => Min.Y = value; + get => Max.Y; + set => Max.Y = value; } public QVec2 Size @@ -384,10 +389,10 @@ namespace Quik Min = min; } - public QRectangle(float r, float t, float l, float b) + public QRectangle(float r, float b, float l, float t) { - Max = new QVec2() {X = r, Y = t}; - Min = new QVec2() {X = l, Y = b}; + Max = new QVec2() {X = r, Y = b}; + Min = new QVec2() {X = l, Y = t}; } public bool Contains(QVec2 point) @@ -405,11 +410,11 @@ namespace Quik public static QRectangle Intersect(in QRectangle a, in QRectangle b) => new QRectangle( - Math.Min(a.Right, b.Right), - Math.Min(a.Top, b.Top), - Math.Max(a.Left, b.Left), + Math.Max(a.Right, b.Right), Math.Max(a.Bottom, b.Bottom) - ); +, + Math.Min(a.Left, b.Left), + Math.Min(a.Top, b.Top)); } /// @@ -493,19 +498,19 @@ namespace Quik public static void Orthographic(out QMat4 mat, QRectangle bounds, float near = 1, float far = -1) { float a, b, c; - mat = default; + mat = Identity; a = 1.0f/(bounds.Right - bounds.Left); b = 1.0f/(bounds.Top - bounds.Bottom); - c = 1.0f/(near - far); + c = 1.0f/(far - near); mat.M11 = 2 * a; mat.M22 = 2 * b; - mat.M33 = 2 * c; + mat.M33 = -2 * c; - mat.M41 = -a * (bounds.Left + bounds.Right); - mat.M42 = -b * (bounds.Top + bounds.Bottom); - mat.M43 = -c * (near + far); + mat.M14 = -a * (bounds.Left + bounds.Right); + mat.M24 = -b * (bounds.Top + bounds.Bottom); + mat.M34 = -c * (far + near); mat.M44 = 1.0f; } }