comparison engine/core/util/structures/point.h @ 646:07b1cf8e92b5

* Major improvements to fife_math.h and added corresponding Python bindings. Users now have access to FIFE's internal math functions. These functions are recommended to be used by all clients if required. Note: this may cause some problems with certain compilers. I hope this wont have to be reverted. TODO: remove the static constant globals somehow. * Adopted the new math functions for all subsystems * Improvements to DeviceCaps. It now detects all possible screen modes. * User can now select 0 for their bpp and it will attempt to initialize SDL with the current screen bpp.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 13 Oct 2010 20:24:48 +0000
parents 291ba2946c73
children bb26a76458c6
comparison
equal deleted inserted replaced
645:291ba2946c73 646:07b1cf8e92b5
129 */ 129 */
130 void normalize() { 130 void normalize() {
131 T invLength = 1.0/length(); 131 T invLength = 1.0/length();
132 132
133 //TODO: get rid of this static cast 133 //TODO: get rid of this static cast
134 if (invLength > static_cast<T>(DBL_ZERO_TOLERANCE)) { 134 if (invLength > static_cast<T>(Mathd::zeroTolerance())) {
135 x = x * invLength; 135 x = x * invLength;
136 y = y * invLength; 136 y = y * invLength;
137 } 137 }
138 else { 138 else {
139 x = 0; 139 x = 0;
143 143
144 /** Rotates the point around the origin 144 /** Rotates the point around the origin
145 */ 145 */
146 void rotate(T angle){ 146 void rotate(T angle){
147 //TODO: get rid of this static cast 147 //TODO: get rid of this static cast
148 T theta = (angle * static_cast<T>(DBL_PI))/180; 148 T theta = (angle * static_cast<T>(Mathd::pi()))/180;
149 T costheta = cos(theta); 149 T costheta = static_cast<T>(Mathd::Cos(theta));
150 T sintheta = sin(theta); 150 T sintheta = static_cast<T>(Mathd::Sin(theta));
151 151
152 T nx = x; 152 T nx = x;
153 T ny = y; 153 T ny = y;
154 154
155 x = costheta * nx - sintheta * ny; 155 x = costheta * nx - sintheta * ny;
158 158
159 /** Rotates the point around an origin 159 /** Rotates the point around an origin
160 */ 160 */
161 void rotate(const PointType2D<T>& origin, T angle){ 161 void rotate(const PointType2D<T>& origin, T angle){
162 //TODO: get rid of this static cast 162 //TODO: get rid of this static cast
163 T theta = (angle * static_cast<T>(DBL_PI))/180; 163 T theta = (angle * static_cast<T>(Mathd::pi()))/180;
164 T costheta = cos(theta); 164 T costheta = static_cast<T>(Mathd::Cos(theta));
165 T sintheta = sin(theta); 165 T sintheta = static_cast<T>(Mathd::Sin(theta));
166 166
167 T nx = x - origin.x; 167 T nx = x - origin.x;
168 T ny = y - origin.y; 168 T ny = y - origin.y;
169 169
170 x = costheta * nx - sintheta * ny; 170 x = costheta * nx - sintheta * ny;
279 */ 279 */
280 void normalize() { 280 void normalize() {
281 T invLength = 1.0/length(); 281 T invLength = 1.0/length();
282 282
283 //TODO: get rid of this static cast 283 //TODO: get rid of this static cast
284 if (invLength > static_cast<T>(DBL_ZERO_TOLERANCE)) { 284 if (invLength > static_cast<T>(Mathd::zeroTolerance())) {
285 x = x * invLength; 285 x = x * invLength;
286 y = y * invLength; 286 y = y * invLength;
287 z = z * invLength; 287 z = z * invLength;
288 } 288 }
289 else { 289 else {