1
$\begingroup$

So I have a matrix:

Matrix4f Mbsp = Matrix4f(Vector4f(1.0, 4.0, 1.0, 0.0)
            , Vector4f(-3.0, 0.0, 3.0, 0.0)
            , Vector4f(3.0, -6.0, 3.0, 0.0)
            , Vector4f(-1.0, 3.0, -3.0, 1.0), true);

and I'm doing a scalar multiplication to it, e.g.:

Mbsp = (1.0/6.0)*Mbsp;

One would now expect Mbsp to be

$$\begin{array} &1/6&-1/2&1/2&-1/6\\2/3&0&-1&1/2\\1/6&1/2&1/2&-1/2\\ 0&0&0&1/6 \end{array}$$

However Mbsp now is:

$$\begin{array} &1.0&1.4901161e-008&1.4901161e-008&0\\1.0&1.4901161e-008&1.4901161e-008&0\\1.0&1.4901161e-008&1.4901161e-008&0&\\ 1.0&1.4901161e-008&1.4901161e-008&0 \end{array}$$

Similarly, doing (using the original Mbsp):

Mbsp = 2.0*Mbsp;

Gives

$$\begin{array} &12&0&0&0\\12&0&0&0\\12&0&0&0\\ 12&0&0&0 \end{array}$$

What's wrong?

$\endgroup$
  • $\begingroup$ which matrix lib? $\endgroup$ – ratchet freak Feb 9 '17 at 11:03
  • $\begingroup$ @ratchetfreak vecmath $\endgroup$ – mavavilj Feb 9 '17 at 11:05
  • $\begingroup$ Have you printed out the original matrix to ensure its constructed OK? Can you step through code to check the scalar multiplication operator is being called and verify that a temporary matrix/vector isn't being constructed? Can you post a link to this vecmath library? $\endgroup$ – PeteUK Feb 11 '17 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.