------------------------------------------------------------------------------ 2D floating-point point.
| 99 | //------------------------------------------------------------------------------ |
| 100 | /// 2D floating-point point. |
| 101 | class Point2F |
| 102 | { |
| 103 | //-------------------------------------- Public data |
| 104 | public: |
| 105 | F32 x; |
| 106 | F32 y; |
| 107 | |
| 108 | public: |
| 109 | Point2F(); ///< Create uninitialized point. |
| 110 | Point2F(const Point2F&); ///< Copy constructor |
| 111 | Point2F(F32 _x, F32 _y); ///< Create point from co-ordinates. |
| 112 | |
| 113 | //-------------------------------------- Non-math mutators and misc functions |
| 114 | public: |
| 115 | void set(F32 _x, F32 _y); ///< Set point's co-ordinates. |
| 116 | |
| 117 | void setMin(const Point2F&); ///< Store lesser co-ordinates. |
| 118 | void setMax(const Point2F&); ///< Store greater co-ordinates. |
| 119 | |
| 120 | /// Interpolate from a to b, based on c. |
| 121 | /// |
| 122 | /// @param a Starting point. |
| 123 | /// @param b Ending point. |
| 124 | /// @param c Interpolation factor (0.0 .. 1.0). |
| 125 | void interpolate(const Point2F& a, const Point2F& b, const F32 c); |
| 126 | |
| 127 | void zero(); ///< Zero all values |
| 128 | |
| 129 | operator F32*() { return &x; } |
| 130 | operator const F32*() const { return &x; } |
| 131 | |
| 132 | //-------------------------------------- Queries |
| 133 | public: |
| 134 | bool isZero() const; ///< Check for zero coordinates. (No epsilon.) |
| 135 | F32 len() const; ///< Get length. |
| 136 | F32 lenSquared() const; ///< Get squared length (one sqrt less than len()). |
| 137 | bool equal( const Point2F &compare ) const; ///< Is compare within POINT_EPSILON of all of the component of this point |
| 138 | F32 magnitudeSafe() const; |
| 139 | |
| 140 | //-------------------------------------- Mathematical mutators |
| 141 | public: |
| 142 | void neg(); ///< Invert signs of co-ordinates. |
| 143 | void normalize(); ///< Normalize vector. |
| 144 | void normalize(F32 val); ///< Normalize, scaling by val. |
| 145 | void normalizeSafe(); |
| 146 | void convolve(const Point2F&); ///< Convolve by parameter. |
| 147 | void convolveInverse(const Point2F&); ///< Inversely convolute by parameter. (ie, divide) |
| 148 | void rotate( F32 radians ); ///< Rotate vector around origin. |
| 149 | |
| 150 | /// Return a perpendicular vector to this one. The result is equivalent to rotating the |
| 151 | /// vector 90 degrees clockwise around the origin. |
| 152 | Point2F getPerpendicular() const { return Point2F( y, - x ); } |
| 153 | |
| 154 | //-------------------------------------- Overloaded operators |
| 155 | public: |
| 156 | // Comparison operators |
| 157 | bool operator==(const Point2F&) const; |
| 158 | bool operator!=(const Point2F&) const; |
no outgoing calls
no test coverage detected