MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vector3.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _vector3_h
41 #define _vector3_h
42 
43 #ifndef SWIG
44  #include <limits>
45 #endif
46 
47 #include "crossplatformexport.h"
48 #include "datatypes.h"
49 #include "enumerations.h"
50 #include "interpolator.h"
51 #include "swig.h"
52 
53 #ifndef SWIG
54  #include "XML/xml.h"
55 #endif
56 
57 //Forward Declarations for wierd compatibility functions
58 class btVector3;
59 namespace Ogre
60 {
61  class Vector3;
62 }
63 
64 
65 
66 namespace Mezzanine
67 {
68 
69  //remove this after testing
70  void PrintHello(); // Function to call from Lua
71 
72  class Quaternion;
73  ///////////////////////////////////////////////////////////////////////////////
74  /// @class Vector3
75  /// @headerfile vector3.h
76  /// @brief This is used to represent a point in space, or a vector through space
77  /// @details This contains an X, Y and a Z value used to represent coordinates.
78  /// This also has a number of facilities to make converting from Physics subsystem
79  /// vectors or graphics subsystems as easy as possible
80  /// @note No operator<< existing in any scripting interface for this class
82  {
83  public:
84 
85  ///////////////////////////////////////////////////////////////////////////////
86  // The Essentials
87 
88  /// @brief Coordinate on the X vector.
90  /// @brief Coordinate on the Y vector.
92  /// @brief Coordinate on the Z vector.
94 
95 #if !(defined(SWIG) && defined(MEZZLUA51)) // Stop Swig from making lua bindings but allow other languages
96  /// @brief Get The value associate with a certain Axis.
97  /// @param Axis Which axis to retrieve.
98  /// @note Despite the multiple scripting overloads of this Method, only Real GetAxisValue(const Whole& Axis) const; exists in the scripting interface
99  /// @return Either X, Y or Z as indicated by the value passed in.
100  Real GetAxisValue(const StandardAxis& Axis) const;
101 #endif // \SWIG
102 
103  /// @copydoc GetAxisValue(const StandardAxis& Axis) const
104  Real GetAxisValue(const Whole& Axis) const;
105 
106 #ifndef SWIG // Since these functions differ only by constness, they make no sense to most(all?) scripting languages
107  /// @brief Get The value associate with a certain Axis in such a way that it can readily be assigned in this Vector3.
108  /// @param Axis Which axis to retrieve.
109  /// @return Either X, Y or Z as indicated by the value passed in.
110  Real& GetAxisValue(const StandardAxis& Axis);
111  /// @copydoc GetAxisValue(const StandardAxis& Axis)
112  Real& GetAxisValue(const Whole& Axis);
113 #endif // \SWIG
114 
115  /// @copydoc GetAxisValue(const StandardAxis& Axis) const
116  Real operator[] (const StandardAxis& Axis) const;
117  /// @copydoc GetAxisValue(const StandardAxis& Axis) const
118  Real operator[] (const Whole& Axis) const;
119  /// @copydoc GetAxisValue(const StandardAxis& Axis)
120  Real& operator[] (const StandardAxis& Axis);
121  /// @copydoc GetAxisValue(const StandardAxis& Axis)
122  Real& operator[] (const Whole& Axis);
123 
124  ///////////////////////////////////////////////////////////////////////////////
125  // Constructors
126 
127  /// @brief Default Constructor.
128  /// @details Basic all zero initialization constructor.
129  Vector3();
130  /// @brief Real value Constructor.
131  /// @details Constructor that sets all three vectors.
132  /// @param X Coordinate on the X vector.
133  /// @param Y Coordinate on the Y vector.
134  /// @param Z Coordinate on the Z vector.
135  Vector3(const Real& X, const Real& Y, const Real& Z);
136  /// @brief Ogre Value Constructor.
137  /// @details Constructor that sets all values to match the Ogre vector.
138  /// @param Vec The vector to be copied to make this vector.
139  explicit Vector3(const Ogre::Vector3& Vec);
140  /// @brief Bullet Value Constructor.
141  /// @details Constructor that sets all values to match the Bullet vector.
142  /// @param Vec The vector to be copied to make this vector.
143  explicit Vector3(const btVector3& Vec);
144  /// @brief Copy Constructor
145  /// @param Vec The other Mezzanine::Vector3 to copy to make this one.
146  Vector3(const Mezzanine::Vector3& Vec);
147  /// @brief Deserializing constructor
148  /// @param OneNode The XML node to deserialize from.
149  explicit Vector3(XML::Node OneNode);
150 
151  ///////////////////////////////////////////////////////////////////////////////
152  // Prebuilt Vectors
153 
154  /// @brief Gets a vector representing the X unit of a Vector3.
155  /// @return A Vector3(1,0,0).
156  static Vector3 Unit_X();
157  /// @brief Gets a vector representing the Y unit of a vector.
158  /// @return A Vector3(0,1,0).
159  static Vector3 Unit_Y();
160  /// @brief Gets a vector representing the Z unit of a vector.
161  /// @return A Vector3(0,0,1).
162  static Vector3 Unit_Z();
163  /// @brief Gets a vector representing the negative X unit of a vector.
164  /// @return A Vector3(-1,0,0).
165  static Vector3 Neg_Unit_X();
166  /// @brief Gets a vector representing the negative Y unit of a vector.
167  /// @return A Vector3(0,-1,0).
168  static Vector3 Neg_Unit_Y();
169  /// @brief Gets a vector representing the negative Z unit of a vector.
170  /// @return A Vector3(0,0,-1).
171  static Vector3 Neg_Unit_Z();
172 
173  /// @brief Get a Unit Vector along the given Axis
174  /// @param Axis The StandardAxis correlating to the Unit Vector you are retrieving
175  /// @return A vector one unit in length along the Axis specified.
176  static Vector3 UnitOnAxis(StandardAxis Axis);
177  /// @brief Get a Unit Vector along the given Axis
178  /// @return The Corresponding StandardAxis if a Vector equal to Unit_X, Unit_Y or Unit_Z is passed in.
179  StandardAxis IsStandardUnitAxis() const;
180 
181  ///////////////////////////////////////////////////////////////////////////////
182  // Assignment Operators
183 
184  /// @brief Assignment operator to convert from Bullet Vectors
185  /// @details This copies the x,y and z values from the bullet into this vector
186  /// @param Vec This is a btVector3 that will be copied
187  /// @return A reference to the assigned Vector3 to allow chained expresions
188  Vector3& operator= (const btVector3 &Vec);
189  /// @brief Assignment operator to convert from Ogre Vectors
190  /// @details This copies the x,y and z values from the bullet into this vector
191  /// @param Vec This is a Ogre::Vector3 that will be copied.
192  /// @return A reference to the assigned Vector3 to allow chained expresions
193  Vector3& operator= (const Ogre::Vector3 &Vec);
194 
195  ///////////////////////////////////////////////////////////////////////////////
196  // Unary Operators
197 
198  /// @brief Additive Inverse Operator
199  /// @details Returns the opposite Vector3 relative to 0,0,0
200  /// @return A copy of Vector3 with the signs on each value flipped
202 
203  ///////////////////////////////////////////////////////////////////////////////
204  // Vector3 Arithmetic with Real
205 
206  /// @brief Scaling by multiplication.
207  /// @details This Multiplies X, Y and Z by scalar.
208  /// @return This returns a Vector3 that has been scaled.
209  /// @param scalar This is the amount to scale the Vector3 by.
210  /// @return A copy of Vector3 scaled by the amount passed.
211  Vector3 operator* (const Real &scalar) const;
212  /// @brief Scaling by Division.
213  /// @details This Diisionn X, Y and Z by scalar.
214  /// @return This returns a Vector3 that has been scaled.
215  /// @param scalar This is the amount to scale the Vector3 by.
216  /// @return A copy of Vector3 scaled by the amount passed.
217  Vector3 operator/ (const Real &scalar) const;
218 
219  ///////////////////////////////////////////////////////////////////////////////
220  // Vector3 Arithmetic and assignment with Real
221 
222  /// @brief Scaling by multiplication.
223  /// @details This Multiplies X, Y and Z by scalar and stores the changes in this Vector3.
224  /// @param scalar This is the amount to scale the Vector3 by.
225  /// @return A reference to the assigned Vector3 to allow chained expresions.
226  Vector3& operator*= (const Real &scalar);
227  /// @brief Scaling by Division
228  /// @details This Division X, Y and Z by scalar and and stores the changes in this Vector3.
229  /// @param scalar This is the amount to scale the Vector3 by.
230  /// @return A reference to the assigned Vector3 to allow chained expresions.
231  Vector3& operator/= (const Real &scalar);
232 
233  ///////////////////////////////////////////////////////////////////////////////
234  // Equality Comparison operators
235 
236  /// @brief Equality Comparison Operator.
237  /// @return Returns true if X==X, Y==Y and Z==Z. If any of those do not match this returns false.
238  /// @param Vec This is the other Mezzanine::Vector3.
239  bool operator== (const Mezzanine::Vector3 &Vec) const;
240  /// @brief Equality Comparison Operator.
241  /// @return Returns true if X==getX(), Y==getY() and Z==getZ(). If any of those do not match this returns false.
242  /// @param Vec This is an btVector3 that needs to be compared with this.
243  bool operator== (const btVector3 &Vec) const;
244  /// @brief Equality Comparison Operator.
245  /// @return Returns true if X==x, Y==y and Z==z. If any of those do not match this returns false.
246  /// @param Vec This is an Ogre::Vector3 that needs to be compared with this.
247  bool operator== (const Ogre::Vector3 &Vec) const;
248 
249  /// @brief Inequality Comparison Operator.
250  /// @return Returns true if X!=X, Y!=Y or Z!=Z. If all of those match this returns false.
251  /// @param Vec This is the other Mezzanine::Vector3.
252  bool operator!= (const Mezzanine::Vector3 &Vec) const;
253  /// @brief Inequality Comparison Operator.
254  /// @return Returns true if X!=getX(), Y!=getY() or Z!=getZ(). If all of those match this returns false.
255  /// @param Vec This is an btVector3 that needs to be compared with this.
256  bool operator!= (const btVector3 &Vec) const;
257  /// @brief Inequality Comparison Operator.
258  /// @return Returns true if X!=x, Y!=y or Z!=z. If all of those match this returns false.
259  /// @param Vec This is an Ogre::Vector3 that needs to be compared with this.
260  bool operator!= (const Ogre::Vector3 &Vec) const;
261 
262  /// @brief Less or Equal Comparison Operator.
263  /// @return Returns true if X<=X, Y<=Y and Z<=Z. If any of those do not hold this returns false.
264  /// @param Vec This is the other Mezzanine::Vector3.
265  /// @note Used primarily for testing. This is not implement for use with other kinds of Vector3 implementations as it is widely considered useless.
266  bool operator<= (const Mezzanine::Vector3 &Vec) const;
267  /// @brief Greater than or Equal Comparison Operator.
268  /// @return Returns true if X>=X, Y>=Y and Z>=Z. If any of those do not hold this returns false.
269  /// @param Vec This is the other Mezzanine::Vector3.
270  /// @note Used primarily for testing. This is not implement for use with other kinds of Vector3 implementations as it is widely considered useless.
271  bool operator>= (const Mezzanine::Vector3 &Vec) const;
272 
273  ///////////////////////////////////////////////////////////////////////////////
274  // Arithmetic Operators
275 
276  /// @brief Addition Operator
277  /// @details Allows for addition from a Mezzanine::Vector3
278  /// @param Vec This is the other Mezzanine::Vector3
279  /// @return A copy of the calculated Vector3 to allow chained expresions.
280  Vector3 operator+ (const Vector3 &Vec) const;
281  /// @brief Subraction Operator
282  /// @details Allows for subtraction from a Mezzanine::Vector3
283  /// @param Vec This is the other Mezzanine::Vector3
284  /// @return A copy of the calculated Vector3 to allow chained expresions.
285  Vector3 operator- (const Vector3 &Vec) const;
286  /// @brief Multiplaction Operator
287  /// @details Allows for multiplaction from a Mezzanine::Vector3
288  /// @param Vec This is the other Mezzanine::Vector3
289  /// @return A copy of the calculated Vector3 to allow chained expresions.
290  Vector3 operator* (const Vector3 &Vec) const;
291  /// @brief Division Operator
292  /// @details Allows for division from a Mezzanine::Vector3
293  /// @param Vec This is the other Mezzanine::Vector3
294  /// @return A copy of the calculated Vector3 to allow chained expresions.
295  Vector3 operator/ (const Vector3 &Vec) const;
296 
297  /////////////////////////////////////////////////////////////////////
298  // Arithmetic Operators with btVector3
299 
300  /// @brief Bullet Addition Operator
301  /// @details Allows for addition between a Mezzanine::Vector3 and a btVector3
302  /// @param Vec This is the btVector3 to be added
303  /// @return A copy of the calculated Vector3 to allow chained expresions.
304  Vector3 operator+ (const btVector3 &Vec) const;
305  /// @brief Bullet Subtraction Operator
306  /// @details Allows for subtraction between a Mezzanine::Vector3 and a btVector3
307  /// @param Vec This is the btVector3 to be subtracted
308  /// @return A copy of the calculated Vector3 to allow chained expresions.
309  Vector3 operator- (const btVector3 &Vec) const;
310  /// @brief Bullet Multiplication Operator
311  /// @details Allows for multiplication between a Mezzanine::Vector3 and a btVector3
312  /// @param Vec This is the btVector3 to be multiplied
313  /// @return A copy of the calculated Vector3 to allow chained expresions.
314  Vector3 operator* (const btVector3 &Vec) const;
315  /// @brief Bullet Division Operator
316  /// @details Allows for division between a Mezzanine::Vector3 and a btVector3
317  /// @param Vec This is the btVector3 to be divided
318  /// @return A copy of the calculated Vector3 to allow chained expresions.
319  Vector3 operator/ (const btVector3 &Vec) const;
320 
321  ///////////////////////////////////////////////////////////////////////////////
322  // Arithmetic Operators with Ogre::Vector3
323 
324  /// @brief Ogre Addition Operator
325  /// @details Allows for addition between a Mezzanine::Vector3 and a Ogre::Vector3
326  /// @param Vec This is the Ogre::Vector3 to be added
327  /// @return A copy of the calculated Vector3 to allow chained expresions.
328  Vector3 operator+ (const Ogre::Vector3 &Vec) const;
329  /// @brief Ogre Subtraction Operator
330  /// @details Allows for subtraction between a Mezzanine::Vector3 and a Ogre::Vector3
331  /// @param Vec This is the Ogre::Vector3 to be subtracted
332  /// @return A copy of the calculated Vector3 to allow chained expresions.
333  Vector3 operator- (const Ogre::Vector3 &Vec) const;
334  /// @brief Ogre Multiplication Operator
335  /// @details Allows for multiplying between a Mezzanine::Vector3 and a Ogre::Vector3
336  /// @param Vec This is the Ogre::Vector3 to be multiplied.
337  /// @return A copy of the calculated Vector3 to allow chained expresions.
338  Vector3 operator* (const Ogre::Vector3 &Vec) const;
339  /// @brief Ogre Division Operator.
340  /// @details Allows for division between a Mezzanine::Vector3 and a Ogre::Vector3
341  /// @param Vec This is the Ogre::Vector3 to be divided.
342  /// @return A copy of the calculated Vector3 to allow chained expresions.
343  Vector3 operator/ (const Ogre::Vector3 &Vec) const;
344 
345  ///////////////////////////////////////////////////////////////////////////////
346  // Fancy Math
347 
348  /// @brief This is used to calculate the crossproduct of this and another vector
349  /// @details This creates a third vector, which should be on a line perpendicular
350  /// to the line that contains the origin and the other vector \n\n
351  /// Thanks to the guys at Ogre3d for the well written version of this function
352  /// that we based this on.
353  /// @param Vec the Vector to work with to create the cross product
354  /// @return A Vector3 containing crossproduct of this vector and Vec
355  Vector3 CrossProduct(const Vector3& Vec) const;
356  /// @brief This is used to calculate the dotproduct of this and another vector
357  /// @details This calculates the sum of the products of X, Y and Z. \n\n
358  /// Thanks to the guys at Ogre3d for the well written version of this function
359  /// that we based this on.
360  /// @param Vec The vector to work with to create the cross product
361  /// @return This is the dotproduct of this vector and vec
362  Real DotProduct(const Vector3& Vec) const;
363  /// @brief This will change this point into it's own normal relative to the origin
364  /// @details This will change this vector into one that is the same direction from the origin, but only one unit a away.
365  /// @return Returns a reference to the normalized vector.
366  Vector3& Normalize();
367  /// @brief This returns the normal for this relative to the origin
368  /// @details This will return a vector that is 1 unit in away from the origin, if a line were starting and the origin it would pass through
369  /// both the normal and the original point.
370  /// @return At a vector3 that is the normal of this Vector3 or 0,0,0 if the current Vector is all 0s
371  Vector3 GetNormal() const;
372  /// @brief This will get the direction between two points.
373  /// @details This returns the direction expressed as a vector between this vector
374  /// and another provided vector.
375  /// @param Destination The point in space to determine the direction for.
376  /// @return A normalized Vector3 that indicates the direction from this vector to another.
377  Vector3 GetDirection(const Vector3& Destination) const;
378  /// @brief This will inverse the reals in the vector.
379  /// @details This function will inverse all the reals in the vector.
380  /// @return A copy of of the current Vector3
381  Vector3 Inverse();
382  /// @brief Gets a reflection vector to the plane with the given normal.
383  /// @param Normal The normal of the plane being reflected off of.
384  /// @return Returns a Vector3 containing the reflection vector.
385  Vector3 Reflect(const Vector3& Normal);
386  /// @brief Gets the distance between this and another vector.
387  /// @details This uses a 3d extension of pythagoras thereom to calculate the distance between
388  /// this Vector3 and another.
389  /// @param OtherVec This is the other point to measure the distance to.
390  /// @return Returns a Real representing the distance.
391  Real Distance(const Vector3& OtherVec) const;
392  /// @brief Gets the squared distance between this and another vector.
393  /// @param OtherVec This is the other point to measure the distance to.
394  /// @return Returns a Real representing the distance squared.
395  Real SquaredDistance(const Vector3& OtherVec) const;
396  /// @brief Gets the length of this vector.
397  /// @return Returns a real representing the length of this vector.
398  Real Length() const;
399  /// @brief Gets the length of this vector squared.
400  /// @return Returns a real representing the squared length of this vector.
401  Real SquaredLength() const;
402  /// @brief Checks to see if the length of this vector is zero.
403  /// @return Returns true if this vector has zero length, false otherwise.
404  bool IsZeroLength() const;
405  /// @brief Gets the rotation needed to rotate this vector as an axis to another axis.
406  /// @param Axis The target axis to rotate to.
407  /// @return Returns a Quaternion representing the needed rotation to the specified axis.
408  Quaternion GetRotationToAxis(const Vector3& Axis, const Vector3& FallBackAxis = Vector3()) const;
409 
410  ///////////////////////////////////////////////////////////////////////////////
411  // Utility Functions
412 
413  /// @brief Sets all the members of this vector3 to zero.
414  void Zero();
415  /// @brief Manually sets all the members of this vector3.
416  /// @param X Value to set for X.
417  /// @param Y Value to set for Y.
418  /// @param Z Value to set for Z.
419  void SetValues(const Real& X, const Real& Y, const Real& Z);
420 
421  /// @brief Sets each member of this Vector3 to the higher value between the two vector3s.
422  /// @param Other The other Vector to compare with.
423  /// @return Returns a reference to this.
424  Vector3& Ceil(const Vector3& Other);
425  /// @brief Sets each member of this Vector3 to the lower value between the two vector3s.
426  /// @param Other The other Vector to compare with.
427  /// @return Returns a reference to this.
428  Vector3& Floor(const Vector3& Other);
429 
430  ///////////////////////////////////////////////////////////////////////////////
431  // Manual Conversions
432 
433  /// @brief Gets a Bullet vector3.
434  /// @details Creates a Bullet vector3 with values equal to this class and returns it.
435  /// @return A Bullet Vector3 containing the same value as the Mezzanine::Vector3
436  btVector3 GetBulletVector3() const;
437  /// @brief Copies an existing Bullet vector3.
438  /// @details This function will copy the values stored in an existing Bullet vector3
439  /// and set the values of this class to be the same.
440  /// @param temp The vector3 to be extracted.
441  void ExtractBulletVector3(const btVector3& temp);
442  /// @brief Gets a Ogre vector3.
443  /// @details Creates a Ogre vector3 with values equal to this class and returns it.
444  /// @return A Ogre Vector3 containing the same value as the Mezzanine::Vector3
445  Ogre::Vector3 GetOgreVector3() const;
446  /// @brief Copies an existing Ogre vector3.
447  /// @details This function will copy the values stored in an existing Ogre vector3
448  /// and set the values of this class to be the same.
449  /// @param temp The vector3 to be extracted.
450  void ExtractOgreVector3(const Ogre::Vector3& temp);
451 
452  ///////////////////////////////////////////////////////////////////////////////
453  // Serialization
454 
455  /// @brief Convert this class to an XML::Node ready for serialization
456  /// @param CurrentRoot The point in the XML hierarchy that all this vector3 should be appended to.
457  void ProtoSerialize(XML::Node& CurrentRoot) const;
458  /// @brief Take the data stored in an XML and overwrite this instance of this object with it
459  /// @param OneNode and XML::Node containing the data.
460  void ProtoDeSerialize(const XML::Node& OneNode);
461  /// @brief Get the name of the the XML tag this class will leave behind as its instances are serialized.
462  /// @return A string containing "Vector3"
463  static String SerializableName();
464  };//Vector3
465 }//Mezzanine
466 
467 namespace std
468 {
469  /// @brief Get Numeric details on Vector3
470  template<>
471  class numeric_limits<Mezzanine::Vector3>
472  {
473  public:
474  /// @brief Does this class (numeric_limits<Mezzanine::Vector3>) exist
475  static const bool is_specialized = true;
476  /// @brief Does this support negative values?
477  static const bool is_signed = true;
478  /// @brief Can this only store integer types.
479  static const bool is_integer = false;
480  /// @brief The Vector3 uses Real, which is typically a machine dependedant which can be inexact
481  static const bool is_exact = std::numeric_limits<Mezzanine::Real>::is_exact;
482  /// @brief Can This represent an infinitely large value in X, Y or Z?
483  static const bool has_infinity = std::numeric_limits<Mezzanine::Real>::has_infinity;
484  /// @brief ??? Required by std::numeric to be compliant
485  /// @todo Learn why this exists and document it.
486  static const bool has_quiet_NaN = std::numeric_limits<Mezzanine::Real>::has_quiet_NaN;
487  /// @brief ??? Required by std::numeric to be compliant
488  /// @todo Learn why this exists and document it.
489  static const bool has_signaling_NaN = std::numeric_limits<Mezzanine::Real>::has_signaling_NaN;
490  /// @brief Does this support exceptionally small numbers near 0?
491  static const std::float_denorm_style has_denorm = std::numeric_limits<Mezzanine::Real>::has_denorm;
492  /// @brief When extra precision near 0 is lost, can this type distinguish that from other imprecision.
493  static const bool has_denorm_loss = std::numeric_limits<Mezzanine::Real>::has_denorm_loss;
494  /// @brief How items that fit between the precise amount a Real can represent will be adapted.
495  static const std::float_round_style round_style = std::numeric_limits<Mezzanine::Real>::round_style;
496  /// @brief Do X, Y and Z adhere to iec 559?
497  static const bool is_iec559 = std::numeric_limits<Mezzanine::Real>::is_iec559;
498  /// @brief Is overflow of this type handle by modulo overflow?
499  static const bool is_modulo = std::numeric_limits<Mezzanine::Real>::is_modulo;
500  /// @brief How many integer digits(in machine base) of precision can this handle in each X, Y or Z without floating point component or error?
501  static const int digits = std::numeric_limits<Mezzanine::Real>::digits;
502  /// @brief How many integer digits in base 10 of precision can this handle in each X, Y or Z without floating point component or error?
503  static const int digits10 = std::numeric_limits<Mezzanine::Real>::digits10;
504  /// @brief The base of the number system that this is implemented in
505  static const int radix = std::numeric_limits<Mezzanine::Real>::radix;
506  /// @brief The smallest power of the radix that is valid floating point value
507  static const int min_exponent = std::numeric_limits<Mezzanine::Real>::min_exponent;
508  /// @brief The smallest power of 10 that is valid floating point value
509  static const int min_exponent10 = std::numeric_limits<Mezzanine::Real>::min_exponent10;
510  /// @brief The largest power of the radix that is valid floating point value
511  static const int max_exponent = std::numeric_limits<Mezzanine::Real>::max_exponent;
512  /// @brief The largest power of 10 that is valid floating point value
513  static const int max_exponent10 = std::numeric_limits<Mezzanine::Real>::max_exponent10;
514  /// @brief Can this generate a trap?
515  static const bool traps = std::numeric_limits<Mezzanine::Real>::traps;
516  /// @brief Are tiny values respected during rounding?
517  static const bool tinyness_before = std::numeric_limits<Mezzanine::Real>::tinyness_before;
518 
519  /// @brief Get the lowest positive finite value this can represent
520  /// @return A vector with 3 very small numbers
522  {
523  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::min(),
524  std::numeric_limits<Mezzanine::Real>::min(),
525  std::numeric_limits<Mezzanine::Real>::min()
526  );
527  }
528 
529  /// @brief Get the highest positive finite value this can represent
530  /// @return A vector with 3 very large numbers
532  {
533  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::max(),
534  std::numeric_limits<Mezzanine::Real>::max(),
535  std::numeric_limits<Mezzanine::Real>::max()
536  );
537  }
538 
539  /// @brief The smallest value representable from 1.0,1.0,1.0 to the next value
540  /// @return A vector with a very small number
542  {
543  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::epsilon(),
544  std::numeric_limits<Mezzanine::Real>::epsilon(),
545  std::numeric_limits<Mezzanine::Real>::epsilon()
546  );
547  }
548 
549  /// @brief Get the largest possible rounding error
550  /// @return A vector containing 3 values indicating how much they could be rounded.
552  {
553  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::round_error(),
554  std::numeric_limits<Mezzanine::Real>::round_error(),
555  std::numeric_limits<Mezzanine::Real>::round_error()
556  );
557  }
558 
559  /// @brief Get the special value "Positive infinity"
560  /// @return A vector containing 3 values.
562  {
563  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::infinity(),
564  std::numeric_limits<Mezzanine::Real>::infinity(),
565  std::numeric_limits<Mezzanine::Real>::infinity()
566  );
567  }
568 
569  /// @brief Get the special value "Quiet Not actual Number"
570  /// @return A vector containing 3 values.
572  {
573  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::quiet_NaN(),
574  std::numeric_limits<Mezzanine::Real>::quiet_NaN(),
575  std::numeric_limits<Mezzanine::Real>::quiet_NaN()
576  );
577  }
578 
579  /// @brief Get the special value "Signaling Not actual Number"
580  /// @return A vector containing 3 values.
582  {
583  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::signaling_NaN(),
584  std::numeric_limits<Mezzanine::Real>::signaling_NaN(),
585  std::numeric_limits<Mezzanine::Real>::signaling_NaN()
586  );
587  }
588 
589  /// @brief Get the closest value to 0 that is not 0 this can represent, including extra precision for being close to 0 if supported.
590  /// @return A vector containing 3 very small values.
592  {
593  return Mezzanine::Vector3(std::numeric_limits<Mezzanine::Real>::denorm_min(),
594  std::numeric_limits<Mezzanine::Real>::denorm_min(),
595  std::numeric_limits<Mezzanine::Real>::denorm_min()
596  );
597  }
598 
599  }; //Numeric Limits
600 
601 } // std
602 
603 ///////////////////////////////////////////////////////////////////////////////
604 // Right Hand Arithmetic Operators
605 /// @brief Right Hand Addition Operator for Bullet Vectors with a Mezzanine::Vector3.
606 /// @param Vec The Bullet Vector to be added.
607 /// @param lhs The Mezzanine::Vector3 to be added.
608 /// @return A Mezzanine::Vector3 with the Sum.
609 Mezzanine::Vector3 MEZZ_LIB operator+ (const btVector3 &Vec, const Mezzanine::Vector3& lhs);
610 
611 /// @brief Right Hand Subtraction Operator for Bullet Vectors with a Mezzanine::Vector3.
612 /// @param Vec The Bullet Vector to be subtracted from.
613 /// @param lhs The Mezzanine::Vector3 to be subtracted.
614 /// @return A Mezzanine::Vector3 with the difference.
615 Mezzanine::Vector3 MEZZ_LIB operator- (const btVector3 &Vec, const Mezzanine::Vector3& lhs);
616 
617 /// @brief Right Hand Multiplication Operator for Bullet Vectors with a Mezzanine::Vector3.
618 /// @param Vec The Bullet Vector to be multiplied.
619 /// @param lhs The Mezzanine::Vector3 to be multiplied.
620 /// @return A Mezzanine::Vector3 with the product.
621 Mezzanine::Vector3 MEZZ_LIB operator* (const btVector3 &Vec, const Mezzanine::Vector3& lhs);
622 
623 /// @brief Right Hand Division Operator for Bullet Vectors with a Mezzanine::Vector3.
624 /// @param Vec The Bullet Vector to be divided by.
625 /// @param lhs The Mezzanine::Vector3 to be divided.
626 /// @return A Mezzanine::Vector3 with the results
627 Mezzanine::Vector3 MEZZ_LIB operator/ (const btVector3 &Vec, const Mezzanine::Vector3& lhs);
628 
629 
630 /// @brief Right Hand Addition Operator for Ogre Vectors with a Mezzanine::Vector3.
631 /// @param Vec The Ogre Vector to be added.
632 /// @param lhs The Mezzanine::Vector3 to be added.
633 /// @return A Mezzanine::Vector3 with the Sum.
634 Mezzanine::Vector3 MEZZ_LIB operator+ (const Ogre::Vector3 &Vec, const Mezzanine::Vector3& lhs);
635 
636 /// @brief Right Hand Subtraction Operator for Ogre Vectors with a Mezzanine::Vector3.
637 /// @param Vec The Ogre Vector to be subtracted from.
638 /// @param lhs The Mezzanine::Vector3 to be subtracted.
639 /// @return A Mezzanine::Vector3 with the difference.
640 Mezzanine::Vector3 MEZZ_LIB operator- (const Ogre::Vector3 &Vec, const Mezzanine::Vector3& lhs);
641 
642 /// @brief Right Hand Multiplication Operator for Ogre Vectors with a Mezzanine::Vector3.
643 /// @param Vec The Ogre Vector to be multiplied.
644 /// @param lhs The Mezzanine::Vector3 to be multiplied.
645 /// @return A Mezzanine::Vector3 with the product.
646 Mezzanine::Vector3 MEZZ_LIB operator* (const Ogre::Vector3 &Vec, const Mezzanine::Vector3& lhs);
647 
648 /// @brief Right Hand Division Operator for Ogre Vectors with a Mezzanine::Vector3.
649 /// @param Vec The Ogre Vector to be divided by.
650 /// @param lhs The Mezzanine::Vector3 to be divided.
651 /// @return A Mezzanine::Vector3 with the results
652 Mezzanine::Vector3 MEZZ_LIB operator/ (const Ogre::Vector3 &Vec, const Mezzanine::Vector3& lhs);
653 
654 ///////////////////////////////////////////////////////////////////////////////
655 // Class External << Operators for streaming or assignment
656 
657 // We can skip these operators when creating bindings with swig
658 #ifndef SWIG
659 
660 /// @brief Used to Serialize an Mezzanine::Vector3 to a human readable stream
661 /// @details The current XML format
662 /// will create one node with no child nodes. The name of the xml node will be "Vector3". It will have 4 attributes.
663 /// "Version", will be set to a value of 1, indicating if came from version 1 compatible Vector3. It will also have an "X", "Y" and
664 /// "Z" attributes will values set appropriately. For example '<Vector3 Version="1" X="1" Y="2" Z="3" />'.
665 /// @param x The Mezzanine::Vector3 to be converted to characters.
666 /// @param stream The place to send the characters, that define the Mezzanine::Vector3.
667 /// @return Get an std::ostream that was written to, this allow chaining of the << operators.
668 std::ostream& MEZZ_LIB operator << (std::ostream& stream, const Mezzanine::Vector3& x);
669 
670 /// @brief Used to de-serialize an Mezzanine::Vector3 from a stream
671 /// @details This reads in the xml and sets the target vector according to values
672 /// from the stream.
673 /// @param Vec The Mezzanine::Vector3 that will accept the values from the xml
674 /// @param stream The place to get the characters from, that define the Mezzanine::Vector3.
675 /// @return Get an std::ostream that was read from, this allow chaining of the >> operators.
676 /// @throw Can throw any exception that any function in the Mezzanine::xml namespace could throw in addition to a Mezzanine::Exception if the serialization version doesn't match.
677 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::Vector3& Vec);
678 
679 /// @brief Converts an XML node into a Mezzanine::Vector3
680 /// @details This will convert an XML::Node will a valid serialized Mezzanine::Vector3 into a Mezzanine::Vector3
681 /// @param OneNode An XML Node containing the the text of a Vector3
682 /// @param Vec the Mezzanine::Vector3 to store the deserialized Vector3
683 /// @return This returns a reference to the XML::Node for operator chaining or whatever.
684 /// @throw Can throw any exception that any function in the Mezzanine::xml namespace could throw in addition to a Mezzanine::Exception if the serialization version doesn't match.
685 void MEZZ_LIB operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Vector3& Vec);
686 
687 /// @brief Conversion Assignment Operator to Ogre::Vector3.
688 /// @param VecTo The left hand side vector, is an Ogre::Vector3. The values of VecFrom will be copied here.
689 /// @param VecFrom The right hand side, is a\ Mezzanine::Vector3, this vector will be copied and unchanged.
690 /// @return An Ogre::Vector3 in case multiple operators are chainged together (not usually a good idea).
691 Ogre::Vector3& MEZZ_LIB operator << (Ogre::Vector3& VecTo, const Mezzanine::Vector3& VecFrom);
692 
693 /// @brief Conversion Assignment Operator to Ogre::Vector3.
694 /// @param VecTo The left hand side vector, is an Ogre::Vector3. The values of VecFrom will be copied here.
695 /// @param VecFrom The right hand side, is a btVector3, this vector will be copied and unchanged.
696 /// @return An Ogre::Vector3 in case multiple operators are chainged together (not usually a good idea).
697 Ogre::Vector3& MEZZ_LIB operator << (Ogre::Vector3& VecTo, const btVector3& VecFrom);
698 
699 /// @brief Conversion Assignment Operator to btVector3.
700 /// @param VecTo The left hand side vector, is an btVector3. The values of VecFrom will be copied here.
701 /// @param VecFrom The right hand side, is a Ogre::Vector3, this vector will be copied and unchanged.
702 /// @return An btVector3 in case multiple operators are chainged together (not usually a good idea).
703 btVector3& MEZZ_LIB operator << (btVector3& VecTo, const Ogre::Vector3& VecFrom);
704 
705 /// @brief Conversion Assignment Operator to btVector3.
706 /// @param VecTo The left hand side vector, is an btVector3. The values of VecFrom will be copied here.
707 /// @param VecFrom The right hand side, is a Mezzanine::Vector3, this vector will be copied and unchanged.
708 /// @return An btVector3 in case multiple operators are chainged together (not usually a good idea).
709 btVector3& MEZZ_LIB operator << (btVector3& VecTo, const Mezzanine::Vector3& VecFrom);
710 
711 /// @brief Conversion Assignment Operator to Mezzanine::Vector3.
712 /// @param VecTo The left hand side vector, is an Mezzanine::Vector3. The values of VecFrom will be copied here.
713 /// @param VecFrom The right hand side, is a Ogre::Vector3, this vector will be copied and unchanged.
714 /// @return An Mezzanine::Vector3 in case multiple operators are chainged together (not usually a good idea).
715 Mezzanine::Vector3& MEZZ_LIB operator << (Mezzanine::Vector3& VecTo, const Ogre::Vector3& VecFrom);
716 
717 /// @brief Conversion Assignment Operator to Mezzanine::Vector3.
718 /// @param VecTo The left hand side vector, is an Mezzanine::Vector3. The values of VecFrom will be copied here.
719 /// @param VecFrom The right hand side, is a btVector3, this vector will be copied and unchanged.
720 /// @return An Mezzanine::Vector3 in case multiple operators are chainged together (not usually a good idea).
721 Mezzanine::Vector3& MEZZ_LIB operator << (Mezzanine::Vector3& VecTo, const btVector3& VecFrom);
722 #endif // \SWIG
723 
724 
725 
726 
727 
728 #endif // \include gaurd