-
Notifications
You must be signed in to change notification settings - Fork 103
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
A simpler way to create a Vector2d from a Vector3d #336
Comments
We could do this, but given that JOML wants to stay allocation-free, we would have to make it like this: Vector2d b = a.xy(new Vector2d()); (of course this |
That would be a great improvement. Alternatively, maybe you could return it as a view on the data? (through Vector2dc) EDIT: never mind, a view also requires you to allocate something. Or just make it explicit in the function name that this function allocates something. |
Initially, I thought that you meant that every Vector3d should also be a Vector2dc. :) |
No, my idea was just bad :D |
But would adding these "swizzle" methods really justify bloating the classes/jar up? I mean, theoretically, people could then ask for all sorts of other 4d to 3d swizzles, etc, including vector4.xxx(vector3d), etc. |
No, I think all the swizzles don't add that much value. But truncating a 3d vector to a 2d vector is quite common in our codebase. Another suggestion: why not add it to Vector2d's constructor? Like this: public Vector2d(Vector3d v) {
x = v.x;
y = v.y;
} Also, on a separate note, could you add a double to float constructor to Vector2f (and 3f and 4f)? public Vector2f(Vector2dc v) {
x = (float) v.x();
y = (float) v.y();
} |
I'd like to have an easier way to get a lower dimension vector from a higher dimension vector. Usually from 3 dimensions to two, but from 4 to 3 too.
Currently, the only way to do this is the following:
I'd like to have something like in GLSL:
This mainly helps when the vector3d is obtained via a long function chain:
The text was updated successfully, but these errors were encountered: