Coder Social home page Coder Social logo

Comments (7)

redorav avatar redorav commented on May 27, 2024 1

Hi @Tormund, thanks for your message. In your example the line that goes wrong is

auto r = hlslpp::quaternion{0.0, 0.0, 0.0, 0.0} * hlslpp::quaternion{0.0, 0.0, 0.0, 0.0};

because there is no * operator that takes two quaternions. HLSL defines the * operator as component-wise multiplication which doesn't make a lot of sense for quaternions. The only multiplication operators that exist are accessible through the mul() function.

mul(quaternion, quaternion) multiplies two quaternions together

mul(quaternion, float3) rotates a vector using a quaternion

mul(float3, quaternion) rotates a vector using the inverse of the quaternion (effectively the opposite rotation)

Other than that there are no other multiplication operations. Does that clarify things a bit?

from hlslpp.

redorav avatar redorav commented on May 27, 2024 1

Hi @Tormund, I'm glad you found a solution. I'm not sure I understand what you mean when you say

It would be great if incorrect code would not compile (using operator * for quaternions)

The bug is about this code not compiling isn't it? I put the operator * in MSVC and it fails to compile. Can you post all the error messages you get?

from hlslpp.

Tormund avatar Tormund commented on May 27, 2024 1

@redorav, I ran several tests for each library. For vectors, I tested addition, normalization, dot product, cross product, and scalar multiplication. For quaternions, I tested multiplication, conjugation, and multiplication by a vector. For matrices, I tested multiplication and inversion. Each test was run in a loop with ten million iterations using randomly generated values that were passed to each test in the same order. All the information was gathered using an RAII object that calculated its lifetime and outputted the results in microseconds. At this point, I'm not entirely sure if I'm using all the libraries properly, but it seems that hlslpp performs similarly to cglm.

Here is result with Ofast flag:
Done - hlslpp_vectors in: 75216
Done - hlslpp_quaternions in: 69075
Done - hlslpp_matrixes in: 92163
Done - HLSLPP in: 239461

Done - cglm_vectors in: 72785
Done - cglm_quaternions in: 65330
Done - cglm_matrixes in: 89840
Done - CGLM in: 230156

And with O3:
Done - hlslpp_vectors in: 72621
Done - hlslpp_quaternions in: 68794
Done - hlslpp_matrixes in: 86990
Done - HLSLPP in: 231015

Done - cglm_vectors in: 91020
Done - cglm_quaternions in: 58385
Done - cglm_matrixes in: 99146
Done - CGLM in: 251470

from hlslpp.

redorav avatar redorav commented on May 27, 2024 1

@Tormund Thank you for that, most useful to have some ballpark numbers. If you end up using hlslpp and care about performance improvements in some area you suspect is slower than it should be (I'm seeing that quaternions are slower than in cglm) let me know and we can accommodate the changes that you need.

from hlslpp.

Tormund avatar Tormund commented on May 27, 2024

@redorav Thanks. After getting a compilation error, I understood my mistake. This is my first time using this library, and I didn't know that there is no * operator for quaternions. It would be great if incorrect code would not compile (using operator * for quaternions) . Anyway, thank you for the advice.

from hlslpp.

Tormund avatar Tormund commented on May 27, 2024

@redorav Sorry, everything is okay. It doesn't compile. It's my mistake. I was running many tests with another 4 math libraries and hlslpp in the same project, and I got confused. Thank you for your help! BTW hlslpp outperforms all of them, even cglm =)

from hlslpp.

redorav avatar redorav commented on May 27, 2024

@Tormund glad you are getting good value out of the library. Let me know if there are any other issues. When you say hlslpp outperforms other libraries, do you have any numbers and a specific test? I've been wanting to write performance tests for a while now but haven't really got to it

from hlslpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.