PPoint2Df.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 <PMath.h>
17 #include <PObject.h>
18 
19 PAPILLON_BEGIN_NAMESPACE
20 
21 class PPoint2Di;
22 
28 class PAPILLON_API_CORE PPoint2Df : public PObject
29 {
30 public:
34  static const PPoint2Df& Bad() { static const PPoint2Df BAD(PMath::NaNf(), PMath::NaNf()); return BAD; }
35 
39  static const PPoint2Df& Zero() { static const PPoint2Df ZERO(0.0f, 0.0f); return ZERO; }
40 
44  explicit PPoint2Df(float xx = 0.0f, float yy = 0.0f);
45 
49  explicit PPoint2Df(double xx, double yy);
50 
54  explicit PPoint2Df(papillon::int32 xx, papillon::int32 yy);
55 
59  PPoint2Df(const PPoint2Df& other);
60 
64  virtual ~PPoint2Df();
65 
69  PPoint2Df& operator=(const PPoint2Df& other);
70 
74  float GetX() const;
75 
79  float GetY() const;
80 
85  bool IsValid() const;
86 
91  bool IsBad() const;
92 
98  bool operator==(const PPoint2Df& other) const;
99 
105  bool operator!=(const PPoint2Df& other) const;
106 
111  PPoint2Df operator+(const PPoint2Df& v) const;
112 
117  PPoint2Df operator-(const PPoint2Df& v) const;
118 
122  PPoint2Df operator-() const;
123 
127  PPoint2Df operator*(float scaleBy) const;
128 
133  PPoint2Df Translated(float vx, float vy) const;
134 
139  PPoint2Df Translated(const PPoint2Df& v) const;
140 
145  PPoint2Df Scaled(float scaleBy) const;
146 
150  PPoint2Di ToPPoint2Di() const;
151 
155  float EuclideanDistance(const PPoint2Df& other) const;
156 
160  static PPoint2Df Middle(const PPoint2Df& A, const PPoint2Df& B);
161 };
162 
163 PAPILLON_END_NAMESPACE
static const PPoint2Df & Bad()
Returns the constant holding the bad instance of a PPoint2Df.
Definition: PPoint2Df.h:34
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
static const PPoint2Df & Zero()
Returns the constant holding the point (0,0).
Definition: PPoint2Df.h:39
PAPILLON_API_CORE papillon::PString operator+(const papillon::PString &lhs, const papillon::PString &rhs)
Constructs a new string by concatenating string lhs with string rhs.
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
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 PPoint2Di class represents a 2D-point with 32-bit int coordinates; PPoint2Di instances are immuta...
Definition: PPoint2Di.h:27