62 #define PROTOTYPEVEC3D_C 64 #include "prototypeVec3d.hh" 66 prototypeVec3d::prototypeVec3d(QObject *parent ) :
72 QString prototypeVec3d::toString()
const {
73 return "Vector : ( " +
74 thisObject().property(
"x").toString() +
"," +
75 thisObject().property(
"y").toString() +
"," +
76 thisObject().property(
"z").toString() +
" )";
80 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() * _scalar.toNumber()));
81 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() * _scalar.toNumber()));
82 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() * _scalar.toNumber()));
86 thisObject().setProperty(
"x", QScriptValue(_vector.property(
"x").toNumber() + thisObject().property(
"x").toNumber()));
87 thisObject().setProperty(
"y", QScriptValue(_vector.property(
"y").toNumber() + thisObject().property(
"y").toNumber()));
88 thisObject().setProperty(
"z", QScriptValue(_vector.property(
"z").toNumber() + thisObject().property(
"z").toNumber()));
93 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() - _vector.property(
"x").toNumber()));
94 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() - _vector.property(
"y").toNumber()));
95 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() - _vector.property(
"z").toNumber()));
99 thisObject().setProperty(
"x", QScriptValue(0.0));
100 thisObject().setProperty(
"y", QScriptValue(0.0));
101 thisObject().setProperty(
"z", QScriptValue(0.0));
105 return QScriptValue( thisObject().property(
"x").toNumber() * _vector.property(
"x").toNumber() +
106 thisObject().property(
"y").toNumber() * _vector.property(
"y").toNumber() +
107 thisObject().property(
"z").toNumber() * _vector.property(
"z").toNumber() );
112 return QScriptValue( sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
113 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
114 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() ) );
118 return QScriptValue( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
119 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
120 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() );
124 double length = sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
125 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
126 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() );
128 if ( length != 0.0 ) {
129 thisObject().setProperty(
"x", ( thisObject().property(
"x").toNumber() / length ) );
130 thisObject().setProperty(
"y", ( thisObject().property(
"y").toNumber() / length ) );
131 thisObject().setProperty(
"z", ( thisObject().property(
"z").toNumber() / length ) );
void normalize()
Normalize the vector.
void zero()
Resets all components of the vector to zero.
void sub(QScriptValue _vector)
Subtracts another vector from this vector.
QScriptValue sprod(QScriptValue _vector)
Calculate scalar product.
void add(QScriptValue _vector)
Adds another vector to this vector.
QScriptValue sqrnorm()
Calculate the squared Euclidean norm of the vector.
void multiply(QScriptValue _scalar)
Multiplies the given vector with the scalar.
QScriptValue norm()
Calculate the Euclidean norm of the vector.