QVector2D Class Reference

#include <qvector2d.h>

Class Description

Definition at line 60 of file qvector2d.h.

Public Member Functions

 QVector2D ()
 
 QVector2D (qreal xpos, qreal ypos)
 
 QVector2D (const QPoint &point)
 
 QVector2D (const QPointF &point)
 
 QVector2D (const QVector3D &vector)
 
 QVector2D (const QVector4D &vector)
 
bool isNull () const
 
qreal x () const
 
qreal y () const
 
void setX (qreal x)
 
void setY (qreal y)
 
qreal length () const
 
qreal lengthSquared () const
 
QVector2D normalized () const
 
void normalize ()
 
QVector2Doperator+= (const QVector2D &vector)
 
QVector2Doperator-= (const QVector2D &vector)
 
QVector2Doperator*= (qreal factor)
 
QVector2Doperator*= (const QVector2D &vector)
 
QVector2Doperator/= (qreal divisor)
 
QVector3D toVector3D () const
 
QVector4D toVector4D () const
 
QPoint toPoint () const
 
QPointF toPointF () const
 
 operator QVariant () const
 

Static Public Member Functions

static qreal dotProduct (const QVector2D &v1, const QVector2D &v2)
 

Friends

class QVector3D
 
class QVector4D
 
bool operator== (const QVector2D &v1, const QVector2D &v2)
 
bool operator!= (const QVector2D &v1, const QVector2D &v2)
 
const QVector2D operator+ (const QVector2D &v1, const QVector2D &v2)
 
const QVector2D operator- (const QVector2D &v1, const QVector2D &v2)
 
const QVector2D operator* (qreal factor, const QVector2D &vector)
 
const QVector2D operator* (const QVector2D &vector, qreal factor)
 
const QVector2D operator* (const QVector2D &v1, const QVector2D &v2)
 
const QVector2D operator- (const QVector2D &vector)
 
const QVector2D operator/ (const QVector2D &vector, qreal divisor)
 
bool qFuzzyCompare (const QVector2D &v1, const QVector2D &v2)
 

Constructor & Destructor Documentation

QVector2D ( )
inline

Definition at line 131 of file qvector2d.h.

131 : xp(0.0f), yp(0.0f) {}
GLclampf f
Definition: GLee.h:9303
QVector2D ( qreal  xpos,
qreal  ypos 
)
inline

Definition at line 135 of file qvector2d.h.

135 : xp(xpos), yp(ypos) {}
QVector2D ( const QPoint point)
inlineexplicit

Definition at line 137 of file qvector2d.h.

137 : xp(point.x()), yp(point.y()) {}
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
QVector2D ( const QPointF point)
inlineexplicit

Definition at line 139 of file qvector2d.h.

139 : xp(point.x()), yp(point.y()) {}
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
QVector2D ( const QVector3D vector)
explicit
QVector2D ( const QVector4D vector)
explicit

Member Function Documentation

bool isNull ( ) const
inline

Definition at line 141 of file qvector2d.h.

142 {
143  return qIsNull(xp) && qIsNull(yp);
144 }
qreal x ( ) const
inline

Definition at line 146 of file qvector2d.h.

146 { return qreal(xp); }
qreal y ( ) const
inline

Definition at line 147 of file qvector2d.h.

147 { return qreal(yp); }
void setX ( qreal  x)
inline

Definition at line 149 of file qvector2d.h.

149 { xp = aX; }
void setY ( qreal  y)
inline

Definition at line 150 of file qvector2d.h.

150 { yp = aY; }
qreal length ( ) const
qreal lengthSquared ( ) const
QVector2D normalized ( ) const
void normalize ( )
QVector2D & operator+= ( const QVector2D vector)
inline

Definition at line 152 of file qvector2d.h.

153 {
154  xp += vector.xp;
155  yp += vector.yp;
156  return *this;
157 }
QVector2D & operator-= ( const QVector2D vector)
inline

Definition at line 159 of file qvector2d.h.

160 {
161  xp -= vector.xp;
162  yp -= vector.yp;
163  return *this;
164 }
QVector2D & operator*= ( qreal  factor)
inline

Definition at line 166 of file qvector2d.h.

167 {
168  xp *= factor;
169  yp *= factor;
170  return *this;
171 }
QVector2D & operator*= ( const QVector2D vector)
inline

Definition at line 173 of file qvector2d.h.

174 {
175  xp *= vector.xp;
176  yp *= vector.yp;
177  return *this;
178 }
QVector2D & operator/= ( qreal  divisor)
inline

Definition at line 180 of file qvector2d.h.

181 {
182  xp /= divisor;
183  yp /= divisor;
184  return *this;
185 }
GLXDrawable int64_t int64_t divisor
Definition: GLee.h:10690
static qreal dotProduct ( const QVector2D v1,
const QVector2D v2 
)
static
QVector3D toVector3D ( ) const
QVector4D toVector4D ( ) const
QPoint toPoint ( ) const
inline

Definition at line 237 of file qvector2d.h.

238 {
239  return QPoint(qRound(xp), qRound(yp));
240 }
Definition: qpoint.h:53
QPointF toPointF ( ) const
inline

Definition at line 242 of file qvector2d.h.

243 {
244  return QPointF(qreal(xp), qreal(yp));
245 }
operator QVariant ( ) const

Friends And Related Function Documentation

friend class QVector3D
friend

Definition at line 125 of file qvector2d.h.

friend class QVector4D
friend

Definition at line 126 of file qvector2d.h.

bool operator== ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 187 of file qvector2d.h.

188 {
189  return v1.xp == v2.xp && v1.yp == v2.yp;
190 }
bool operator!= ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 192 of file qvector2d.h.

193 {
194  return v1.xp != v2.xp || v1.yp != v2.yp;
195 }
const QVector2D operator+ ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 197 of file qvector2d.h.

198 {
199  return QVector2D(v1.xp + v2.xp, v1.yp + v2.yp, 1);
200 }
const QVector2D operator- ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 202 of file qvector2d.h.

203 {
204  return QVector2D(v1.xp - v2.xp, v1.yp - v2.yp, 1);
205 }
const QVector2D operator* ( qreal  factor,
const QVector2D vector 
)
friend

Definition at line 207 of file qvector2d.h.

208 {
209  return QVector2D(vector.xp * factor, vector.yp * factor, 1);
210 }
const QVector2D operator* ( const QVector2D vector,
qreal  factor 
)
friend

Definition at line 212 of file qvector2d.h.

213 {
214  return QVector2D(vector.xp * factor, vector.yp * factor, 1);
215 }
const QVector2D operator* ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 217 of file qvector2d.h.

218 {
219  return QVector2D(v1.xp * v2.xp, v1.yp * v2.yp, 1);
220 }
const QVector2D operator- ( const QVector2D vector)
friend

Definition at line 222 of file qvector2d.h.

223 {
224  return QVector2D(-vector.xp, -vector.yp, 1);
225 }
const QVector2D operator/ ( const QVector2D vector,
qreal  divisor 
)
friend

Definition at line 227 of file qvector2d.h.

228 {
229  return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
230 }
GLXDrawable int64_t int64_t divisor
Definition: GLee.h:10690
bool qFuzzyCompare ( const QVector2D v1,
const QVector2D v2 
)
friend

Definition at line 232 of file qvector2d.h.

233 {
234  return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
235 }
friend bool qFuzzyCompare(const QVector2D &v1, const QVector2D &v2)
Definition: qvector2d.h:232

The documentation for this class was generated from the following file: