MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / Point2D

Class Point2D

Engine/source/math/mPoint2.h:193–263  ·  view source on GitHub ↗

------------------------------------------------------------------------------ 2D high-precision point. Uses F64 internally.

Source from the content-addressed store, hash-verified

191///
192/// Uses F64 internally.
193class Point2D
194{
195 //-------------------------------------- Public data
196 public:
197 F64 x; ///< X co-ordinate.
198 F64 y; ///< Y co-ordinate.
199
200 public:
201 Point2D(); ///< Create uninitialized point.
202 Point2D(const Point2D&); ///< Copy constructor
203 Point2D(F64 _x, F64 _y); ///< Create point from coordinates.
204
205 //-------------------------------------- Non-math mutators and misc functions
206 public:
207 void set(F64 _x, F64 _y); ///< Set point's coordinates.
208
209 void setMin(const Point2D&); ///< Store lesser co-ordinates.
210 void setMax(const Point2D&); ///< Store greater co-ordinates.
211
212 /// Interpolate from a to b, based on c.
213 ///
214 /// @param a Starting point.
215 /// @param b Ending point.
216 /// @param c Interpolation factor (0.0 .. 1.0).
217 void interpolate(const Point2D &a, const Point2D &b, const F64 c);
218
219 void zero(); ///< Zero all values
220
221 operator F64*() { return &x; }
222 operator const F64*() const { return &x; }
223
224 //-------------------------------------- Queries
225 public:
226 bool isZero() const;
227 F64 len() const;
228 F64 lenSquared() const;
229
230 //-------------------------------------- Mathematical mutators
231 public:
232 void neg();
233 void normalize();
234 void normalize(F64 val);
235 void convolve(const Point2D&);
236 void convolveInverse(const Point2D&);
237
238 //-------------------------------------- Overloaded operators
239 public:
240 // Comparison operators
241 bool operator==(const Point2D&) const;
242 bool operator!=(const Point2D&) const;
243
244 // Arithmetic w/ other points
245 Point2D operator+(const Point2D&) const;
246 Point2D operator-(const Point2D&) const;
247 Point2D& operator+=(const Point2D&);
248 Point2D& operator-=(const Point2D&);
249
250 // Arithmetic w/ scalars

Callers 4

operator+Method · 0.85
operator-Method · 0.85
operator*Method · 0.85
operator/Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected