43 #define PROTOTYPEVEC3D_C 45 #include "prototypeVec3d.hh" 47 prototypeVec3d::prototypeVec3d(QObject *parent ) :
53 QString prototypeVec3d::toString()
const {
54 return "Vector : ( " +
55 thisObject().property(
"x").toString() +
"," +
56 thisObject().property(
"y").toString() +
"," +
57 thisObject().property(
"z").toString() +
" )";
61 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() * _scalar.toNumber()));
62 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() * _scalar.toNumber()));
63 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() * _scalar.toNumber()));
67 thisObject().setProperty(
"x", QScriptValue(_vector.property(
"x").toNumber() + thisObject().property(
"x").toNumber()));
68 thisObject().setProperty(
"y", QScriptValue(_vector.property(
"y").toNumber() + thisObject().property(
"y").toNumber()));
69 thisObject().setProperty(
"z", QScriptValue(_vector.property(
"z").toNumber() + thisObject().property(
"z").toNumber()));
74 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() - _vector.property(
"x").toNumber()));
75 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() - _vector.property(
"y").toNumber()));
76 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() - _vector.property(
"z").toNumber()));
80 thisObject().setProperty(
"x", QScriptValue(0.0));
81 thisObject().setProperty(
"y", QScriptValue(0.0));
82 thisObject().setProperty(
"z", QScriptValue(0.0));
86 return QScriptValue( thisObject().property(
"x").toNumber() * _vector.property(
"x").toNumber() +
87 thisObject().property(
"y").toNumber() * _vector.property(
"y").toNumber() +
88 thisObject().property(
"z").toNumber() * _vector.property(
"z").toNumber() );
93 return QScriptValue( sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
94 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
95 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() ) );
99 return QScriptValue( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
100 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
101 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() );
105 double length = sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
106 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
107 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() );
109 if ( length != 0.0 ) {
110 thisObject().setProperty(
"x", ( thisObject().property(
"x").toNumber() / length ) );
111 thisObject().setProperty(
"y", ( thisObject().property(
"y").toNumber() / length ) );
112 thisObject().setProperty(
"z", ( thisObject().property(
"z").toNumber() / length ) );
void multiply(QScriptValue _scalar)
Multiplies the given vector with the scalar.
QScriptValue sqrnorm()
Calculate the squared Euclidean norm of the vector.
void normalize()
Normalize the vector.
void add(QScriptValue _vector)
Adds another vector to this vector.
void zero()
Resets all components of the vector to zero.
QScriptValue sprod(QScriptValue _vector)
Calculate scalar product.
void sub(QScriptValue _vector)
Subtracts another vector from this vector.
QScriptValue norm()
Calculate the Euclidean norm of the vector.