Skip to content

rtm/vector4f.h

#include "rtm/vector4f.h"

vector_set

vector4f vector_set(float x, float y, float z, float w)

Creates a vector4 from all 4 components.

vector4f vector_set(float x, float y, float z)

Creates a vector4 from the [xyz] components and sets [w] to 0.0.

vector4f vector_set(float xyzw)

Creates a vector4 from a single value for all 4 components.

vector_zero

vector4f vector_zero()

Returns a vector consisting of all zeros.

The return value also converts to vector4d.

vector_coord_forward

vector4f vector_coord_forward()

Returns a unit vector pointing in the forward direction of the default coordinate system (Z+).

The return value also converts to vector4d.

vector_coord_up

vector4f vector_coord_up()

Returns a unit vector pointing in the up direction of the default coordinate system (Y+).

The return value also converts to vector4d.

vector_coord_cross

vector4f vector_coord_cross()

Returns a unit vector pointing in the cross direction of the default coordinate system (X+).

The return value also converts to vector4d.

vector_as_scalar

float vector_as_scalar(vector4f input)

Coerces an vector4 input into a scalar by grabbing the first SIMD lane.

The return value also converts to scalarf.

Setters, getters, and casts

vector_load

vector4f vector_load(const float* input)
vector4f vector_load(const float4f* input)

Loads an unaligned vector4 from memory.

vector4f vector_load(const uint8_t* input)

Loads an unaligned vector4 from memory.

The return value also converts to vector4d.

vector_load1

vector4f vector_load1(const float* input)

Loads an input scalar from memory into the [x] component and sets the [yzw] components to zero.

vector4f vector_load1(const uint8_t* input)

Loads an unaligned vector1 from memory and sets the [yzw] components to zero.

The return value also converts to vector4d.

vector_load2

vector4f vector_load2(const float* input)
vector4f vector_load2(const float2f* input)

Loads an unaligned vector2 from memory and sets the [zw] components to zero.

vector4f vector_load2(const uint8_t* input)

Loads an unaligned vector2 from memory and sets the [zw] components to zero.

The return value also converts to vector4d.

vector_load3

vector4f vector_load3(const float* input)
vector4f vector_load3(const float3f* input)

Loads an unaligned vector3 from memory and sets the [w] component to zero.

vector4f vector_load3(const uint8_t* input)

Loads an unaligned vector3 from memory and sets the [w] component to zero.

The return value also converts to vector4d.

vector_broadcast

vector4f vector_broadcast(const float* input)

Loads an input scalar from memory into the [xyzw] components.

quat_to_vector

vector4f quat_to_vector(quatf input)

Casts a quaternion to a vector4.

vector_cast

vector4f vector_cast(vector4d input)

Casts a vector4 float64 variant to a float32 variant.

vector_get_x

float vector_get_x(vector4f input)

Returns the vector4 [x] component.

vector_get_x_as_scalar

scalarf vector_get_x_as_scalar(vector4f input)

Returns the vector4 [x] component.

vector_get_y

float vector_get_y(vector4f input)

Returns the vector4 [y] component.

vector_get_y_as_scalar

scalarf vector_get_y_as_scalar(vector4f input)

Returns the vector4 [y] component.

vector_get_z

float vector_get_z(vector4f input)

Returns the vector4 [z] component.

vector_get_z_as_scalar

scalarf vector_get_z_as_scalar(vector4f input)

Returns the vector4 [z] component.

vector_get_w

float vector_get_w(vector4f input)

Returns the vector4 [w] component.

vector_get_w_as_scalar

scalarf vector_get_w_as_scalar(vector4f input)

Returns the vector4 [w] component.

vector_get_component2

template<component2 component, component4 component_ = static_cast<component4>(component)>
float vector_get_component2(vector4f input)

float vector_get_component2(vector4f input, component2 component)

Returns the vector2 desired component.

vector_get_component2_as_scalar

template<component2 component>
scalarf vector_get_component2_as_scalar(vector4f input)

scalarf vector_get_component2_as_scalar(vector4f input, component2 component)

Returns the vector2 desired component.

vector_get_component3

template<component3 component, component4 component_ = static_cast<component4>(component)>
float vector_get_component3(vector4f input)

float vector_get_component3(vector4f input, component3 component)

Returns the vector3 desired component.

vector_get_component3_as_scalar

template<component3 component>
scalarf vector_get_component3_as_scalar(vector4f input)

scalarf vector_get_component3_as_scalar(vector4f input, component3 component)

Returns the vector3 desired component.

vector_get_component

template<component4 component>
float vector_get_component(vector4f input)

float vector_get_component(vector4f input, component4 component)

Returns the vector4 desired component.

vector_get_component_as_scalar

template<component4 component>
scalarf vector_get_component_as_scalar(vector4f input)

scalarf vector_get_component_as_scalar(vector4f input, component4 component)

Returns the vector4 desired component.

vector_get_min_component

float vector_get_min_component(vector4f input)

Returns the smallest component in the input vector as a scalar.

vector_get_min_component_as_scalar

scalarf vector_get_min_component_as_scalar(vector4f input)

Returns the smallest component in the input vector as a scalar.

vector_get_max_component

float vector_get_max_component(vector4f input)

Returns the largest component in the input vector as a scalar.

vector_get_max_component_as_scalar

scalarf vector_get_max_component_as_scalar(vector4f input)

Returns the largest component in the input vector as a scalar.

vector_set_x

vector4f vector_set_x(vector4f input, float lane_value)

Sets the vector4 [x] component and returns the new value.

vector_set_y

vector4f vector_set_y(vector4f input, float lane_value)

Sets the vector4 [y] component and returns the new value.

vector_set_z

vector4f vector_set_z(vector4f input, float lane_value)

Sets the vector4 [z] component and returns the new value.

vector_set_w

vector4f vector_set_w(vector4f input, float lane_value)

Sets the vector4 [w] component and returns the new value.

vector_set_component2

template<component2 component>
vector4f vector_set_component2(vector4f input, float lane_value)

vector4f vector_set_component2(vector4f input, float lane_value, component2 component)

Sets the desired vector2 component and returns the new value.

vector_set_component3

template<component3 component>
vector4f vector_set_component3(vector4f input, float lane_value)

vector4f vector_set_component3(vector4f input, float lane_value, component3 component)

Sets the desired vector3 component and returns the new value.

vector_set_component

template<component4 component>
vector4f vector_set_component(vector4f input, float lane_value)

vector4f vector_set_component(vector4f input, float lane_value, component4 component)

Sets the desired vector4 component and returns the new value.

vector_to_pointer

const float * vector_to_pointer(const vector4f& input)

Returns a floating point pointer to the vector4 data.

vector_store

void vector_store(vector4f input, float* output)
void vector_store(vector4f input, uint8_t* output)
void vector_store(vector4f input, float4f* output)

Writes a vector4 to unaligned memory.

vector_store1

void vector_store1(vector4f input, float* output)
void vector_store1(vector4f input, uint8_t* output)

Writes a vector1 to unaligned memory.

vector_store2

void vector_store2(vector4f input, float* output)
void vector_store2(vector4f input, uint8_t* output)
void vector_store2(vector4f input, float2f* output)

Writes a vector2 to unaligned memory.

vector_store3

void vector_store3(vector4f input, float* output)
void vector_store3(vector4f input, uint8_t* output)
void vector_store3(vector4f input, float3f* output)

Writes a vector3 to unaligned memory.

Arithmetic

vector_add

vector4f vector_add(vector4f lhs, vector4f rhs)

Per component addition of the two inputs: lhs + rhs.

vector_sub

vector4f vector_sub(vector4f lhs, vector4f rhs)

Per component subtraction of the two inputs: lhs - rhs.

vector_mul

vector4f vector_mul(vector4f lhs, vector4f rhs)

Per component multiplication of the two inputs: lhs * rhs.

vector4f vector_mul(vector4f lhs, float rhs)

Per component multiplication of the vector by a scalar: lhs * rhs.

vector_div

vector4f vector_div(vector4f lhs, vector4f rhs)

Per component division of the two inputs: lhs / rhs.

vector_max

vector4f vector_max(vector4f lhs, vector4f rhs)

Per component maximum of the two inputs: max(lhs, rhs).

vector_min

vector4f vector_min(vector4f lhs, vector4f rhs)

Per component minimum of the two inputs: min(lhs, rhs).

vector_clamp

vector4f vector_clamp(vector4f input, vector4f min_value, vector4f max_value)

Per component clamping of an input between a minimum and a maximum value: min(max_value, max(min_value, input)).

vector_abs

vector4f vector_abs(vector4f input)

Per component absolute of the input: abs(input).

vector_neg

vector4f vector_neg(vector4f input)

Per component negation of the input: -input.

template<bool x, bool y, bool z, bool w>
vector4f vector_neg(vector4f input)

Per component negation of the input: -input Each template argument controls whether a SIMD lane should be negated (true) or not (false).

vector_reciprocal

vector4f vector_reciprocal(vector4f input)

Per component reciprocal of the input: 1.0 / input.

vector_sqrt

vector4f vector_sqrt(vector4f input)

Per component square root of the input: sqrt(input).

vector_sqrt_reciprocal

vector4f vector_sqrt_reciprocal(vector4f input)

Per component reciprocal square root of the input: 1.0 / sqrt(input).

vector_ceil

vector4f vector_ceil(vector4f input)

Per component returns the smallest integer value not less than the input (round towards positive infinity). vector_ceil([1.8, 1.0, -1.8, -1.0]) = [2.0, 1.0, -1.0, -1.0]

vector_floor

vector4f vector_floor(vector4f input)

Per component returns the largest integer value not greater than the input (round towards negative infinity). vector_floor([1.8, 1.0, -1.8, -1.0]) = [1.0, 1.0, -2.0, -1.0]

vector_cross3

vector4f vector_cross3(vector4f lhs, vector4f rhs)

3D cross product: lhs x rhs

vector_dot

float vector_dot(vector4f lhs, vector4f rhs)

4D dot product: lhs . rhs

vector_dot_as_scalar

scalarf vector_dot_as_scalar(vector4f lhs, vector4f rhs)

4D dot product: lhs . rhs

vector_dot_as_vector

vector4f vector_dot_as_vector(vector4f lhs, vector4f rhs)

4D dot product: lhs . rhs

vector_dot2

float vector_dot2(vector4f lhs, vector4f rhs)

2D dot product: lhs . rhs

vector_dot2_as_scalar

scalarf vector_dot2_as_scalar(vector4f lhs, vector4f rhs)

2D dot product: lhs . rhs

vector_dot2_as_vector

vector4f vector_dot2_as_vector(vector4f lhs, vector4f rhs)

2D dot product: lhs . rhs

vector_dot3

float vector_dot3(vector4f lhs, vector4f rhs)

3D dot product: lhs . rhs

vector_dot3_as_scalar

scalarf vector_dot3_as_scalar(vector4f lhs, vector4f rhs)

3D dot product: lhs . rhs

vector_dot3_as_vector

vector4f vector_dot3_as_vector(vector4f lhs, vector4f rhs)

3D dot product: lhs . rhs

vector_length_squared

float vector_length_squared(vector4f input)

Returns the squared length/norm of the vector4.

vector_length_squared_as_scalar

scalarf vector_length_squared_as_scalar(vector4f input)

Returns the squared length/norm of the vector4.

vector_length_squared_as_vector

vector4f vector_length_squared_as_vector(vector4f input)

Returns the squared length/norm of the vector4.

vector_length_squared2

float vector_length_squared2(vector4f input)

Returns the squared length/norm of the vector2.

vector_length_squared2_as_scalar

scalarf vector_length_squared2_as_scalar(vector4f input)

Returns the squared length/norm of the vector2.

vector_length_squared2_as_vector

vector4f vector_length_squared2_as_vector(vector4f input)

Returns the squared length/norm of the vector2.

vector_length_squared3

float vector_length_squared3(vector4f input)

Returns the squared length/norm of the vector3.

vector_length_squared3_as_scalar

scalarf vector_length_squared3_as_scalar(vector4f input)

Returns the squared length/norm of the vector3.

vector_length_squared3_as_vector

vector4f vector_length_squared3_as_vector(vector4f input)

Returns the squared length/norm of the vector3.

vector_length

float vector_length(vector4f input)

Returns the length/norm of the vector4.

vector_length_as_scalar

scalarf vector_length_as_scalar(vector4f input)

Returns the length/norm of the vector4.

vector_length3

float vector_length3(vector4f input)

Returns the length/norm of the vector3.

vector_length3_as_scalar

scalarf vector_length3_as_scalar(vector4f input)

Returns the length/norm of the vector3.

vector_length_reciprocal

float vector_length_reciprocal(vector4f input)

Returns the reciprocal length/norm of the vector4.

vector_length_reciprocal_as_scalar

scalarf vector_length_reciprocal_as_scalar(vector4f input)

Returns the reciprocal length/norm of the vector4.

vector_length_reciprocal2

float vector_length_reciprocal2(vector4f input)

Returns the reciprocal length/norm of the vector2.

vector_length_reciprocal2_as_scalar

scalarf vector_length_reciprocal2_as_scalar(vector4f input)

Returns the reciprocal length/norm of the vector2.

vector_length_reciprocal3

float vector_length_reciprocal3(vector4f input)

Returns the reciprocal length/norm of the vector3.

vector_length_reciprocal3_as_scalar

scalarf vector_length_reciprocal3_as_scalar(vector4f input)

Returns the reciprocal length/norm of the vector3.

vector_distance3

float vector_distance3(vector4f lhs, vector4f rhs)

Returns the distance between two 3D points.

vector_distance3_as_scalar

scalarf vector_distance3_as_scalar(vector4f lhs, vector4f rhs)

Returns the distance between two 3D points.

vector_distance_squared3

float vector_distance_squared3(vector4f lhs, vector4f rhs)

Returns the squared distance between two 3D points.

vector_distance_squared3_as_scalar

scalarf vector_distance_squared3_as_scalar(vector4f lhs, vector4f rhs)

Returns the squared distance between two 3D points.

vector_normalize2

vector4f vector_normalize2(vector4f input)

Returns a normalized vector2. If the length of the input is not finite or zero, the result is undefined. For a safe alternative, supply a fallback value and a threshold.

vector4f vector_normalize2(vector4f input, vector4f fallback, float threshold=1.0E-8F)

Returns a normalized vector2. If the length of the input is below the supplied threshold, the fall back value is returned instead.

vector_normalize3

vector4f vector_normalize3(vector4f input)

Returns a normalized vector3. If the length of the input is not finite or zero, the result is undefined. For a safe alternative, supply a fallback value and a threshold.

vector4f vector_normalize3(vector4f input, vector4f fallback, float threshold=1.0E-8F)

Returns a normalized vector3. If the length of the input is below the supplied threshold, the fall back value is returned instead.

vector_normalize

vector4f vector_normalize(vector4f input)

Returns a normalized vector4. If the length of the input is not finite or zero, the result is undefined. For a safe alternative, supply a fallback value and a threshold.

vector4f vector_normalize(vector4f input, vector4f fallback, float threshold=1.0E-8F)

Returns a normalized vector4. If the length of the input is below the supplied threshold, the fall back value is returned instead.

vector_fraction

vector4f vector_fraction(vector4f input)

Returns per component the fractional part of the input.

vector_mul_add

vector4f vector_mul_add(vector4f v0, vector4f v1, vector4f v2)

Per component multiplication/addition of the three inputs: v2 + (v0 * v1).

vector4f vector_mul_add(vector4f v0, float s1, vector4f v2)

Per component multiplication/addition of the three inputs: v2 + (v0 * s1).

vector_neg_mul_sub

vector4f vector_neg_mul_sub(vector4f v0, vector4f v1, vector4f v2)

Per component negative multiplication/subtraction of the three inputs: -((v0 * v1) - v2) This is mathematically equivalent to: v2 - (v0 * v1)

vector4f vector_neg_mul_sub(vector4f v0, float s1, vector4f v2)

Per component negative multiplication/subtraction of the three inputs: -((v0 * s1) - v2) This is mathematically equivalent to: v2 - (v0 * s1)

vector_lerp

vector4f vector_lerp(vector4f start, vector4f end, float alpha)
vector4f vector_lerp(vector4f start, vector4f end, vector4f alpha)

Per component linear interpolation of the two inputs at the specified alpha. The formula used is: ((1.0 - alpha) * start) + (alpha * end). Interpolation is stable and will return 'start' when alpha is 0.0 and 'end' when it is 1.0. This is the same instruction count when FMA is present but it might be slightly slower due to the extra multiplication compared to: start + (alpha * (end - start)).

Comparisons and masking

vector_equal

mask4f vector_equal(vector4f lhs, vector4f rhs)

Returns per component ~0 if equal, otherwise 0: lhs == rhs ? ~0 : 0.

vector_not_equal

mask4f vector_not_equal(vector4f lhs, vector4f rhs)

Returns per component ~0 if not equal, otherwise 0: lhs != rhs ? ~0 : 0.

vector_less_than

mask4f vector_less_than(vector4f lhs, vector4f rhs)

Returns per component ~0 if less than, otherwise 0: lhs < rhs ? ~0 : 0.

vector_less_equal

mask4f vector_less_equal(vector4f lhs, vector4f rhs)

Returns per component ~0 if less equal, otherwise 0: lhs <= rhs ? ~0 : 0.

vector_greater_than

mask4f vector_greater_than(vector4f lhs, vector4f rhs)

Returns per component ~0 if greater than, otherwise 0: lhs > rhs ? ~0 : 0.

vector_greater_equal

mask4f vector_greater_equal(vector4f lhs, vector4f rhs)

Returns per component ~0 if greater equal, otherwise 0: lhs >= rhs ? ~0 : 0.

vector_all_less_than

bool vector_all_less_than(vector4f lhs, vector4f rhs)

Returns true if all 4 components are less than, otherwise false: all(lhs.xyzw < rhs.xyzw).

vector_all_less_than2

bool vector_all_less_than2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are less than, otherwise false: all(lhs.xy < rhs.xy).

vector_all_less_than3

bool vector_all_less_than3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are less than, otherwise false: all(lhs.xyz < rhs.xyz).

vector_any_less_than

bool vector_any_less_than(vector4f lhs, vector4f rhs)

Returns true if any 4 components are less than, otherwise false: any(lhs.xyzw < rhs.xyzw).

vector_any_less_than2

bool vector_any_less_than2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are less than, otherwise false: any(lhs.xy < rhs.xy).

vector_any_less_than3

bool vector_any_less_than3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are less than, otherwise false: any(lhs.xyz < rhs.xyz).

vector_all_less_equal

bool vector_all_less_equal(vector4f lhs, vector4f rhs)

Returns true if all 4 components are less equal, otherwise false: all(lhs.xyzw <= rhs.xyzw).

vector_all_less_equal2

bool vector_all_less_equal2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are less equal, otherwise false: all(lhs.xy <= rhs.xy).

vector_all_less_equal3

bool vector_all_less_equal3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are less equal, otherwise false: all(lhs.xyz <= rhs.xyz).

vector_any_less_equal

bool vector_any_less_equal(vector4f lhs, vector4f rhs)

Returns true if any 4 components are less equal, otherwise false: any(lhs.xyzw <= rhs.xyzw).

vector_any_less_equal2

bool vector_any_less_equal2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are less equal, otherwise false: any(lhs.xy <= rhs.xy).

vector_any_less_equal3

bool vector_any_less_equal3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are less equal, otherwise false: any(lhs.xyz <= rhs.xyz).

vector_all_greater_than

bool vector_all_greater_than(vector4f lhs, vector4f rhs)

Returns true if all 4 components are greater than, otherwise false: all(lhs.xyzw > rhs.xyzw).

vector_all_greater_than2

bool vector_all_greater_than2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are greater than, otherwise false: all(lhs.xy > rhs.xy).

vector_all_greater_than3

bool vector_all_greater_than3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are greater than, otherwise false: all(lhs.xyz > rhs.xyz).

vector_any_greater_than

bool vector_any_greater_than(vector4f lhs, vector4f rhs)

Returns true if any 4 components are greater than, otherwise false: any(lhs.xyzw > rhs.xyzw).

vector_any_greater_than2

bool vector_any_greater_than2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are greater than, otherwise false: any(lhs.xy > rhs.xy).

vector_any_greater_than3

bool vector_any_greater_than3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are greater than, otherwise false: any(lhs.xyz > rhs.xyz).

vector_all_greater_equal

bool vector_all_greater_equal(vector4f lhs, vector4f rhs)

Returns true if all 4 components are greater equal, otherwise false: all(lhs.xyzw >= rhs.xyzw).

vector_all_greater_equal2

bool vector_all_greater_equal2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are greater equal, otherwise false: all(lhs.xy >= rhs.xy).

vector_all_greater_equal3

bool vector_all_greater_equal3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are greater equal, otherwise false: all(lhs.xyz >= rhs.xyz).

vector_any_greater_equal

bool vector_any_greater_equal(vector4f lhs, vector4f rhs)

Returns true if any 4 components are greater equal, otherwise false: any(lhs.xyzw >= rhs.xyzw).

vector_any_greater_equal2

bool vector_any_greater_equal2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are greater equal, otherwise false: any(lhs.xy >= rhs.xy).

vector_any_greater_equal3

bool vector_any_greater_equal3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are greater equal, otherwise false: any(lhs.xyz >= rhs.xyz).

vector_all_equal

bool vector_all_equal(vector4f lhs, vector4f rhs)

Returns true if all [xyzw] components are equal, otherwise false: all(lhs.xyzw == rhs.xyzw).

vector_all_equal2

bool vector_all_equal2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are equal, otherwise false: all(lhs.xy == rhs.xy).

vector_all_equal3

bool vector_all_equal3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are equal, otherwise false: all(lhs.xyz == rhs.xyz).

vector_any_equal

bool vector_any_equal(vector4f lhs, vector4f rhs)

Returns true if any [xyzw] components are equal, otherwise false: any(lhs.xyzw == rhs.xyzw).

vector_any_equal2

bool vector_any_equal2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are equal, otherwise false: any(lhs.xy == rhs.xy).

vector_any_equal3

bool vector_any_equal3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are equal, otherwise false: any(lhs.xyz == rhs.xyz).

vector_all_not_equal

bool vector_all_not_equal(vector4f lhs, vector4f rhs)

Returns true if all [xyzw] components are not equal, otherwise false: all(lhs.xyzw != rhs.xyzw).

vector_all_not_equal2

bool vector_all_not_equal2(vector4f lhs, vector4f rhs)

Returns true if all [xy] components are not equal, otherwise false: all(lhs.xy != rhs.xy).

vector_all_not_equal3

bool vector_all_not_equal3(vector4f lhs, vector4f rhs)

Returns true if all [xyz] components are not equal, otherwise false: all(lhs.xyz != rhs.xyz).

vector_any_not_equal

bool vector_any_not_equal(vector4f lhs, vector4f rhs)

Returns true if any [xyzw] components are not equal, otherwise false: any(lhs.xyzw != rhs.xyzw).

vector_any_not_equal2

bool vector_any_not_equal2(vector4f lhs, vector4f rhs)

Returns true if any [xy] components are not equal, otherwise false: any(lhs.xy != rhs.xy).

vector_any_not_equal3

bool vector_any_not_equal3(vector4f lhs, vector4f rhs)

Returns true if any [xyz] components are not equal, otherwise false: any(lhs.xyz != rhs.xyz).

vector_all_near_equal

bool vector_all_near_equal(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if all 4 components are near equal, otherwise false: all(abs(lhs - rhs).xyzw <= threshold).

vector_all_near_equal2

bool vector_all_near_equal2(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if all [xy] components are near equal, otherwise false: all(abs(lhs - rhs).xy <= threshold).

vector_all_near_equal3

bool vector_all_near_equal3(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if all [xyz] components are near equal, otherwise false: all(abs(lhs - rhs).xyz <= threshold).

vector_any_near_equal

bool vector_any_near_equal(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if any 4 components are near equal, otherwise false: any(abs(lhs - rhs).xyzw <= threshold).

vector_any_near_equal2

bool vector_any_near_equal2(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if any [xy] components are near equal, otherwise false: any(abs(lhs - rhs).xy <= threshold).

vector_any_near_equal3

bool vector_any_near_equal3(vector4f lhs, vector4f rhs, float threshold=0.00001F)

Returns true if any [xyz] components are near equal, otherwise false: any(abs(lhs - rhs).xyz <= threshold).

vector_finite

mask4f vector_finite(vector4f input)

Returns per component ~0 if input is finite, otherwise 0: finite(input) ? ~0 : 0.

vector_is_finite

bool vector_is_finite(vector4f input)

Returns true if all 4 components are finite (not NaN/Inf), otherwise false: all(finite(input)).

vector_is_finite2

bool vector_is_finite2(vector4f input)

Returns true if all [xy] components are finite (not NaN/Inf), otherwise false: all(finite(input)).

vector_is_finite3

bool vector_is_finite3(vector4f input)

Returns true if all [xyz] components are finite (not NaN/Inf), otherwise false: all(finite(input)).

Swizzling, permutations, and mixing

vector_select

vector4f vector_select(mask4f mask, vector4f if_true, vector4f if_false)

Per component selection depending on the mask: mask != 0 ? if_true : if_false.

vector_mix

template<mix4 comp0, mix4 comp1, mix4 comp2, mix4 comp3>
vector4f vector_mix(vector4f input0, vector4f input1)

Mixes two inputs and returns the desired components. [xyzw] indexes into the first input while [abcd] indexes in the second.

vector_dup_x

vector4f vector_dup_x(vector4f input)

Replicates the [x] component in all components.

vector_dup_y

vector4f vector_dup_y(vector4f input)

Replicates the [y] component in all components.

vector_dup_z

vector4f vector_dup_z(vector4f input)

Replicates the [z] component in all components.

vector_dup_w

vector4f vector_dup_w(vector4f input)

Replicates the [w] component in all components.

Logical

vector_and

vector4f vector_and(vector4f input0, vector4f input1)

Per component logical AND between the inputs: input0 & input1.

vector_or

vector4f vector_or(vector4f input0, vector4f input1)

Per component logical OR between the inputs: input0 | input1.

vector_xor

vector4f vector_xor(vector4f input0, vector4f input1)

Per component logical XOR between the inputs: input0 ^ input1.

Miscellaneous

vector_sign

vector4f vector_sign(vector4f input)

Returns per component the sign of the input vector: input >= 0.0 ? 1.0 : -1.0.

vector_copy_sign

vector4f vector_copy_sign(vector4f input, vector4f control_sign)

Returns per component the input with the sign of the control value.

vector_round_symmetric

vector4f vector_round_symmetric(vector4f input)

Returns per component the rounded input using a symmetric algorithm. vector_round_symmetric(1.5) = 2.0 vector_round_symmetric(1.2) = 1.0 vector_round_symmetric(-1.5) = -2.0 vector_round_symmetric(-1.2) = -1.0

vector_round_bankers

vector4f vector_round_bankers(vector4f input)

Returns per component the rounded input using banker's rounding (half to even). vector_round_bankers(2.5) = 2.0 vector_round_bankers(1.5) = 2.0 vector_round_bankers(1.2) = 1.0 vector_round_bankers(-2.5) = -2.0 vector_round_bankers(-1.5) = -2.0 vector_round_bankers(-1.2) = -1.0

vector_exp

vector4f vector_exp(vector4f input)

Returns per component the natural exponential of the input: e^input.

vector_log

vector4f vector_log(vector4f input)

Returns per component the natural logarithm of the input. The result is -inf when the input is zero, and NaN when the input is negative.

vector_eerp

vector4f vector_eerp(vector4f start, vector4f end, float alpha)
vector4f vector_eerp(vector4f start, vector4f end, vector4f alpha)

Per component exponential interpolation of the two inputs at the specified alpha. The formula used is: start * (end / start)^alpha. For equal steps of alpha, the result changes by the same ratio. Use it to interpolate a scale. The result is 'start' when alpha is 0.0. It is approximately 'end' when alpha is 1.0. The two inputs must have the same sign and must not be zero. Otherwise, the result is undefined.

vector_sin

vector4f vector_sin(vector4f input)

Returns per component the sine of the input angle.

vector_asin

vector4f vector_asin(vector4f input)

Returns per component the arc-sine of the input. Input value must be in the range [-1.0, 1.0].

vector_cos

vector4f vector_cos(vector4f input)

Returns per component the cosine of the input angle.

vector_acos

vector4f vector_acos(vector4f input)

Returns per component the arc-cosine of the input. Input value must be in the range [-1.0, 1.0].

vector_sincos

void vector_sincos(vector4f input, vector4f& out_sine, vector4f& out_cosine)

Returns per component the sine and cosine of the input angle.

vector_tan

vector4f vector_tan(vector4f angle)

Returns per component the tangent of the input angle.

vector_atan

vector4f vector_atan(vector4f input)

Returns per component the arc-tangent of the input. Note that due to the sign ambiguity, atan cannot determine which quadrant the value resides in.

vector_atan2

vector4f vector_atan2(vector4f y, vector4f x)

Returns per component the arc-tangent of [y/x] using the sign of the arguments to determine the correct quadrant. Y represents the proportion of the y-coordinate. X represents the proportion of the x-coordinate.