# struct Vec4

A vector with 4 components: x, y, z, and w. Can be useful for things like shaders, where the registers are aligned to 4 float vectors.

This is a wrapper on System.Numerics.Vector4, so it’s SIMD optimized, and can be cast to and from implicitly.

## Instance Fields and Properties

Quat Quat A Vec4 and a Quat are only really different by name and purpose. So, if you need to do Quat math with your Vec4, or visa versa, who am I to judge?
Vector4 v The internal, wrapped System.Numerics type. This can be nice to have around so you can pass its fields as ‘ref’, which you can’t do with properties. You won’t often need this, as implicit conversions to System.Numerics types are also provided.
float w W component.
float x X component.
Vec2 XY This extracts a Vec2 from the X and Y axes.
Vec3 XYZ This extracts a Vec3 from the X, Y, and Z axes.
Vec2 XZ This extracts a Vec2 from the X and Z axes.
float y Y component.
Vec2 YZ This extracts a Vec2 from the Y and Z axes.
float z Z component.
Vec2 ZW This extracts a Vec2 from the Z and W axes.

## Instance Methods

Vec4 A basic constructor, just copies the values in!
ToString Mostly for debug purposes, this is a decent way to log or inspect the vector in debug mode. Looks like “[x, y, z, w]”

## Static Fields and Properties

Vec4 UnitW A normalized Vector that points down the W axis, this is the same as `new Vec4(0,1,0,0)`.
Vec4 UnitX A normalized Vector that points down the X axis, this is the same as `new Vec4(1,0,0,0)`.
Vec4 UnitY A normalized Vector that points down the Y axis, this is the same as `new Vec4(0,1,0,0)`.
Vec4 UnitZ A normalized Vector that points down the Z axis, this is the same as `new Vec4(0,1,0,0)`.

## Static Methods

Dot What’s a dot product do for 4D vectors, you might ask? Well, I’m no mathematician, so hopefully you are! I’ve never used it before. Whatever you’re doing with this function, it’s SIMD fast!
Lerp Blends (Linear Interpolation) between two vectors, based on a ‘blend’ value, where 0 is a, and 1 is b. Doesn’t clamp percent for you.
Max Returns a vector where each elements is the maximum value for each corresponding pair.
Min Returns a vector where each elements is the minimum value for each corresponding pair.

## Operators

+ Adds matching components together. Commutative.
/ A component-wise vector division. Not commutative
Implicit Conversions Allows implicit conversion from System.Numerics.Vector4 to StereoKit.Vec4.
* A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot product! Commutative.
- Subtracts matching components from eachother. Not commutative.
- Vector negation, returns a vector where each component has been negated.

Found an issue with these docs, or have some additional questions? Create an Issue on Github!