42 #define PROTOTYPEVEC4D_C 44 #include "prototypeVec4d.hh" 46 prototypeVec4d::prototypeVec4d(QObject *parent ) :
52 QString prototypeVec4d::toString()
const {
53 return "Vector : ( " +
54 thisObject().property(
"x").toString() +
"," +
55 thisObject().property(
"y").toString() +
"," +
56 thisObject().property(
"z").toString() +
"," +
57 thisObject().property(
"w").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()));
64 thisObject().setProperty(
"w", QScriptValue(thisObject().property(
"w").toNumber() * _scalar.toNumber()));
68 thisObject().setProperty(
"x", QScriptValue(_vector.property(
"x").toNumber() + thisObject().property(
"x").toNumber()));
69 thisObject().setProperty(
"y", QScriptValue(_vector.property(
"y").toNumber() + thisObject().property(
"y").toNumber()));
70 thisObject().setProperty(
"z", QScriptValue(_vector.property(
"z").toNumber() + thisObject().property(
"z").toNumber()));
71 thisObject().setProperty(
"w", QScriptValue(_vector.property(
"w").toNumber() + thisObject().property(
"w").toNumber()));
76 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() - _vector.property(
"x").toNumber()));
77 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() - _vector.property(
"y").toNumber()));
78 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() - _vector.property(
"z").toNumber()));
79 thisObject().setProperty(
"w", QScriptValue(thisObject().property(
"w").toNumber() - _vector.property(
"w").toNumber()));
83 thisObject().setProperty(
"x", QScriptValue(0.0));
84 thisObject().setProperty(
"y", QScriptValue(0.0));
85 thisObject().setProperty(
"z", QScriptValue(0.0));
86 thisObject().setProperty(
"w", QScriptValue(0.0));
90 return QScriptValue( thisObject().property(
"x").toNumber() * _vector.property(
"x").toNumber() +
91 thisObject().property(
"y").toNumber() * _vector.property(
"y").toNumber() +
92 thisObject().property(
"z").toNumber() * _vector.property(
"z").toNumber() +
93 thisObject().property(
"w").toNumber() * _vector.property(
"w").toNumber() );
98 return QScriptValue( sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
99 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
100 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() +
101 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() ) );
105 return QScriptValue( 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() +
108 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() );
112 double length = 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() +
115 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() );
117 if ( length != 0.0 ) {
118 thisObject().setProperty(
"x", ( thisObject().property(
"x").toNumber() / length ) );
119 thisObject().setProperty(
"y", ( thisObject().property(
"y").toNumber() / length ) );
120 thisObject().setProperty(
"z", ( thisObject().property(
"z").toNumber() / length ) );
121 thisObject().setProperty(
"w", ( thisObject().property(
"w").toNumber() / length ) );
void sub(QScriptValue _vector)
Subtracts another vector from this vector.
void multiply(QScriptValue _scalar)
Multiplies the given vector with the scalar.
QScriptValue sprod(QScriptValue _vector)
Calculate scalar product.
void zero()
Resets all components of the vector to zero.
QScriptValue norm()
Calculate the Euclidean norm of the vector.
void normalize()
Normalize the vector.
QScriptValue sqrnorm()
Calculate the squared Euclidean norm of the vector.
void add(QScriptValue _vector)
Adds another vector to this vector.