Registered Member
|
I am trying to decide if I want to use Eigen or GLM for my engine math library. GLM just dropped in and did what I expected. But Eigen is given me some issues.
I am using Qt as the development platform. Qt already has heartburn with Eigen with its auto completion abilities. Thats a irritation, but I can live with it. But here's a small problem which makes me worry Eigen just might not be a good fit with Qt. I have a small piece of code that does this:
When I try to compile this, I get this error:
I worry that using Eigen in Qt is just going to be a uphill battle. What am I doing wrong here? |
Global Moderator
|
I don't know Eigen, but the static_assert is pretty clear, no? There's intentionally no overload for * in "v*v", because it's unclear whether you mean the dot product or the coefficient-wise product. Use the appropriate functions to calculate either of them.
Greetings!
I'm working on the KDevelop IDE.
|
Registered Member
|
I looked through the documentation somewhat. they do a lot of multiplication of a matrices. From what I gathered, a Vector2 is just a really small, two element matrix. the examples I saw show them multiplying matrices the way my code above does. I couldn't find a straight forward example of multiplying two vectors together. This is fairly common in 3d math.
Can someone show me a example of how this is done with Eigen?. |
Global Moderator
|
Did you try v.dot(w)?
You cannot matrix-multiply [1, 2] with [3, 4], I guess that's why it doesn't work.
I'm working on the KDevelop IDE.
|
Registered Member
|
"You cannot matrix-multiply a [1, 2] with [3, 4], maybe that's why it doesn't work?"
Hmm. I'm not sure I follow. I thought I was multiplying two vec2's together and simply dumping the result back into the receiver. I can do this, and it works fine: result = temp + temp I get back result(4.0, 4.0). I'm clearly missing something obvious here. but Qt's auto complete gives virtually no help with this. |
Global Moderator
|
Did you try v.dot(w)?
You can only multiply a 2x1 matrix with a 1x2 one, or a 1x2 with a 2x1 one, or take their scalar product, but not multiply a 2x1 matrix with another 2x1 matrix. That's what the error is about, as far as I understand. Please recognize the difference between Qt and QtCreator, because it's super confusing if people say Qt instead of QtCreator
I'm working on the KDevelop IDE.
|
Registered Member
|
You cannot matrix-multiply a [1, 2] with [3, 4], maybe that's why it doesn't work?
hmm. I'm not sure I follow. I just thought I was multiplying two Vec2's together and getting back the result. I guess because I'm having issues in Qt with Eigen, I worried I had some kind of library issue here. I tried this same operation with two other math libraries and it worked as expected. I guess if this is a incorrect use of the function, I'll accept that. |
Global Moderator
|
There is no such thing as the multiplication of two 1-column matrices, that's just maths. There's the element-wise product, and the scalar product, but neither of them is just the matrix multiplication of the two matrices (which is undefined!). Use v.dot(w) if you want the scalar product (which is what I understand you want). That should be the same as v.transpose() * w.
I'm working on the KDevelop IDE.
|
Registered Member
|
I now realize that. I just thought I was throwing a couple of simple test cases at the library and wasn't thinking. It appears the library is working fine. I just was having a senior moment.
|
Global Moderator
|
|
Administrator
|
I've now moved this topic into the Eigen forum.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]