mPoint.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _MPOINT_H_
  23. #define _MPOINT_H_
  24. #define POINT_EPSILON (1e-4) ///< Epsilon for point types.
  25. //-------------------------------------- Note: because of a circular dependency,
  26. // the mMathFn.h header is below the point
  27. // class declarations... DMM
  28. #ifndef _PLATFORM_H_
  29. #include "platform/platform.h"
  30. #endif
  31. //------------------------------------------------------------------------------
  32. /// 2D integer point
  33. ///
  34. /// Uses S32 internally.
  35. class Point2I
  36. {
  37. //-------------------------------------- Public data
  38. public:
  39. S32 x; ///< X position
  40. S32 y; ///< Y position
  41. //-------------------------------------- Public interface
  42. public:
  43. Point2I(); ///< Create an uninitialized point.
  44. Point2I(const Point2I&); ///< Copy constructor
  45. Point2I(const S32 in_x, const S32 in_y); ///< Create point from two co-ordinates.
  46. //-------------------------------------- Non-math mutators and misc functions
  47. void set(const S32 in_x, const S32 in_y);///< Set (x,y) position
  48. void setMin(const Point2I&); ///< Store lesser co-ordinates from parameter in this point.
  49. void setMax(const Point2I&); ///< Store greater co-ordinates from parameter in this point.
  50. //-------------------------------------- Math mutators
  51. void neg(); ///< Invert sign of point's co-ordinates.
  52. void convolve(const Point2I&); ///< Convolve this point by parameter.
  53. //-------------------------------------- Queries
  54. bool isZero() const; ///< Is this point at the origin? (No epsilon used)
  55. F32 len() const; ///< Get the length of the point
  56. //-------------------------------------- Overloaded operators
  57. public:
  58. // Comparison operators
  59. bool operator==(const Point2I&) const;
  60. bool operator!=(const Point2I&) const;
  61. // Arithmetic w/ other points
  62. Point2I operator+(const Point2I&) const;
  63. Point2I operator-(const Point2I&) const;
  64. Point2I& operator+=(const Point2I&);
  65. Point2I& operator-=(const Point2I&);
  66. // Arithmetic w/ scalars
  67. Point2I operator*(const S32) const;
  68. Point2I& operator*=(const S32);
  69. Point2I operator/(const S32) const;
  70. Point2I& operator/=(const S32);
  71. // Unary operators
  72. Point2I operator-() const;
  73. };
  74. //------------------------------------------------------------------------------
  75. /// 3D integer point
  76. ///
  77. /// Uses S32 internally.
  78. class Point3I
  79. {
  80. //-------------------------------------- Public data
  81. public:
  82. S32 x; ///< X co-ordinate
  83. S32 y; ///< Y co-ordinate
  84. S32 z; ///< Z co-ordinate
  85. //-------------------------------------- Public interface
  86. public:
  87. Point3I(); ///< Create an uninitialized point.
  88. Point3I(const Point3I&); ///< Copy constructor.
  89. Point3I(const S32 in_x, const S32 in_y, const S32 in_z); ///< Create a point from co-ordinates.
  90. //-------------------------------------- Non-math mutators and misc functions
  91. void set(const S32 in_x, const S32 in_y, const S32 in_z);///< Set co-ordinates.
  92. void setMin(const Point3I&); ///< Store lesser co-ordinates in this point.
  93. void setMax(const Point3I&); ///< Store greater co-ordinates in this point.
  94. //-------------------------------------- Math mutators
  95. void neg(); ///< Invert co-ordinate's signs.
  96. void convolve(const Point3I&); ///< Convolve by paramater.
  97. //-------------------------------------- Queries
  98. bool isZero() const; ///< Check for point at origin. (No epsilon.)
  99. F32 len() const; ///< Get length.
  100. //-------------------------------------- Overloaded operators
  101. public:
  102. // Comparison operators
  103. bool operator==(const Point3I&) const;
  104. bool operator!=(const Point3I&) const;
  105. // Arithmetic w/ other points
  106. Point3I operator+(const Point3I&) const;
  107. Point3I operator-(const Point3I&) const;
  108. Point3I& operator+=(const Point3I&);
  109. Point3I& operator-=(const Point3I&);
  110. // Arithmetic w/ scalars
  111. Point3I operator*(const S32) const;
  112. Point3I& operator*=(const S32);
  113. Point3I operator/(const S32) const;
  114. Point3I& operator/=(const S32);
  115. // Unary operators
  116. Point3I operator-() const;
  117. };
  118. //------------------------------------------------------------------------------
  119. /// 2D floating-point point.
  120. class Point2F
  121. {
  122. //-------------------------------------- Public data
  123. public:
  124. F32 x;
  125. F32 y;
  126. public:
  127. Point2F(); ///< Create uninitialized point.
  128. Point2F(const Point2F&); ///< Copy constructor
  129. Point2F(const F32 _x, const F32 _y); ///< Create point from co-ordinates.
  130. //-------------------------------------- Non-math mutators and misc functions
  131. public:
  132. void set(const F32 _x, const F32 _y);///< Set point's co-ordinates.
  133. void setMin(const Point2F&); ///< Store lesser co-ordinates.
  134. void setMax(const Point2F&); ///< Store greater co-ordinates.
  135. /// Interpolate from a to b, based on c.
  136. ///
  137. /// @param a Starting point.
  138. /// @param b Ending point.
  139. /// @param c Interpolation factor (0.0 .. 1.0).
  140. void interpolate(const Point2F& a, const Point2F& b, const F32 c);
  141. operator F32*() { return (&x); }
  142. operator F32*() const { return (F32*)(&x); }
  143. //-------------------------------------- Queries
  144. public:
  145. bool isZero() const; ///< Check for zero coordinates. (No epsilon.)
  146. F32 len() const; ///< Get length.
  147. F32 lenSquared() const; ///< Get squared length (one sqrt less than len()).
  148. //-------------------------------------- Mathematical mutators
  149. public:
  150. void neg(); ///< Invert signs of co-ordinates.
  151. void normalize(); ///< Normalize vector.
  152. void normalize(F32 val); ///< Normalize, scaling by val.
  153. void convolve(const Point2F&); ///< Convolve by parameter.
  154. void convolveInverse(const Point2F&); ///< Inversely convolute by parameter. (ie, divide)
  155. //Luma: Utility function to round a Point2F
  156. void round() {x = (F32)((S32)(x + 0.5f)); y = (F32)((S32)(y + 0.5f));}
  157. //-------------------------------------- Overloaded operators
  158. public:
  159. // Comparison operators
  160. bool operator==(const Point2F&) const;
  161. bool operator!=(const Point2F&) const;
  162. // Arithmetic w/ other points
  163. Point2F operator+(const Point2F&) const;
  164. Point2F operator-(const Point2F&) const;
  165. Point2F& operator+=(const Point2F&);
  166. Point2F& operator-=(const Point2F&);
  167. // Arithmetic w/ scalars
  168. Point2F operator*(const F32) const;
  169. Point2F operator/(const F32) const;
  170. Point2F& operator*=(const F32);
  171. Point2F& operator/=(const F32);
  172. // Unary operators
  173. Point2F operator-() const;
  174. };
  175. //------------------------------------------------------------------------------
  176. /// 2D high-precision point.
  177. ///
  178. /// Uses F64 internally.
  179. class Point2D
  180. {
  181. //-------------------------------------- Public data
  182. public:
  183. F64 x; ///< X co-ordinate.
  184. F64 y; ///< Y co-ordinate.
  185. public:
  186. Point2D(); ///< Create uninitialized point.
  187. Point2D(const Point2D&); ///< Copy constructor
  188. Point2D(const F64 _x, const F64 _y); ///< Create point from coordinates.
  189. //-------------------------------------- Non-math mutators and misc functions
  190. public:
  191. void set(const F64 _x, const F64 _y);///< Set point's coordinates.
  192. void setMin(const Point2D&); ///< Store lesser co-ordinates.
  193. void setMax(const Point2D&); ///< Store greater co-ordinates.
  194. /// Interpolate from a to b, based on c.
  195. ///
  196. /// @param a Starting point.
  197. /// @param b Ending point.
  198. /// @param c Interpolation factor (0.0 .. 1.0).
  199. void interpolate(const Point2D &a, const Point2D &b, const F64 c);
  200. operator F64*() { return (&x); }
  201. operator F64*() const { return (F64*)(&x); }
  202. //-------------------------------------- Queries
  203. public:
  204. bool isZero() const;
  205. F64 len() const;
  206. F64 lenSquared() const;
  207. //-------------------------------------- Mathematical mutators
  208. public:
  209. void neg();
  210. void normalize();
  211. void normalize(F64 val);
  212. void convolve(const Point2D&);
  213. void convolveInverse(const Point2D&);
  214. //-------------------------------------- Overloaded operators
  215. public:
  216. // Comparison operators
  217. bool operator==(const Point2D&) const;
  218. bool operator!=(const Point2D&) const;
  219. // Arithmetic w/ other points
  220. Point2D operator+(const Point2D&) const;
  221. Point2D operator-(const Point2D&) const;
  222. Point2D& operator+=(const Point2D&);
  223. Point2D& operator-=(const Point2D&);
  224. // Arithmetic w/ scalars
  225. Point2D operator*(const F64) const;
  226. Point2D operator/(const F64) const;
  227. Point2D& operator*=(const F64);
  228. Point2D& operator/=(const F64);
  229. // Unary operators
  230. Point2D operator-() const;
  231. };
  232. //------------------------------------------------------------------------------
  233. class Point3F
  234. {
  235. //-------------------------------------- Public data
  236. public:
  237. F32 x;
  238. F32 y;
  239. F32 z;
  240. public:
  241. Point3F();
  242. Point3F(const Point3F&);
  243. Point3F(const F32 _x, const F32 _y, const F32 _z);
  244. //-------------------------------------- Non-math mutators and misc functions
  245. public:
  246. void set(const F32 _x, const F32 _y, const F32 _z);
  247. void set(const Point3F&);
  248. void setMin(const Point3F&);
  249. void setMax(const Point3F&);
  250. void interpolate(const Point3F&, const Point3F&, const F32);
  251. void zero();
  252. F32& operator [](int i) { /*ASSERT HERE??*/ return( *((&x)+i) ); }
  253. operator F32*() { return (&x); }
  254. operator F32*() const { return (F32*)(&x); }
  255. //-------------------------------------- Queries
  256. public:
  257. bool isZero() const;
  258. F32 len() const;
  259. F32 lenSquared() const;
  260. F32 magnitudeSafe();
  261. bool equal( Point3F &compare );
  262. //-------------------------------------- Mathematical mutators
  263. public:
  264. void neg();
  265. void normalize();
  266. void normalizeSafe();
  267. void normalize(F32 val);
  268. void convolve(const Point3F&);
  269. void convolveInverse(const Point3F&);
  270. //-------------------------------------- Overloaded operators
  271. public:
  272. // Comparison operators
  273. bool operator==(const Point3F&) const;
  274. bool operator!=(const Point3F&) const;
  275. // Arithmetic w/ other points
  276. Point3F operator+(const Point3F&) const;
  277. Point3F operator-(const Point3F&) const;
  278. Point3F& operator+=(const Point3F&);
  279. Point3F& operator-=(const Point3F&);
  280. // Arithmetic w/ scalars
  281. Point3F operator*(const F32) const;
  282. Point3F operator/(const F32) const;
  283. Point3F& operator*=(const F32);
  284. Point3F& operator/=(const F32);
  285. Point3F operator*(const Point3F&) const;
  286. Point3F& operator*=(const Point3F&);
  287. // Unary operators
  288. Point3F operator-() const;
  289. };
  290. typedef Point3F VectorF;
  291. typedef Point3F EulerF;
  292. //------------------------------------------------------------------------------
  293. class Point3D
  294. {
  295. //-------------------------------------- Public data
  296. public:
  297. F64 x;
  298. F64 y;
  299. F64 z;
  300. public:
  301. Point3D();
  302. Point3D(const Point3D&);
  303. Point3D(const F64 _x, const F64 _y, const F64 _z);
  304. //-------------------------------------- Non-math mutators and misc functions
  305. public:
  306. void set(const F64 _x, const F64 _y, const F64 _z);
  307. void setMin(const Point3D&);
  308. void setMax(const Point3D&);
  309. void interpolate(const Point3D&, const Point3D&, const F64);
  310. operator F64*() { return (&x); }
  311. operator F64*() const { return (F64*)(&x); }
  312. //-------------------------------------- Queries
  313. public:
  314. bool isZero() const;
  315. F64 len() const;
  316. F64 lenSquared() const;
  317. //-------------------------------------- Mathematical mutators
  318. public:
  319. void neg();
  320. void normalize();
  321. void normalize(F64 val);
  322. void convolve(const Point3D&);
  323. void convolveInverse(const Point3D&);
  324. //-------------------------------------- Overloaded operators
  325. public:
  326. // Comparison operators
  327. bool operator==(const Point3D&) const;
  328. bool operator!=(const Point3D&) const;
  329. // Arithmetic w/ other points
  330. Point3D operator+(const Point3D&) const;
  331. Point3D operator-(const Point3D&) const;
  332. Point3D& operator+=(const Point3D&);
  333. Point3D& operator-=(const Point3D&);
  334. // Arithmetic w/ scalars
  335. Point3D operator*(const F64) const;
  336. Point3D operator/(const F64) const;
  337. Point3D& operator*=(const F64);
  338. Point3D& operator/=(const F64);
  339. // Unary operators
  340. Point3D operator-() const;
  341. };
  342. //------------------------------------------------------------------------------
  343. /// 4D floating-point point.
  344. ///
  345. /// Uses F32 internally.
  346. ///
  347. /// Useful for representing quaternions and other 4d beasties.
  348. class Point4F
  349. {
  350. //-------------------------------------- Public data
  351. public:
  352. F32 x; ///< X co-ordinate.
  353. F32 y; ///< Y co-ordinate.
  354. F32 z; ///< Z co-ordinate.
  355. F32 w; ///< W co-ordinate.
  356. public:
  357. Point4F(); ///< Create an unitialized point.
  358. Point4F(const Point4F&); ///< Copy constructor.
  359. /// Create point from coordinates.
  360. Point4F(const F32 _x, const F32 _y, const F32 _z, const F32 _w);
  361. /// Set point's coordinates.
  362. void set(const F32 _x, const F32 _y, const F32 _z, const F32 _w);
  363. /// Interpolate from _pt1 to _pt2, based on _factor.
  364. ///
  365. /// @param _pt1 Starting point.
  366. /// @param _pt2 Ending point.
  367. /// @param _factor Interpolation factor (0.0 .. 1.0).
  368. void interpolate(const Point4F& _pt1, const Point4F& _pt2, const F32 _factor);
  369. operator F32*() { return (&x); }
  370. operator F32*() const { return (F32*)(&x); }
  371. };
  372. typedef Point4F Vector4F; ///< Points can be vectors!
  373. #ifndef _MMATHFN_H_
  374. #include "math/mMathFn.h"
  375. #endif
  376. //------------------------------------------------------------------------------
  377. //-------------------------------------- Inline functions inclusions
  378. //------------------------------------------------------------------------------
  379. //-------------------------------------- Point2I
  380. //
  381. inline Point2I::Point2I()
  382. {
  383. //
  384. }
  385. inline Point2I::Point2I(const Point2I& _copy)
  386. : x(_copy.x), y(_copy.y)
  387. {
  388. //
  389. }
  390. inline Point2I::Point2I(const S32 _x, const S32 _y)
  391. : x(_x), y(_y)
  392. {
  393. //
  394. }
  395. inline void Point2I::set(const S32 _x, const S32 _y)
  396. {
  397. x = _x;
  398. y = _y;
  399. }
  400. inline void Point2I::setMin(const Point2I& _test)
  401. {
  402. x = (_test.x < x) ? _test.x : x;
  403. y = (_test.y < y) ? _test.y : y;
  404. }
  405. inline void Point2I::setMax(const Point2I& _test)
  406. {
  407. x = (_test.x > x) ? _test.x : x;
  408. y = (_test.y > y) ? _test.y : y;
  409. }
  410. inline void Point2I::neg()
  411. {
  412. x = -x;
  413. y = -y;
  414. }
  415. inline void Point2I::convolve(const Point2I& c)
  416. {
  417. x *= c.x;
  418. y *= c.y;
  419. }
  420. inline bool Point2I::isZero() const
  421. {
  422. return ((x == 0) && (y == 0));
  423. }
  424. inline F32 Point2I::len() const
  425. {
  426. return mSqrt(F32(x*x + y*y));
  427. }
  428. inline bool Point2I::operator==(const Point2I& _test) const
  429. {
  430. return ((x == _test.x) && (y == _test.y));
  431. }
  432. inline bool Point2I::operator!=(const Point2I& _test) const
  433. {
  434. return (operator==(_test) == false);
  435. }
  436. inline Point2I Point2I::operator+(const Point2I& _add) const
  437. {
  438. return Point2I(x + _add.x, y + _add.y);
  439. }
  440. inline Point2I Point2I::operator-(const Point2I& _rSub) const
  441. {
  442. return Point2I(x - _rSub.x, y - _rSub.y);
  443. }
  444. inline Point2I& Point2I::operator+=(const Point2I& _add)
  445. {
  446. x += _add.x;
  447. y += _add.y;
  448. return *this;
  449. }
  450. inline Point2I& Point2I::operator-=(const Point2I& _rSub)
  451. {
  452. x -= _rSub.x;
  453. y -= _rSub.y;
  454. return *this;
  455. }
  456. inline Point2I Point2I::operator-() const
  457. {
  458. return Point2I(-x, -y);
  459. }
  460. inline Point2I Point2I::operator*(const S32 mul) const
  461. {
  462. return Point2I(x * mul, y * mul);
  463. }
  464. inline Point2I Point2I::operator/(const S32 div) const
  465. {
  466. AssertFatal(div != 0, "Error, div by zero attempted");
  467. return Point2I(x/div, y/div);
  468. }
  469. inline Point2I& Point2I::operator*=(const S32 mul)
  470. {
  471. x *= mul;
  472. y *= mul;
  473. return *this;
  474. }
  475. inline Point2I& Point2I::operator/=(const S32 div)
  476. {
  477. AssertFatal(div != 0, "Error, div by zero attempted");
  478. x /= div;
  479. y /= div;
  480. return *this;
  481. }
  482. //------------------------------------------------------------------------------
  483. //-------------------------------------- Point3I
  484. //
  485. inline Point3I::Point3I()
  486. {
  487. //
  488. }
  489. inline Point3I::Point3I(const Point3I& _copy)
  490. : x(_copy.x), y(_copy.y), z(_copy.z)
  491. {
  492. //
  493. }
  494. inline Point3I::Point3I(const S32 _x, const S32 _y, const S32 _z)
  495. : x(_x), y(_y), z(_z)
  496. {
  497. //
  498. }
  499. inline void Point3I::set(const S32 _x, const S32 _y, const S32 _z)
  500. {
  501. x = _x;
  502. y = _y;
  503. z = _z;
  504. }
  505. inline void Point3I::setMin(const Point3I& _test)
  506. {
  507. x = (_test.x < x) ? _test.x : x;
  508. y = (_test.y < y) ? _test.y : y;
  509. z = (_test.z < z) ? _test.z : z;
  510. }
  511. inline void Point3I::setMax(const Point3I& _test)
  512. {
  513. x = (_test.x > x) ? _test.x : x;
  514. y = (_test.y > y) ? _test.y : y;
  515. z = (_test.z > z) ? _test.z : z;
  516. }
  517. inline void Point3I::neg()
  518. {
  519. x = -x;
  520. y = -y;
  521. z = -z;
  522. }
  523. inline F32 Point3I::len() const
  524. {
  525. return mSqrt(F32(x*x + y*y + z*z));
  526. }
  527. inline void Point3I::convolve(const Point3I& c)
  528. {
  529. x *= c.x;
  530. y *= c.y;
  531. z *= c.z;
  532. }
  533. inline bool Point3I::isZero() const
  534. {
  535. return ((x == 0) && (y == 0) && (z == 0));
  536. }
  537. inline bool Point3I::operator==(const Point3I& _test) const
  538. {
  539. return ((x == _test.x) && (y == _test.y) && (z == _test.z));
  540. }
  541. inline bool Point3I::operator!=(const Point3I& _test) const
  542. {
  543. return (operator==(_test) == false);
  544. }
  545. inline Point3I Point3I::operator+(const Point3I& _add) const
  546. {
  547. return Point3I(x + _add.x, y + _add.y, z + _add.z);
  548. }
  549. inline Point3I Point3I::operator-(const Point3I& _rSub) const
  550. {
  551. return Point3I(x - _rSub.x, y - _rSub.y, z - _rSub.z);
  552. }
  553. inline Point3I& Point3I::operator+=(const Point3I& _add)
  554. {
  555. x += _add.x;
  556. y += _add.y;
  557. z += _add.z;
  558. return *this;
  559. }
  560. inline Point3I& Point3I::operator-=(const Point3I& _rSub)
  561. {
  562. x -= _rSub.x;
  563. y -= _rSub.y;
  564. z -= _rSub.z;
  565. return *this;
  566. }
  567. inline Point3I Point3I::operator-() const
  568. {
  569. return Point3I(-x, -y, -z);
  570. }
  571. inline Point3I Point3I::operator*(const S32 mul) const
  572. {
  573. return Point3I(x * mul, y * mul, z * mul);
  574. }
  575. inline Point3I Point3I::operator/(const S32 div) const
  576. {
  577. AssertFatal(div != 0, "Error, div by zero attempted");
  578. return Point3I(x/div, y/div, z/div);
  579. }
  580. inline Point3I& Point3I::operator*=(const S32 mul)
  581. {
  582. x *= mul;
  583. y *= mul;
  584. z *= mul;
  585. return *this;
  586. }
  587. inline Point3I& Point3I::operator/=(const S32 div)
  588. {
  589. AssertFatal(div != 0, "Error, div by zero attempted");
  590. x /= div;
  591. y /= div;
  592. z /= div;
  593. return *this;
  594. }
  595. //------------------------------------------------------------------------------
  596. //-------------------------------------- Point2F
  597. //
  598. inline Point2F::Point2F()
  599. {
  600. //
  601. }
  602. inline Point2F::Point2F(const Point2F& _copy)
  603. : x(_copy.x), y(_copy.y)
  604. {
  605. //
  606. }
  607. inline Point2F::Point2F(const F32 _x, const F32 _y)
  608. : x(_x), y(_y)
  609. {
  610. }
  611. inline void Point2F::set(const F32 _x, const F32 _y)
  612. {
  613. x = _x;
  614. y = _y;
  615. }
  616. inline void Point2F::setMin(const Point2F& _test)
  617. {
  618. x = (_test.x < x) ? _test.x : x;
  619. y = (_test.y < y) ? _test.y : y;
  620. }
  621. inline void Point2F::setMax(const Point2F& _test)
  622. {
  623. x = (_test.x > x) ? _test.x : x;
  624. y = (_test.y > y) ? _test.y : y;
  625. }
  626. inline void Point2F::interpolate(const Point2F& _rFrom, const Point2F& _to, const F32 _factor)
  627. {
  628. AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
  629. x = (_rFrom.x * (1.0f - _factor)) + (_to.x * _factor);
  630. y = (_rFrom.y * (1.0f - _factor)) + (_to.y * _factor);
  631. }
  632. inline bool Point2F::isZero() const
  633. {
  634. return (x == 0.0f) && (y == 0.0f);
  635. }
  636. inline F32 Point2F::lenSquared() const
  637. {
  638. return (x * x) + (y * y);
  639. }
  640. inline void Point2F::neg()
  641. {
  642. x = -x;
  643. y = -y;
  644. }
  645. inline void Point2F::convolve(const Point2F& c)
  646. {
  647. x *= c.x;
  648. y *= c.y;
  649. }
  650. inline void Point2F::convolveInverse(const Point2F& c)
  651. {
  652. x /= c.x;
  653. y /= c.y;
  654. }
  655. inline bool Point2F::operator==(const Point2F& _test) const
  656. {
  657. return (x == _test.x) && (y == _test.y);
  658. }
  659. inline bool Point2F::operator!=(const Point2F& _test) const
  660. {
  661. return operator==(_test) == false;
  662. }
  663. inline Point2F Point2F::operator+(const Point2F& _add) const
  664. {
  665. return Point2F(x + _add.x, y + _add.y);
  666. }
  667. inline Point2F Point2F::operator-(const Point2F& _rSub) const
  668. {
  669. return Point2F(x - _rSub.x, y - _rSub.y);
  670. }
  671. inline Point2F& Point2F::operator+=(const Point2F& _add)
  672. {
  673. x += _add.x;
  674. y += _add.y;
  675. return *this;
  676. }
  677. inline Point2F& Point2F::operator-=(const Point2F& _rSub)
  678. {
  679. x -= _rSub.x;
  680. y -= _rSub.y;
  681. return *this;
  682. }
  683. inline Point2F Point2F::operator*(const F32 _mul) const
  684. {
  685. return Point2F(x * _mul, y * _mul);
  686. }
  687. inline Point2F Point2F::operator/(const F32 _div) const
  688. {
  689. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  690. F32 inv = 1.0f / _div;
  691. return Point2F(x * inv, y * inv);
  692. }
  693. inline Point2F& Point2F::operator*=(const F32 _mul)
  694. {
  695. x *= _mul;
  696. y *= _mul;
  697. return *this;
  698. }
  699. inline Point2F& Point2F::operator/=(const F32 _div)
  700. {
  701. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  702. F32 inv = 1.0f / _div;
  703. x *= inv;
  704. y *= inv;
  705. return *this;
  706. }
  707. inline Point2F Point2F::operator-() const
  708. {
  709. return Point2F(-x, -y);
  710. }
  711. inline F32 Point2F::len() const
  712. {
  713. return mSqrt(x*x + y*y);
  714. }
  715. inline void Point2F::normalize()
  716. {
  717. m_point2F_normalize(*this);
  718. }
  719. inline void Point2F::normalize(F32 val)
  720. {
  721. m_point2F_normalize_f(*this, val);
  722. }
  723. //------------------------------------------------------------------------------
  724. //-------------------------------------- Point2D
  725. //
  726. inline Point2D::Point2D()
  727. {
  728. //
  729. }
  730. inline Point2D::Point2D(const Point2D& _copy)
  731. : x(_copy.x), y(_copy.y)
  732. {
  733. //
  734. }
  735. inline Point2D::Point2D(const F64 _x, const F64 _y)
  736. : x(_x), y(_y)
  737. {
  738. }
  739. inline void Point2D::set(const F64 _x, const F64 _y)
  740. {
  741. x = _x;
  742. y = _y;
  743. }
  744. inline void Point2D::setMin(const Point2D& _test)
  745. {
  746. x = (_test.x < x) ? _test.x : x;
  747. y = (_test.y < y) ? _test.y : y;
  748. }
  749. inline void Point2D::setMax(const Point2D& _test)
  750. {
  751. x = (_test.x > x) ? _test.x : x;
  752. y = (_test.y > y) ? _test.y : y;
  753. }
  754. inline void Point2D::interpolate(const Point2D& _rFrom, const Point2D& _to, const F64 _factor)
  755. {
  756. AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
  757. x = (_rFrom.x * (1.0f - _factor)) + (_to.x * _factor);
  758. y = (_rFrom.y * (1.0f - _factor)) + (_to.y * _factor);
  759. }
  760. inline bool Point2D::isZero() const
  761. {
  762. return (x == 0.0f) && (y == 0.0f);
  763. }
  764. inline F64 Point2D::lenSquared() const
  765. {
  766. return (x * x) + (y * y);
  767. }
  768. inline void Point2D::neg()
  769. {
  770. x = -x;
  771. y = -y;
  772. }
  773. inline void Point2D::convolve(const Point2D& c)
  774. {
  775. x *= c.x;
  776. y *= c.y;
  777. }
  778. inline void Point2D::convolveInverse(const Point2D& c)
  779. {
  780. x /= c.x;
  781. y /= c.y;
  782. }
  783. inline bool Point2D::operator==(const Point2D& _test) const
  784. {
  785. return (x == _test.x) && (y == _test.y);
  786. }
  787. inline bool Point2D::operator!=(const Point2D& _test) const
  788. {
  789. return operator==(_test) == false;
  790. }
  791. inline Point2D Point2D::operator+(const Point2D& _add) const
  792. {
  793. return Point2D(x + _add.x, y + _add.y);
  794. }
  795. inline Point2D Point2D::operator-(const Point2D& _rSub) const
  796. {
  797. return Point2D(x - _rSub.x, y - _rSub.y);
  798. }
  799. inline Point2D& Point2D::operator+=(const Point2D& _add)
  800. {
  801. x += _add.x;
  802. y += _add.y;
  803. return *this;
  804. }
  805. inline Point2D& Point2D::operator-=(const Point2D& _rSub)
  806. {
  807. x -= _rSub.x;
  808. y -= _rSub.y;
  809. return *this;
  810. }
  811. inline Point2D Point2D::operator*(const F64 _mul) const
  812. {
  813. return Point2D(x * _mul, y * _mul);
  814. }
  815. inline Point2D Point2D::operator/(const F64 _div) const
  816. {
  817. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  818. F64 inv = 1.0f / _div;
  819. return Point2D(x * inv, y * inv);
  820. }
  821. inline Point2D& Point2D::operator*=(const F64 _mul)
  822. {
  823. x *= _mul;
  824. y *= _mul;
  825. return *this;
  826. }
  827. inline Point2D& Point2D::operator/=(const F64 _div)
  828. {
  829. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  830. F64 inv = 1.0f / _div;
  831. x *= inv;
  832. y *= inv;
  833. return *this;
  834. }
  835. inline Point2D Point2D::operator-() const
  836. {
  837. return Point2D(-x, -y);
  838. }
  839. inline F64 Point2D::len() const
  840. {
  841. return mSqrtD(x*x + y*y);
  842. }
  843. inline void Point2D::normalize()
  844. {
  845. m_point2D_normalize(*this);
  846. }
  847. inline void Point2D::normalize(F64 val)
  848. {
  849. m_point2D_normalize_f(*this, val);
  850. }
  851. //------------------------------------------------------------------------------
  852. //-------------------------------------- Point3F
  853. //
  854. inline Point3F::Point3F()
  855. #if defined(TORQUE_OS_LINUX)
  856. : x(0.f), y(0.f), z(0.f)
  857. #endif
  858. {
  859. // Uninitialized points are definitely a problem.
  860. // Enable the following code to see how often they crop up.
  861. #ifdef DEBUG_MATH
  862. *(U32 *)&x = 0x7FFFFFFA;
  863. *(U32 *)&y = 0x7FFFFFFB;
  864. *(U32 *)&z = 0x7FFFFFFC;
  865. #endif
  866. }
  867. inline Point3F::Point3F(const Point3F& _copy)
  868. : x(_copy.x), y(_copy.y), z(_copy.z)
  869. {
  870. //
  871. }
  872. inline Point3F::Point3F(const F32 _x, const F32 _y, const F32 _z)
  873. : x(_x), y(_y), z(_z)
  874. {
  875. //
  876. }
  877. inline void Point3F::set(const F32 _x, const F32 _y, const F32 _z)
  878. {
  879. x = _x;
  880. y = _y;
  881. z = _z;
  882. }
  883. inline void Point3F::set(const Point3F& copy)
  884. {
  885. x = copy.x;
  886. y = copy.y;
  887. z = copy.z;
  888. }
  889. inline void Point3F::setMin(const Point3F& _test)
  890. {
  891. x = (_test.x < x) ? _test.x : x;
  892. y = (_test.y < y) ? _test.y : y;
  893. z = (_test.z < z) ? _test.z : z;
  894. }
  895. inline void Point3F::setMax(const Point3F& _test)
  896. {
  897. x = (_test.x > x) ? _test.x : x;
  898. y = (_test.y > y) ? _test.y : y;
  899. z = (_test.z > z) ? _test.z : z;
  900. }
  901. inline void Point3F::interpolate(const Point3F& _from, const Point3F& _to, const F32 _factor)
  902. {
  903. AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
  904. m_point3F_interpolate( _from, _to, _factor, *this);
  905. }
  906. inline void Point3F::zero()
  907. {
  908. x = y = z = 0.0f;
  909. }
  910. inline bool Point3F::isZero() const
  911. {
  912. return ((x*x) <= POINT_EPSILON) && ((y*y) <= POINT_EPSILON) && ((z*z) <= POINT_EPSILON );
  913. }
  914. inline bool Point3F::equal( Point3F &compare )
  915. {
  916. return( ( mFabs( x - compare.x ) < POINT_EPSILON ) &&
  917. ( mFabs( y - compare.y ) < POINT_EPSILON ) &&
  918. ( mFabs( z - compare.z ) < POINT_EPSILON ) );
  919. }
  920. inline void Point3F::neg()
  921. {
  922. x = -x;
  923. y = -y;
  924. z = -z;
  925. }
  926. inline void Point3F::convolve(const Point3F& c)
  927. {
  928. x *= c.x;
  929. y *= c.y;
  930. z *= c.z;
  931. }
  932. inline void Point3F::convolveInverse(const Point3F& c)
  933. {
  934. x /= c.x;
  935. y /= c.y;
  936. z /= c.z;
  937. }
  938. inline F32 Point3F::lenSquared() const
  939. {
  940. return (x * x) + (y * y) + (z * z);
  941. }
  942. inline F32 Point3F::len() const
  943. {
  944. return mSqrt(x*x + y*y + z*z);
  945. }
  946. inline void Point3F::normalize()
  947. {
  948. m_point3F_normalize(*this);
  949. }
  950. inline F32 Point3F::magnitudeSafe()
  951. {
  952. if( isZero() )
  953. {
  954. return 0.0f;
  955. }
  956. else
  957. {
  958. return len();
  959. }
  960. }
  961. inline void Point3F::normalizeSafe()
  962. {
  963. F32 vmag = magnitudeSafe();
  964. if( vmag > POINT_EPSILON )
  965. {
  966. *this *= F32(1.0 / vmag);
  967. }
  968. }
  969. inline void Point3F::normalize(F32 val)
  970. {
  971. m_point3F_normalize_f(*this, val);
  972. }
  973. inline bool Point3F::operator==(const Point3F& _test) const
  974. {
  975. return (x == _test.x) && (y == _test.y) && (z == _test.z);
  976. }
  977. inline bool Point3F::operator!=(const Point3F& _test) const
  978. {
  979. return operator==(_test) == false;
  980. }
  981. inline Point3F Point3F::operator+(const Point3F& _add) const
  982. {
  983. return Point3F(x + _add.x, y + _add.y, z + _add.z);
  984. }
  985. inline Point3F Point3F::operator-(const Point3F& _rSub) const
  986. {
  987. return Point3F(x - _rSub.x, y - _rSub.y, z - _rSub.z);
  988. }
  989. inline Point3F& Point3F::operator+=(const Point3F& _add)
  990. {
  991. x += _add.x;
  992. y += _add.y;
  993. z += _add.z;
  994. return *this;
  995. }
  996. inline Point3F& Point3F::operator-=(const Point3F& _rSub)
  997. {
  998. x -= _rSub.x;
  999. y -= _rSub.y;
  1000. z -= _rSub.z;
  1001. return *this;
  1002. }
  1003. inline Point3F Point3F::operator*(const F32 _mul) const
  1004. {
  1005. return Point3F(x * _mul, y * _mul, z * _mul);
  1006. }
  1007. inline Point3F Point3F::operator*(const Point3F &_vec) const
  1008. {
  1009. return Point3F(x * _vec.x, y * _vec.y, z * _vec.z);
  1010. }
  1011. inline Point3F Point3F::operator/(const F32 _div) const
  1012. {
  1013. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  1014. F32 inv = 1.0f / _div;
  1015. return Point3F(x * inv, y * inv, z * inv);
  1016. }
  1017. inline Point3F& Point3F::operator*=(const F32 _mul)
  1018. {
  1019. x *= _mul;
  1020. y *= _mul;
  1021. z *= _mul;
  1022. return *this;
  1023. }
  1024. inline Point3F& Point3F::operator*=(const Point3F &_vec)
  1025. {
  1026. x *= _vec.x;
  1027. y *= _vec.y;
  1028. z *= _vec.z;
  1029. return *this;
  1030. }
  1031. inline Point3F& Point3F::operator/=(const F32 _div)
  1032. {
  1033. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  1034. F32 inv = 1.0f / _div;
  1035. x *= inv;
  1036. y *= inv;
  1037. z *= inv;
  1038. return *this;
  1039. }
  1040. inline Point3F Point3F::operator-() const
  1041. {
  1042. return Point3F(-x, -y, -z);
  1043. }
  1044. //------------------------------------------------------------------------------
  1045. //-------------------------------------- Point3D
  1046. //
  1047. inline Point3D::Point3D()
  1048. {
  1049. //
  1050. }
  1051. inline Point3D::Point3D(const Point3D& _copy)
  1052. : x(_copy.x), y(_copy.y), z(_copy.z)
  1053. {
  1054. //
  1055. }
  1056. inline Point3D::Point3D(const F64 _x, const F64 _y, const F64 _z)
  1057. : x(_x), y(_y), z(_z)
  1058. {
  1059. //
  1060. }
  1061. inline void Point3D::set(const F64 _x, const F64 _y, const F64 _z)
  1062. {
  1063. x = _x;
  1064. y = _y;
  1065. z = _z;
  1066. }
  1067. inline void Point3D::setMin(const Point3D& _test)
  1068. {
  1069. x = (_test.x < x) ? _test.x : x;
  1070. y = (_test.y < y) ? _test.y : y;
  1071. z = (_test.z < z) ? _test.z : z;
  1072. }
  1073. inline void Point3D::setMax(const Point3D& _test)
  1074. {
  1075. x = (_test.x > x) ? _test.x : x;
  1076. y = (_test.y > y) ? _test.y : y;
  1077. z = (_test.z > z) ? _test.z : z;
  1078. }
  1079. inline void Point3D::interpolate(const Point3D& _from, const Point3D& _to, const F64 _factor)
  1080. {
  1081. AssertFatal(_factor >= 0.0f && _factor <= 1.0f, "Out of bound interpolation factor");
  1082. m_point3D_interpolate( _from, _to, _factor, *this);
  1083. }
  1084. inline bool Point3D::isZero() const
  1085. {
  1086. return (x == 0.0f) && (y == 0.0f) && (z == 0.0f);
  1087. }
  1088. inline void Point3D::neg()
  1089. {
  1090. x = -x;
  1091. y = -y;
  1092. z = -z;
  1093. }
  1094. inline void Point3D::convolve(const Point3D& c)
  1095. {
  1096. x *= c.x;
  1097. y *= c.y;
  1098. z *= c.z;
  1099. }
  1100. inline void Point3D::convolveInverse(const Point3D& c)
  1101. {
  1102. x /= c.x;
  1103. y /= c.y;
  1104. z /= c.z;
  1105. }
  1106. inline F64 Point3D::lenSquared() const
  1107. {
  1108. return (x * x) + (y * y) + (z * z);
  1109. }
  1110. inline F64 Point3D::len() const
  1111. {
  1112. return mSqrtD(x*x + y*y + z*z);
  1113. }
  1114. inline void Point3D::normalize()
  1115. {
  1116. m_point3D_normalize(*this);
  1117. }
  1118. inline void Point3D::normalize(F64 val)
  1119. {
  1120. m_point3D_normalize_f(*this, val);
  1121. }
  1122. inline bool Point3D::operator==(const Point3D& _test) const
  1123. {
  1124. return (x == _test.x) && (y == _test.y) && (z == _test.z);
  1125. }
  1126. inline bool Point3D::operator!=(const Point3D& _test) const
  1127. {
  1128. return operator==(_test) == false;
  1129. }
  1130. inline Point3D Point3D::operator+(const Point3D& _add) const
  1131. {
  1132. return Point3D(x + _add.x, y + _add.y, z + _add.z);
  1133. }
  1134. inline Point3D Point3D::operator-(const Point3D& _rSub) const
  1135. {
  1136. return Point3D(x - _rSub.x, y - _rSub.y, z - _rSub.z);
  1137. }
  1138. inline Point3D& Point3D::operator+=(const Point3D& _add)
  1139. {
  1140. x += _add.x;
  1141. y += _add.y;
  1142. z += _add.z;
  1143. return *this;
  1144. }
  1145. inline Point3D& Point3D::operator-=(const Point3D& _rSub)
  1146. {
  1147. x -= _rSub.x;
  1148. y -= _rSub.y;
  1149. z -= _rSub.z;
  1150. return *this;
  1151. }
  1152. inline Point3D Point3D::operator*(const F64 _mul) const
  1153. {
  1154. return Point3D(x * _mul, y * _mul, z * _mul);
  1155. }
  1156. inline Point3D Point3D::operator/(const F64 _div) const
  1157. {
  1158. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  1159. F64 inv = 1.0f / _div;
  1160. return Point3D(x * inv, y * inv, z * inv);
  1161. }
  1162. inline Point3D& Point3D::operator*=(const F64 _mul)
  1163. {
  1164. x *= _mul;
  1165. y *= _mul;
  1166. z *= _mul;
  1167. return *this;
  1168. }
  1169. inline Point3D& Point3D::operator/=(const F64 _div)
  1170. {
  1171. AssertFatal(_div != 0.0f, "Error, div by zero attempted");
  1172. F64 inv = 1.0f / _div;
  1173. x *= inv;
  1174. y *= inv;
  1175. z *= inv;
  1176. return *this;
  1177. }
  1178. inline Point3D Point3D::operator-() const
  1179. {
  1180. return Point3D(-x, -y, -z);
  1181. }
  1182. //------------------------------------------------------------------------------
  1183. //-------------------------------------- Point4F
  1184. //
  1185. inline Point4F::Point4F()
  1186. {
  1187. //
  1188. }
  1189. inline Point4F::Point4F(const Point4F& _copy)
  1190. : x(_copy.x), y(_copy.y), z(_copy.z), w(_copy.w)
  1191. {
  1192. //
  1193. }
  1194. inline Point4F::Point4F(const F32 _x, const F32 _y, const F32 _z, const F32 _w)
  1195. : x(_x), y(_y), z(_z), w(_w)
  1196. {
  1197. //
  1198. }
  1199. inline void Point4F::set(const F32 _x, const F32 _y, const F32 _z, const F32 _w)
  1200. {
  1201. x = _x;
  1202. y = _y;
  1203. z = _z;
  1204. w = _w;
  1205. }
  1206. inline void Point4F::interpolate(const Point4F& _from, const Point4F& _to, const F32 _factor)
  1207. {
  1208. x = (_from.x * (1.0f - _factor)) + (_to.x * _factor);
  1209. y = (_from.y * (1.0f - _factor)) + (_to.y * _factor);
  1210. z = (_from.z * (1.0f - _factor)) + (_to.z * _factor);
  1211. w = (_from.w * (1.0f - _factor)) + (_to.w * _factor);
  1212. }
  1213. //--------------------------------------------------------------------------
  1214. //-------------------------------------- NON-MEMBER Operators
  1215. //
  1216. inline Point2I operator*(const S32 mul, const Point2I& multiplicand)
  1217. {
  1218. return multiplicand * mul;
  1219. }
  1220. inline Point3I operator*(const S32 mul, const Point3I& multiplicand)
  1221. {
  1222. return multiplicand * mul;
  1223. }
  1224. inline Point2F operator*(const F32 mul, const Point2F& multiplicand)
  1225. {
  1226. return multiplicand * mul;
  1227. }
  1228. inline Point3F operator*(const F32 mul, const Point3F& multiplicand)
  1229. {
  1230. return multiplicand * mul;
  1231. }
  1232. inline Point2D operator*(const F64 mul, const Point2D& multiplicand)
  1233. {
  1234. return multiplicand * mul;
  1235. }
  1236. inline Point3D operator*(const F64 mul, const Point3D& multiplicand)
  1237. {
  1238. return multiplicand * mul;
  1239. }
  1240. #endif // _POINT_H_