From 769c2f4b46956644b93fc30174b7c8c9d4db4f65 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 1 Apr 2015 11:58:05 +0100 Subject: [PATCH] Added isFinite() methods to Point and Rectangle. --- modules/juce_graphics/geometry/juce_Point.h | 3 +++ modules/juce_graphics/geometry/juce_Rectangle.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules/juce_graphics/geometry/juce_Point.h b/modules/juce_graphics/geometry/juce_Point.h index 7cc5d4990c..c62f7c4dde 100644 --- a/modules/juce_graphics/geometry/juce_Point.h +++ b/modules/juce_graphics/geometry/juce_Point.h @@ -58,6 +58,9 @@ public: /** Returns true if the point is (0, 0). */ bool isOrigin() const noexcept { return x == ValueType() && y == ValueType(); } + /** Returns true if the coordinates are finite values. */ + inline bool isFinite() const noexcept { return juce_isfinite(x) && juce_isfinite(y); } + /** Returns the point's x coordinate. */ inline ValueType getX() const noexcept { return x; } diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index 6191d1aa7f..49f2d30079 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -100,6 +100,9 @@ public: /** Returns true if the rectangle's width or height are zero or less */ bool isEmpty() const noexcept { return w <= ValueType() || h <= ValueType(); } + /** Returns true if the rectangle's values are all finite numbers, i.e. not NaN or infinity. */ + inline bool isFinite() const noexcept { return pos.isFinite() && juce_isfinite(w) && juce_isfinite(h); } + /** Returns the x coordinate of the rectangle's left-hand-side. */ inline ValueType getX() const noexcept { return pos.x; }