Comments (7)
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.
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.
@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.
@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.
@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.
@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.
@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)
- Cast between types HOT 4
- Memory packing difference C++ <-> HLSL HOT 16
- Integer vector division is working incorrectly on Macs with Apple M1 (ARM) HOT 7
- Integer vector comparison is working incorrectly on Intel based Macs with MacOS >= 11 HOT 3
- Improve HLSL++ unit tests by using full-featured testing framework HOT 2
- Matrix accessor operator HOT 6
- operator / (float1, float3) looks inverted HOT 8
- How well does this cover HLSL202x? HOT 11
- Quaternion slerp returning nan values HOT 2
- Clang error: unused variable 't4' in hlsl++_quaternion.h HOT 6
- Upgrade warnings to errors HOT 2
- round() on ARM Neon uses wrong rounding mode HOT 2
- mul() intrinsic is missing some overloads. HOT 2
- clamp() intrinsic is missing overloads for intN HOT 1
- Some non square matrix definitions are incorrect HOT 6
- Missing matrix constructors HOT 2
- Some vector double functions missing HOT 5
- Undefined behavior when accessing vector elements with operator[] HOT 10
- internal::round_float gives incorrect results HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hlslpp.