38 qWarning(
"Vec::projectOnAxis: axis direction is not normalized (norm=%f).", direction.
norm());
41 *
this = (((*this)*direction) / direction.
squaredNorm()) * direction;
51 qWarning(
"Vec::projectOnPlane: plane normal is not normalized (norm=%f).", normal.
norm());
54 *
this -= (((*this)*normal) / normal.
squaredNorm()) * normal;
62 if ((fabs(y) >= 0.9*fabs(x)) && (fabs(z) >= 0.9*fabs(x)))
63 return Vec(0.0, -z, y);
65 if ((fabs(x) >= 0.9*fabs(y)) && (fabs(z) >= 0.9*fabs(y)))
66 return Vec(-z, 0.0, x);
68 return Vec(-y, x, 0.0);
80 QStringList attribute;
81 attribute <<
"x" <<
"y" <<
"z";
82 for (
int i=0; i<attribute.size(); ++i)
83 #ifdef QGLVIEWER_UNION_NOT_SUPPORTED
126 QDomElement de = document.createElement(name);
127 de.setAttribute(
"x", QString::number(x));
128 de.setAttribute(
"y", QString::number(y));
129 de.setAttribute(
"z", QString::number(z));
156 const Vec v(element);
162 return o << v.
x <<
'\t' << v.
y <<
'\t' << v.
z;
void initFromDOMElement(const QDomElement &element)
Vec orthogonalVec() const
qreal squaredNorm() const
void projectOnPlane(const Vec &normal)
The Vec class represents 3D positions and 3D vectors.
static qreal qrealFromDom(const QDomElement &e, const QString &attribute, qreal defValue)
void projectOnAxis(const Vec &direction)
QDomElement domElement(const QString &name, QDomDocument &document) const
ostream & operator<<(ostream &o, const Vec &v)