-
Notifications
You must be signed in to change notification settings - Fork 1
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
Should PVector Switch to Doubles? #111
Comments
Super, my initiatial proposition is not work on PVector double, just propose a class Vector version different, with |
To quote the other-nuts-and-bolts page:
I don't really get what Ben Fry means with this. For me personally it's that a lot of methods can't accept a PVector as an argument. Like But since the name of your OP, how often have people that they prefer double in practise. Also introducing a second vector will be a pain. Now half the libraries won't support that vector. And changing it to double is also bad. Cause now half the libraries are broken cause they are not compatible with the updated vector. I think if the vector has to be double then it should be done when processing is moving away from java to another language. Anyway, about the library of StanLepunk. Let's take Back on topic public int num;
public float x,y,z,w = Float.NaN;
public float e,f = Float.NaN; // for vec5 and vec6
public float s,t,p,q = Float.NaN;
public float u,v = Float.NaN; Then public PApplet pa;
private String VERSION = "0.8.5.30"; So every vector created has not only a reference to the PApplet, but also a version. Then when it comes to methods there are things like: public float max() {
float [] list = new float[num];
if(num == 2) {
list[0] = x;
list[1] = y;
} else if(num == 3) {
list[0] = x;
list[1] = y;
list[2] = z;
} else if(num == 4) {
list[0] = x;
list[1] = y;
list[2] = z;
list[3] = w;
} else if(num == 5) {
list[0] = x;
list[1] = y;
list[2] = z;
list[3] = w;
list[4] = e;
} else if(num == 6) {
list[0] = x;
list[1] = y;
list[2] = z;
list[3] = w;
list[4] = e;
list[5] = e;
}
return max(list);
} Which not only creates a new array everytime. It also has to set all the elements, and does a lot of branching which is not ideal for cpu's. Also when I look at other things I see: public vec3 set(float x, float y, float z) {
this.x = this.s = x;
this.y = this.t = y;
this.z = this.p = z;
return this;
} There is so much overhead. Apart from the Vector discussion. I thought the main reason of this fork was support for Java 11, OpenJDK, and OpenJFX. Which I believe work fine? For me personally I would really love to see this migrate in the main branch (of processing/processing) soon. |
Last year openFrameworks (a C++ framework in some ways similar to Processing) replaced it's own vector classes by the GLM library. This avoid reinventing the wheel, is a standard, and the syntax is similar to GLSL. I just checked and found GLM for JVM: https://github.com/kotlin-graphics/glm GLM provides the vector and matrix math required for 2D and 3D graphics, so in theory it might help simplify the Processing code base, and using the same syntax as in other platforms would make it easier to port code between them. At the same time it can be a huge effort. Still I wanted to throw the idea here. Also, the vector story in Processing is long :) It seems standards are not liked, so ToxicLibs, heMesh and maybe others implement their own. Then you always end up with glue code to convert vectors from one to another. But I've seen the same on C++ too. Too bad 2D and 3D vectors and matrices are not a core datatype. |
@clankill3r thanks for your strong feedback :) that's very nice for my personnal code improvement. For the second...this library is work in progress, I'm sure there is a lot of default must be, can be corrected, improved... At the first time of my library I don't use the class For the third, I'm very open to find a way to improve my library all help is very very very welcome @clankill3r @hamoid thx for the link https://github.com/kotlin-graphics/glm when I've a time I going to look it, that's can be a very very good way for my library and for Processing too :) thanks. PS : So for my english, it's like my code very very artistic ! |
I don't get the weirdly negative tone in these comments and the rest of the thread. Why am I referenced personally? I'm building this thing in my free time and this animosity is bizarre. It means that a lot of the design decisions, and the way that the methods work in
Passing a So… do we ~double the number of methods in
As with all design decisions we've made, it's always about providing a balance between 1) what's intuitive, 2) what people will use, and 3) what has good performance. There are always tradeoffs, but those are the criteria, and we do what we feel is best for the community.
Is it? A vector class was (originally) terrible for performance, but it's helpful as a container. So we eventually added a class for it. Others made their own, but weren't used universally, so it didn't make sense to use them as a replacement. Toxiclibs had a nice one, but it was designed for advanced users, not our core audience. No need to be melodramatic. But addressing the original question for this issue… Why would we switch to double? What's fixed? There are currently 524 open issues for the project. To my knowledge, it doesn't fix a single one of them. It also doubles the amount of memory required to hold the objects. Sure, If you want |
@benfry thanks for your light ! And again thank to you and @REAS to lead the awesome project. |
@StanLepunK To reduce the noise in this topic I gave some feedback on your library in your repository. knupel/Rope#4 I can provide some more later.
It was not meant negative. And it was referenced personally since you wrote that page. |
From @StanLepunK in processing#5753,
What are people's thoughts?
The text was updated successfully, but these errors were encountered: