62 #define PROTOTYPEVEC4D_C 64 #include "prototypeVec4d.hh" 66 prototypeVec4d::prototypeVec4d(QObject *parent ) :
72 QString prototypeVec4d::toString()
const {
73 return "Vector : ( " +
74 thisObject().property(
"x").toString() +
"," +
75 thisObject().property(
"y").toString() +
"," +
76 thisObject().property(
"z").toString() +
"," +
77 thisObject().property(
"w").toString() +
" )";
81 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() * _scalar.toNumber()));
82 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() * _scalar.toNumber()));
83 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() * _scalar.toNumber()));
84 thisObject().setProperty(
"w", QScriptValue(thisObject().property(
"w").toNumber() * _scalar.toNumber()));
88 thisObject().setProperty(
"x", QScriptValue(_vector.property(
"x").toNumber() + thisObject().property(
"x").toNumber()));
89 thisObject().setProperty(
"y", QScriptValue(_vector.property(
"y").toNumber() + thisObject().property(
"y").toNumber()));
90 thisObject().setProperty(
"z", QScriptValue(_vector.property(
"z").toNumber() + thisObject().property(
"z").toNumber()));
91 thisObject().setProperty(
"w", QScriptValue(_vector.property(
"w").toNumber() + thisObject().property(
"w").toNumber()));
96 thisObject().setProperty(
"x", QScriptValue(thisObject().property(
"x").toNumber() - _vector.property(
"x").toNumber()));
97 thisObject().setProperty(
"y", QScriptValue(thisObject().property(
"y").toNumber() - _vector.property(
"y").toNumber()));
98 thisObject().setProperty(
"z", QScriptValue(thisObject().property(
"z").toNumber() - _vector.property(
"z").toNumber()));
99 thisObject().setProperty(
"w", QScriptValue(thisObject().property(
"w").toNumber() - _vector.property(
"w").toNumber()));
103 thisObject().setProperty(
"x", QScriptValue(0.0));
104 thisObject().setProperty(
"y", QScriptValue(0.0));
105 thisObject().setProperty(
"z", QScriptValue(0.0));
106 thisObject().setProperty(
"w", QScriptValue(0.0));
110 return QScriptValue( thisObject().property(
"x").toNumber() * _vector.property(
"x").toNumber() +
111 thisObject().property(
"y").toNumber() * _vector.property(
"y").toNumber() +
112 thisObject().property(
"z").toNumber() * _vector.property(
"z").toNumber() +
113 thisObject().property(
"w").toNumber() * _vector.property(
"w").toNumber() );
118 return QScriptValue( sqrt( 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() +
121 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() ) );
125 return QScriptValue( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
126 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
127 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() +
128 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() );
132 double length = sqrt( thisObject().property(
"x").toNumber() * thisObject().property(
"x").toNumber() +
133 thisObject().property(
"y").toNumber() * thisObject().property(
"y").toNumber() +
134 thisObject().property(
"z").toNumber() * thisObject().property(
"z").toNumber() +
135 thisObject().property(
"w").toNumber() * thisObject().property(
"w").toNumber() );
137 if ( length != 0.0 ) {
138 thisObject().setProperty(
"x", ( thisObject().property(
"x").toNumber() / length ) );
139 thisObject().setProperty(
"y", ( thisObject().property(
"y").toNumber() / length ) );
140 thisObject().setProperty(
"z", ( thisObject().property(
"z").toNumber() / length ) );
141 thisObject().setProperty(
"w", ( thisObject().property(
"w").toNumber() / length ) );
QScriptValue norm()
Calculate the Euclidean norm of the vector.
void sub(QScriptValue _vector)
Subtracts another vector from this vector.
QScriptValue sqrnorm()
Calculate the squared Euclidean norm of the vector.
void multiply(QScriptValue _scalar)
Multiplies the given vector with the scalar.
QScriptValue sprod(QScriptValue _vector)
Calculate scalar product.
void add(QScriptValue _vector)
Adds another vector to this vector.
void zero()
Resets all components of the vector to zero.
void normalize()
Normalize the vector.