-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ofVec, double precision? #1847
Comments
+1 |
i don't think templating ofVec would cause slower execution. templates are evaluated at compile time, so it would be exactly the same as using custom code. i think it's also "the right way" to solve the problem. that said, templating the math classes is kind of a big job and could lead to a lot of new bugs. if someone wants to volunteer to tackle this, i'm guessing everyone else would be open to it -- but it'd be really important to write a few examples that show the behavior hasn't changed (and isn't different in the case of vec2f vs vec2d). |
I think templating the math classes would be a prime opportunity to start with some kind of automated testing for OF. We could ascertain that the results don't change with double precision in an automated way, and while examples are really practical for some tests, I'm not sure they're the best way to approach math tests. We even already got volunteers recently for this: in #1068, @diasbruno showed interest in starting a testing effort for OF. |
hi, i'm trying to get the openFrameworks' core running with automated tests. so, i'm using this # to figure out the best way to make it. hope this can help. https://github.com/diasbruno/ofCoreTest/tree/feature-ofVec-templates/src/template-ofVec (i'm still working on it) |
Just cross listing a related issue #1821 |
Definitely +1000 for templated ofVec and in fact all math functions. Cinder has been doing this from the start and it's ace. Not only for being able to have float vs double vectors, but int vectors are quite useful, and even being able to ofMap, ofLerp, ofClamp vectors etc. as well. It can get tricky if you start doing ofMap(f, 0, 1, 0, 100); // where f is a float, the rest are ints. |
i think any invisible change of internal mechanism (i.e. templating against function arguments) has the chance to cause a lot frustration for new users, and more advanced users would perhaps be happy with explicit template argument syntax: ofMap<int>(value, minIn, maxIn, minOut, maxOut); The template argument would default to float. btw, is there a reason we don't use default template arguments across oF, (e.g. |
Yea that solution didn't occur to me, it's a great idea. +1. Maybe one for |
That is a good idea. But I think default template parameters for functions are only allowed in C++11? With the old standard you can only add them to templated classes. Is C++11 widespread enough to use? |
for addons, i've started using C++11 in examples, but not within the addons themselves we eventually have to consider how to drop support for old compilers (as we have for Visual Studio 2010), and i presume at that time we'll start building up a table somewhere in the wiki that looks like (i didn't fill out the crosses correctly at all): 005 x x x Visual Studio 2012 x Makefile (linux) Makefile (osx) Makefile (windows) |
This seems to be covered by the recent move to GLM... Closing if that's cool. |
I'm working on a project where I need double precision.
I've had a look at ofVec2f, ofVec3f and ofVec4f, and I see they are independent classes. Obviously the easy route would be to make more custom classes (ofVec2d, ofVec3d and ofVec4d); but it feels kinda wrong.
Maybe it would make sense to template ofVec "à la" ofImage? (although that would be much more work, and most likely slower execution).
The text was updated successfully, but these errors were encountered: