PRectanglef.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 #include <PMath.h>
18 
19 PAPILLON_BEGIN_NAMESPACE
20 
21 class PPoint2Df;
22 class PRectanglei;
23 class PSizef;
24 class PSizei;
25 
34 class PAPILLON_API_CORE PRectanglef : public PObject
35 {
36 public:
37 
41  static const PRectanglef& Bad() { static const PRectanglef BAD; return BAD; }
42 
47  explicit PRectanglef(float x = PMath::NaNf(), float y = PMath::NaNf(), float w = PMath::NaNf(), float h = PMath::NaNf());
48 
52  PRectanglef(const PRectanglef& other);
53 
57  virtual ~PRectanglef();
58 
62  PRectanglef& operator=(const PRectanglef& other);
63 
68  bool IsValid() const;
69 
75  bool operator==(const PRectanglef& other) const;
76 
82  bool operator!=(const PRectanglef& other) const;
83 
87  float GetX() const;
88 
92  float GetY() const;
93 
98  float GetWidth() const;
99 
104  float GetHeight() const;
105 
109  PPoint2Df GetOrigin() const;
110 
114  PSizef GetSize() const;
115 
119  PPoint2Df GetCentre() const;
120 
124  float GetArea() const;
125 
129  float GetOverlapArea(const PRectanglef& i_rectangle) const;
130 
142  float GetDiceCoefficient(const PRectanglef& i_rectangle) const;
143 
148  bool Contains(const PPoint2Df& p) const;
149 
154  bool Contains(const PRectanglef& r) const;
155 
160  PAPILLON_DEPRECATED("This function will be removed in Papillon 5")
161  PRectanglef Expand(float expandBy) const;
162 
166  PRectanglef Expanded(float expandBy) const;
167 
171  PRectanglef Intersected(const PRectanglef& other) const;
172 
177  PRectanglef Scaled(float scaleBy) const;
178 
186  PRectanglef Scaled(float sx, float sy) const;
187 
195  PRectanglef Scaled(const PSizef& size) const;
196 
204  PRectanglef Scaled(const PSizei& size) const;
205 
212  PRectanglef Normalized(float sx, float sy) const;
213 
220  PRectanglef Normalized(const PSizef& size) const;
221 
228  PRectanglef Normalized(const PSizei& size) const;
229 
235  PRectanglef Translated(float xTranslateBy, float yTranslateBy) const;
236 
242  PRectanglef Translated(const PPoint2Df& v) const;
243 
247  PRectanglei ToPRectanglei() const;
248 };
249 
250 PAPILLON_END_NAMESPACE
static float NaNf()
Returns NaN (Not a Number) value for float numbers.
Definition: PMath.h:41
The PPoint2Df class represents a 2D-point with float coordinates; PPoint2Df instances are immutable (...
Definition: PPoint2Df.h:28
The PSizei class represents the size of an image or a rectangle: width (int) and height (int); PSizei...
Definition: PSizei.h:27
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
The PRectanglei class represents an axis-aligned rectangle with 32-bit int coordinates; PRectanglei i...
Definition: PRectanglei.h:33
The PRectanglef class represents an axis-aligned rectangle with float coordinates; PRectanglef instan...
Definition: PRectanglef.h:34
Math toolbox.
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45
The PSizef class represents the size of an image or a rectangle: width (float) and height (float); PS...
Definition: PSizef.h:28
static const PRectanglef & Bad()
Returns an invalid (bad) instance of PRectanglef, made of NaN values.
Definition: PRectanglef.h:41