44 #include "stringtool.h"
46 #include "MathTools/mathtools.h"
113 return ( this->
X == 0.0 && this->
Y == 0.0 );
120 {
return ( Vec2.
X == this->X && Vec2.
Y == this->Y ); }
123 {
return ( Vec2.
X != this->X || Vec2.
Y != this->Y ); }
126 {
return ( Vec2.x == this->X && Vec2.y == this->Y ); }
129 {
return ( Vec2.x != this->X || Vec2.y != this->Y ); }
132 {
return ( this->X <= Vec.X && this->
Y <= Vec.
Y); }
135 {
return ( this->
X >= Vec.
X && this->Y >= Vec.
Y); }
141 {
return Vector2( -(this->
X), -(this->
Y) ); }
246 {
return ( this->
X * Other.
Y ) - ( this->
Y * Other.
X ); }
249 {
return ( this->
X * Other.
X ) + ( this->
Y * Other.
Y ); }
252 {
return ( *
this - Other ).Length(); }
255 {
return ( *
this - Other ).SquaredLength(); }
261 {
return ( this->
X * this->
X + this->
Y * this->
Y ); }
273 if( Length > 1e-08 ) {
293 Angle = MathTools::GetTwoPi() - Angle;
302 if( LenProduct < 1e-6f )
307 f = MathTools::Clamp( f, (
Real)-1.0, (
Real)1.0 );
308 return MathTools::ACos(f);
322 if( VersionAttr && XAttr && YAttr )
352 {
return String(
"Vector2"); }
359 if( ( First - Second ).SquaredLength() < 1e-6 )
361 if( MathTools::Abs( First.
X - Second.
X ) > 1e-3 )
362 return ( First.
X < Second.
X );
363 return ( First.
Y < Second.
Y );
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
static Vector2 Unit_Y()
Gets a vector representing the Y unit of a Vector2.
Boole IsZero() const
Checks to see if the values of this vector are all zero.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
Vector2 Perpendicular() const
Generates a Vector2 that is perpendicular to this vector.
Vector2 operator/(const Real &scalar) const
Scaling by Division.
bool Boole
Generally acts a single bit, true or false.
Real Distance(const Vector2 &Other) const
Gets the distance between this and another vector.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
std::ostream & Serialize(std::ostream &Stream, const T &Converted, const String &Indent=String(""))
Convert any class that supports serialization or has a serializer to a string of chars in a stream...
Vector2 & operator/=(const Real &scalar)
Scaling by Division.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
void ExtractOgreVector2(const Ogre::Vector2 &Thiers)
Copies an existing Ogre vector2.
Ogre::Vector2 GetOgreVector2() const
Gets a Ogre vector2.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
Real AngleTo(const Vector2 &Other) const
Gets an oriented angle between this Vector2 and another Vector2.
This implements the exception hiearchy for Mezzanine.
Vector2 & operator-=(const Vector2 &Vec2)
Subraction assignment Operator.
Boole operator()(const Vector2 &First, const Vector2 &Second) const
Compares two Vector2's to determine which has the greater length/magnitude.
Real DotProduct(const Vector2 &Other) const
This is used to calculate the dotproduct of this and another vector.
Boole operator==(const Mezzanine::Vector2 &Vec2) const
Equality Comparison Operator.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
Vector2 Reflect(const Vector2 &Normal) const
Gets a reflection vector to the line with the given normal.
bool SetValue(const Char8 *rhs)
Set the value of this.
bool SetName(const Char8 *rhs)
Set the name of .
Vector2 operator+(const Vector2 &Vec2) const
Addition Operator.
Real Y
Coordinate on the Y vector.
A light-weight handle for manipulating nodes in DOM tree.
Real X
Coordinate on the X vector.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
This is used to represent a point on a 2 dimentional area, such as a screen.
Real CrossProduct(const Vector2 &Other) const
This is used to calculate the crossproduct of this and another vector.
void SetIdentity()
Sets the values of this vector2 to identity values(0,0).
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
Real SquaredLength() const
Gets the length of this vector squared.
static Vector2 Unit_X()
Gets a vector representing the X unit of a Vector2.
Vector2 operator*(const Real &scalar) const
Scaling by multiplication.
static Vector2 Neg_Unit_Y()
Gets a vector representing the negative Y unit of a Vector2.
Real SquaredDistance(const Vector2 &Other) const
Gets the squared distance between this and another vector.
void SetValues(const Real &x, const Real &y)
Sets the X and Y values of this vector2.
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
Real Length() const
Gets the length of this vector.
Thrown when the identity string wasn't valid at all.
Boole operator>=(const Mezzanine::Vector2 &Vec) const
Greater than or Equal Comparison Operator.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
Boole operator!=(const Mezzanine::Vector2 &Vec2) const
Equality Comparison Operator.
The bulk of the engine components go in this namspace.
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
Vector2()
Default Constructor.
Vector2 & Normalize()
Normalizes this Vector2.
Vector2 operator-()
Unary Operator.
Vector2 GetNormal() const
Gets the normal of this Vector2.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
Vector2 & operator+=(const Vector2 &Vec2)
Addition assignment Operator.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
Vector2 & operator*=(const Real &scalar)
Scaling by multiplication.
static Vector2 Neg_Unit_X()
Gets a vector representing the negative X unit of a Vector2.
std::string String
A datatype used to a series of characters.
Real AngleBetween(const Vector2 &Other) const
Gets the angle between this Vector2 and another.
void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Boole operator<=(const Mezzanine::Vector2 &Vec) const
Less or Equal Comparison Operator.