-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiate between scalar and angle types. #5
Comments
Sorry for the delay, I didn't receive an e-mail notification. Could you provide a use case? Also, are you requesting this for the master branch (CML1), or CML2? Thanks! |
Sure, so as I mentioned, the function matrix_rotation_axis_angle is what I'm using in particular but I'm sure theres other rotation functions with the same problem. The issue appears to be that you are using the scalar type of the matrix as the angle's type as well. If the matrix uses an integer scalar type, this renders these functions essentially unusable.
Adding an extra template parameter would probably be sufficient.
|
A rotation matrix must have a determinant of 1 (or -1 if you include reflections), which limits the entries of an integral matrix to +/-1 and 0. Is this really what you are looking for? |
I'm aware, thats exactly what I'm using it for. However, this particular edge case only serves to hi-light a larger issue. Angles and scalars are not the same thing and should be in my opinion therefore served by separate types. |
As long as you know what you are getting into. :-) The CML2 version of matrix_rotation_axis_angle() allows for any integral or float angle type that has a std::numeric_limits<> specialization, and that can be converted to the matrix scalar type. This should allow for integral matrices and floating-point angles, but that use case has never come up, so I've not tested it. Here is the signature for good measure:
I haven't ported every CML1 function to CML2 yet, but if you'd like to give it a try and let me know which functions you need implemented, I can let you know if time would permit me to get them done. |
Apologies for the delay, this new function looks promising; I will test it when I can but as long as the two types are separate it should in theory solve the problem I was having. Thanks! |
No worries! I am going to close this issue, but please do open another if you have any more questions or problems. |
Just an update; I attempted to install cml2; however it required disabling an error in the cmake file stating that my compiler was not recognized. Following this, there was no option to make install, so I had to copy the folder directly. It then failed to compile due to various static_asserts when I included it. I take it clang/osx is not supported at this time. :) |
Doh! I don't have OS/X to test on, but I can see what happens with clang on Windows (and probably Linux). "make install" isn't done yet, as I use CML2 in my production code directly from a git clone. I'm willing to port over the "make install" step, but I can't guarantee it will work for OS/X. Let me know what clang version you are using, and I will give it a try. I will also open a new issue so we can track this new development... |
Sounds great, thanks! These were the errors I encountered when #including <cml/cml.h> if it helps any: I can run the tests for you as well if you want, whenever the makefile target for those exists or if theres another way to run them heh :) |
Thanks, the error messages were helpful, particularly because none were "showstoppers". In case you didn't get a message about it, I've created a new issue for updating CML2 to build with clang/XCode (#6). Let's continue there. |
@segmented I'm pinging you here, as I don't know if pinging you from #6 actually works. Let me know whenever you have a change if the latest changes have resolved those errors. |
Unfortunately, while it now accepts the int/float combo, matrix_rotation_axis_angle yields an incorrect matrix. I believe this to be due to the traits structure treating the angle parameter as an integer type in cos and sin. For example, if line 56 in traits.h was instead:
Then the correct matrix is produced for me. |
@segmented, please give the latest commit a try when you have a chance (demianmnave/CML@ce7ccec), and let me know how it works for you. |
Seems to work for me. Thanks! |
Awesome, thanks for your patience, and for spurring a pretty important update. Please let me know if you have any more questions or problems. |
Kamino cloned this issue to demianmnave/CML |
If the templates allowed for a separate angle type then various functions such as matrix_rotation_axis_angle would be much more useful for integer matrix types.
The text was updated successfully, but these errors were encountered: