32 #include "qmath_utils.h"
87 return QVector(pointA.x+pointB.x,pointA.y+pointB.y);
95 QVector &operator /=(
const float &value) {
101 return QVector(pointA.x/pointB.x,pointA.y/pointB.y);
104 return QVector(point.x/value,point.y/value);
107 return QVector(point.x/value,point.y/value);
115 QVector &operator *=(
const float &value) {
120 friend QVector operator *(
const QVector point,
const float value){
121 return QVector(point.x*value,point.y*value);
124 return QVector(point.x*value,point.y*value);
135 return QVector(pointA.x-pointB.x,pointA.y-pointB.y);
138 bool operator ==(
const QVector &other)
const {
139 return x==other.x && y==other.y;
141 bool operator !=(
const QVector &other)
const {
142 return !(x==other.x && y==other.y);
147 friend ostream& operator<<(ostream& os,
QVector const & point){
148 return os<<
"QVector("<< point.x<<
","<<point.y<<
")";
153 QVector Rotated(
float radianAngle)
const;
154 static QVector AngleToUnitVector(
const float radianAngle);
155 static float AngleBetweenTwoVectors(
QVector vector,
QVector referenceVector);
156 static QSides GetVectorSide(
QVector vector,
QVector referenceUpVector,
float maxAngleDefiningSide=0.785398f);
161 inline float Dot(
QVector with)
const{
162 return (x*with.x)+(y*with.y);
164 inline float Length()
const {
165 return sqrt(x*x+y*y);
167 inline QVector Normalized()
const {
169 return QVector::Zero();
170 float lsqrt=LengthSquared();
172 return QVector::Zero();
176 inline QVector Perpendicular()
const {
179 inline float LengthSquared()
const {
183 inline bool isNaN()
const{
184 if(isnan(x) && isnan(y) ){