22 #include <dtkCoreSupport/dtkGlobal.h>
31 double coordinates[3];
48 d->coordinates[0] = 0.0;
49 d->coordinates[1] = 0.0;
50 d->coordinates[2] = 0.0;
62 d->coordinates[0] =
x;
63 d->coordinates[1] =
y;
64 d->coordinates[2] =
z;
74 this->setParent(other.parent());
75 d->coordinates[0] = other.d->coordinates[0];
76 d->coordinates[1] = other.d->coordinates[1];
77 d->coordinates[2] = other.d->coordinates[2];
87 this->setParent(other->parent());
88 d->coordinates[0] = other->d->coordinates[0];
89 d->coordinates[1] = other->d->coordinates[1];
90 d->coordinates[2] = other->d->coordinates[2];
98 d->coordinates[0] = p[0];
99 d->coordinates[1] = p[1];
100 d->coordinates[2] = p[2];
120 d->coordinates[0] = other.d->coordinates[0];
121 d->coordinates[1] = other.d->coordinates[1];
122 d->coordinates[2] = other.d->coordinates[2];
133 d->coordinates[0] += other.d->coordinates[0];
134 d->coordinates[1] += other.d->coordinates[1];
135 d->coordinates[2] += other.d->coordinates[2];
146 d->coordinates[0] -= other.d->coordinates[0];
147 d->coordinates[1] -= other.d->coordinates[1];
148 d->coordinates[2] -= other.d->coordinates[2];
159 d->coordinates[0] *= scalar;
160 d->coordinates[1] *= scalar;
161 d->coordinates[2] *= scalar;
172 if(!(scalar != 0.)) {
173 qWarning() << DTK_PRETTY_FUNCTION <<
"Preventing division by 0. Operand not affected.";
177 d->coordinates[0] /= scalar;
178 d->coordinates[1] /= scalar;
179 d->coordinates[2] /= scalar;
192 axlPoint result(d->coordinates[0] + other.d->coordinates[0],
193 d->coordinates[1] + other.d->coordinates[1],
194 d->coordinates[2] + other.d->coordinates[2] );
204 axlPoint result(d->coordinates[0] - other.d->coordinates[0],
205 d->coordinates[1] - other.d->coordinates[1],
206 d->coordinates[2] - other.d->coordinates[2]);
216 axlPoint result(d->coordinates[0] * scalar,
217 d->coordinates[1] * scalar,
218 d->coordinates[2] * scalar);
228 return (d->coordinates[0] * other[0]
229 + d->coordinates[1] * other[1]
230 + d->coordinates[2] * other[2]);
237 return (d->coordinates[0] < other.
x()
238 || (!(other.
x() == d->coordinates[0]) && d->coordinates[1] < other.
y())
239 || (!(other.
x() == d->coordinates[0]) && !(other.
y() == d->coordinates[1]) && d->coordinates[2] < other.
z()));
250 if(!(scalar != 0.)) {
251 qWarning() << DTK_PRETTY_FUNCTION <<
"Preventing division by 0. Returning default point";
255 axlPoint result(d->coordinates[0] / scalar,
256 d->coordinates[1] / scalar,
257 d->coordinates[2] / scalar);
265 d->coordinates[0] * matrix[0] + d->coordinates[1] * matrix[1] + d->coordinates[2] * matrix[2] + matrix[3],
266 d->coordinates[0] * matrix[4] + d->coordinates[1] * matrix[5] + d->coordinates[2] * matrix[6] + matrix[7],
267 d->coordinates[0] * matrix[8] + d->coordinates[1] * matrix[9] + d->coordinates[2] * matrix[10] + matrix[11]
274 d->coordinates[0] * matrix[0] + d->coordinates[1] * matrix[1] + d->coordinates[2] * matrix[2],
275 d->coordinates[0] * matrix[4] + d->coordinates[1] * matrix[5] + d->coordinates[2] * matrix[6],
276 d->coordinates[0] * matrix[8] + d->coordinates[1] * matrix[9] + d->coordinates[2] * matrix[10]
282 return (this->
x() == point2.
x()
283 && this->
y() == point2.
y()
284 && this->
z() == point2.
z());
288 return !(*
this == point2);
298 return d->coordinates[0];
307 return d->coordinates[1];
316 return d->coordinates[2];
326 return d->coordinates[i];
335 return d->coordinates[0];
344 return d->coordinates[1];
353 return d->coordinates[2];
363 return d->coordinates[i];
372 d->coordinates[0] =
x;
373 d->coordinates[1] =
y;
374 d->coordinates[2] =
z;
391 d->coordinates[0] =
x;
398 d->coordinates[1] =
y;
405 d->coordinates[2] =
z;
412 double n = this->
norm();
415 d->coordinates[0] /= n;
416 d->coordinates[1] /= n;
417 d->coordinates[2] /= n;
422 double n = this->
norm();
425 d->coordinates[0] /= n;
426 d->coordinates[1] /= n;
427 d->coordinates[2] /= n;
438 return (d->coordinates[0]==point->
x() && d->coordinates[1]==point->
y() && d->coordinates[2]==point->
z());
447 return d->coordinates ;
452 return sqrt(d->coordinates[0] * d->coordinates[0] + d->coordinates[1] * d->coordinates[1] + d->coordinates[2] * d->coordinates[2]);
461 double dx = rhs.d->coordinates[0] - lhs.d->coordinates[0];
462 double dy = rhs.d->coordinates[1] - lhs.d->coordinates[1];
463 double dz = rhs.d->coordinates[2] - lhs.d->coordinates[2];
465 return qSqrt(dx*dx + dy*dy + dz*dz);
474 double dx = rhs->d->coordinates[0] - lhs->d->coordinates[0];
475 double dy = rhs->d->coordinates[1] - lhs->d->coordinates[1];
476 double dz = rhs->d->coordinates[2] - lhs->d->coordinates[2];
478 return qSqrt(dx*dx + dy*dy + dz*dz);
488 lhs.d->coordinates[1]*rhs.d->coordinates[2] - lhs.d->coordinates[2]*rhs.d->coordinates[1],
489 lhs.d->coordinates[2]*rhs.d->coordinates[0] - lhs.d->coordinates[0]*rhs.d->coordinates[2],
490 lhs.d->coordinates[0]*rhs.d->coordinates[1] - lhs.d->coordinates[1]*rhs.d->coordinates[0]
501 lhs->d->coordinates[1]*rhs->d->coordinates[2] - lhs->d->coordinates[2]*rhs->d->coordinates[1],
502 lhs->d->coordinates[2]*rhs->d->coordinates[0] - lhs->d->coordinates[0]*rhs->d->coordinates[2],
503 lhs->d->coordinates[0]*rhs->d->coordinates[1] - lhs->d->coordinates[1]*rhs->d->coordinates[0]
509 return lhs.
x()*rhs.
x() + lhs.
y()*rhs.
y() + lhs.
z()*rhs.
z();
513 return lhs->
x()*rhs->
x() + lhs->
y()*rhs->
y() + lhs->
z()*rhs->
z();
523 dbg.nospace() << QString(
"axlPoint: (%1, %2, %3)").arg(point.
x()).arg(point.
y()).arg(point.
z());
530 dbg.nospace() << QString(
"axlPoint: (%1, %2, %3)").arg(point.
x()).arg(point.
y()).arg(point.
z());
537 dbg.nospace() << QString(
"axlPoint: (%1, %2, %3)").arg(point->
x()).arg(point->
y()).arg(point->
z());
544 QString result =
"axlPoint";
545 result.append(
"\nX : "+QString::number(d->coordinates[0]) +
"\nY : "+QString::number(d->coordinates[1]) +
"\nZ : "+QString::number(d->coordinates[2]));
573 QVariant
id = QVariant::fromValue(
identifier());
574 QVariant
x = QVariant::fromValue(d->coordinates[0]);
575 QVariant
y = QVariant::fromValue(d->coordinates[1]);
576 QVariant
z = QVariant::fromValue(d->coordinates[2]);
581 QVariant name = QVariant::fromValue(objectName());
589 QVariant
x = data.at(1);
590 QVariant
y = data.at(2);
591 QVariant
z = data.at(3);
592 QString name = data.last().toString();
594 setCoordinates(qvariant_cast<double>(x),qvariant_cast<double>(y),qvariant_cast<double>(z) );
QDebug operator<<(QDebug dbg, axlPoint point)
Class axlPoint defines 3D points.
double operator*(const axlPoint &other) const
Compute the inner product of the two vectors.
double * coordinates(void) const
Returns coordinates of this point.
void transformAsPoint(double matrix[12])
Multiplication by 3x3 left block (rotation part) and addition with 3x1 right block (translation part)...
QVariantList convertDataToQVariant(void) const
Convert an axlAbstractData into a QVariantList that specifies all properties of the axlAbstractData...
bool operator!=(const axlPoint &point2) const
axlPoint(QObject *parent=0)
Constructs an axel point of zero coordinates with parent parent of QObject type.
~axlPoint(void)
Destroys the axel point.
axlPoint operator+(const axlPoint &other) const
Returns a point that results from the addition of this point and the other point. ...
void touchX(double x)
Change coordinates of this point.
dtkAbstractData * createaxlPoint(void)
virtual QString description(void) const
virtual QString identifier(void) const
axlPoint & operator-=(const axlPoint &other)
Substracts the coordinates of the other point to this point and returns a reference to this point...
double z(void) const
Returns z-coordinate of this point.
axlPoint & operator/=(double scalar)
Divides the coordinates of this point by a scalar value and returns a reference to this point...
axlPoint & normalized(void)
static double dotProduct(const axlPoint &lhs, const axlPoint &rhs)
axlPoint operator/(double scalar) const
Returns a point that results from the division of the scalar with this point.
axlPoint operator-(const axlPoint &other) const
Returns a point that results from the substraction of this point and the other point.
axlPoint & operator+=(const axlPoint &other)
Adds the coordinates of the other point to this point and returns a reference to this point...
double x(void) const
Returns x-coordinate of this point.
bool operator==(const axlPoint &point2) const
static axlPoint crossProduct(const axlPoint &lhs, const axlPoint &rhs)
Returns the cross product between lhs (coords) and rhs (coords).
bool isEqualTo(axlPoint *point)
Check if the point we apply the method on is equal to point.
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
axlPoint & operator=(const axlPoint &other)
Assigns other to this point and returns a reference to this point.
int convertQVariantToData(const QVariantList &data)
Modify properties and geometry variables of the axlAbstractData. Return 1 if the modification was suc...
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
double operator[](int i) const
Returns i-th coordinate of this point.
Class axlAbstractData defines an API for all type of axel data.
double y(void) const
Returns y-coordinate of this point.
axlPoint & operator*=(double scalar)
Multiplies the coordinates of this point by a scalar value and returns a reference to this point...
void transformAsVector(double matrix[12])
Multiplication by 3x3 left block (rotation part) and addition with 3x1 right block (translation part)...
bool operator<(const axlPoint &other) const
order on axlPoints. Compare the coordinates (x,y,z) by lexicographic order.