More swizzling types?

Just getting started with nalgebra and porting over some code to see how it works…

Looks amazing and a great way to learn about linear algebra too, even just by looking up what some of the structs and functions are :slight_smile:

As a starting point, I tried replacing my Color struct (which has rgba components) with Vector4 and it seems I can’t access the components like that.

Was wondering if it’s possible to add the additional swizzle types… maybe to be compatible with GLSL in general?

Here’s a reference:

You can use xyzw , rgba (for colors), or stpq (for texture coordinates)

Hi! The components of a Vector4 are x, y, z, w (so you can do vec4.x = 10.0 for example) and you can use swizzling for any combination of x, y, and z (for example vec4.xyy()). It is not possible to include w in the swizzle because that would imply adding a lot of methods to nalgebra which would increase significantly the size of the generated .rlib. Though we could add those behind a feature though if you need it.

There is no rgba or stpq components in nalgebra because we want to remain focused on linear algebra. Components related to colors or textures are out of scope.

1 Like