Skip to content

rtm/vector4d.h

#include "rtm/vector4d.h"

vector_set

vector4d vector_set(double x, double y, double z, double w)

Creates a vector4 from all 4 components.

vector4d vector_set(double x, double y, double z)

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

vector4d vector_set(double xyzw)

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

vector_zero

vector4d vector_zero()

Returns a vector consisting of all zeros.

The return value also converts to vector4f.

vector_coord_forward

vector4d vector_coord_forward()

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

The return value also converts to vector4f.

vector_coord_up

vector4d vector_coord_up()

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

The return value also converts to vector4f.

vector_coord_cross

vector4d vector_coord_cross()

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

The return value also converts to vector4f.

vector_as_scalar

double vector_as_scalar(vector4d input)

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

The return value also converts to scalard.

Setters, getters, and casts

vector_load

vector4d vector_load(const double* input)
vector4d vector_load(const float4d* input)

Loads an unaligned vector4 from memory.

vector4d vector_load(const uint8_t* input)

Loads an unaligned vector4 from memory.

The return value also converts to vector4f.

vector_load1

vector4d vector_load1(const double* input)

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

vector4d 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 vector4f.

vector_load2

vector4d vector_load2(const double* input)
vector4d vector_load2(const float2d* input)

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

vector4d 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 vector4f.

vector_load3

vector4d vector_load3(const double* input)
vector4d vector_load3(const float3d* input)

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

vector4d 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 vector4f.

vector_broadcast

vector4d vector_broadcast(const double* input)

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

quat_to_vector

vector4d quat_to_vector(quatd input)

Casts a quaternion to a vector4.

vector_cast

vector4d vector_cast(vector4f input)

Casts a vector4 float32 variant to a float64 variant.

vector_get_x

double vector_get_x(vector4d input)

Returns the vector4 [x] component.

vector_get_x_as_scalar

scalard vector_get_x_as_scalar(vector4d input)

Returns the vector4 [x] component.

vector_get_y

double vector_get_y(vector4d input)

Returns the vector4 [y] component.

vector_get_y_as_scalar

scalard vector_get_y_as_scalar(vector4d input)

Returns the vector4 [y] component.

vector_get_z

double vector_get_z(vector4d input)

Returns the vector4 [z] component.

vector_get_z_as_scalar

scalard vector_get_z_as_scalar(vector4d input)

Returns the vector4 [z] component.

vector_get_w

double vector_get_w(vector4d input)

Returns the vector4 [w] component.

vector_get_w_as_scalar

scalard vector_get_w_as_scalar(vector4d input)

Returns the vector4 [w] component.

vector_get_component2

template<component2 component, component4 component_ = static_cast<component4>(component)>
double vector_get_component2(vector4d input)

double vector_get_component2(vector4d input, component2 component)

Returns the vector2 desired component.

vector_get_component2_as_scalar

template<component2 component>
scalard vector_get_component2_as_scalar(vector4d input)

scalard vector_get_component2_as_scalar(vector4d input, component2 component)

Returns the vector2 desired component.

vector_get_component3

template<component3 component, component4 component_ = static_cast<component4>(component)>
double vector_get_component3(vector4d input)

double vector_get_component3(vector4d input, component3 component)

Returns the vector3 desired component.

vector_get_component3_as_scalar

template<component3 component>
scalard vector_get_component3_as_scalar(vector4d input)

scalard vector_get_component3_as_scalar(vector4d input, component3 component)

Returns the vector3 desired component.

vector_get_component

template<component4 component>
double vector_get_component(vector4d input)

double vector_get_component(vector4d input, component4 component)

Returns the vector4 desired component.

vector_get_component_as_scalar

template<component4 component>
scalard vector_get_component_as_scalar(vector4d input)

scalard vector_get_component_as_scalar(vector4d input, component4 component)

Returns the vector4 desired component.

vector_get_min_component

double vector_get_min_component(vector4d input)

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

vector_get_min_component_as_scalar

scalard vector_get_min_component_as_scalar(vector4d input)

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

vector_get_max_component

double vector_get_max_component(vector4d input)

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

vector_get_max_component_as_scalar

scalard vector_get_max_component_as_scalar(vector4d input)

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

vector_set_x

vector4d vector_set_x(vector4d input, double lane_value)

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

vector_set_y

vector4d vector_set_y(vector4d input, double lane_value)

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

vector_set_z

vector4d vector_set_z(vector4d input, double lane_value)

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

vector_set_w

vector4d vector_set_w(vector4d input, double lane_value)

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

vector_set_component2

template<component2 component>
vector4d vector_set_component2(vector4d input, double lane_value)

vector4d vector_set_component2(vector4d input, double lane_value, component2 component)

Sets the desired vector2 component and returns the new value.

vector_set_component3

template<component3 component>
vector4d vector_set_component3(vector4d input, double lane_value)

vector4d vector_set_component3(vector4d input, double lane_value, component3 component)

Sets the desired vector3 component and returns the new value.

vector_set_component

template<component4 component>
vector4d vector_set_component(vector4d input, double lane_value)

vector4d vector_set_component(vector4d input, double lane_value, component4 component)

Sets the desired vector4 component and returns the new value.

vector_to_pointer

const double * vector_to_pointer(const vector4d& input)

Returns a floating point pointer to the vector4 data.

vector_store

void vector_store(vector4d input, double* output)
void vector_store(vector4d input, uint8_t* output)
void vector_store(vector4d input, float4d* output)

Writes a vector4 to unaligned memory.

vector_store1

void vector_store1(vector4d input, double* output)
void vector_store1(vector4d input, uint8_t* output)

Writes a vector1 to unaligned memory.

vector_store2

void vector_store2(vector4d input, double* output)
void vector_store2(vector4d input, uint8_t* output)
void vector_store2(vector4d input, float2d* output)

Writes a vector2 to unaligned memory.

vector_store3

void vector_store3(vector4d input, double* output)
void vector_store3(vector4d input, uint8_t* output)
void vector_store3(vector4d input, float3d* output)

Writes a vector3 to unaligned memory.

Arithmetic

vector_add

vector4d vector_add(vector4d lhs, vector4d rhs)

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

vector_sub

vector4d vector_sub(vector4d lhs, vector4d rhs)

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

vector_mul

vector4d vector_mul(vector4d lhs, vector4d rhs)

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

vector4d vector_mul(vector4d lhs, double rhs)

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

vector_div

vector4d vector_div(vector4d lhs, vector4d rhs)

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

vector_max

vector4d vector_max(vector4d lhs, vector4d rhs)

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

vector_min

vector4d vector_min(vector4d lhs, vector4d rhs)

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

vector_clamp

vector4d vector_clamp(vector4d input, vector4d min_value, vector4d max_value)

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

vector_abs

vector4d vector_abs(vector4d input)

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

vector_neg

vector4d vector_neg(vector4d input)

Per component negation of the input: -input.

template<bool x, bool y, bool z, bool w>
vector4d vector_neg(vector4d 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

vector4d vector_reciprocal(vector4d input)

Per component reciprocal of the input: 1.0 / input.

vector_sqrt

vector4d vector_sqrt(vector4d input)

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

vector_sqrt_reciprocal

vector4d vector_sqrt_reciprocal(vector4d input)

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

vector_ceil

vector4d vector_ceil(vector4d 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

vector4d vector_floor(vector4d 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

vector4d vector_cross3(vector4d lhs, vector4d rhs)

3D cross product: lhs x rhs

vector_dot

double vector_dot(vector4d lhs, vector4d rhs)

4D dot product: lhs . rhs

vector_dot_as_scalar

scalard vector_dot_as_scalar(vector4d lhs, vector4d rhs)

4D dot product: lhs . rhs

vector_dot_as_vector

vector4d vector_dot_as_vector(vector4d lhs, vector4d rhs)

4D dot product: lhs . rhs

vector_dot2

double vector_dot2(vector4d lhs, vector4d rhs)

2D dot product: lhs . rhs

vector_dot2_as_scalar

scalard vector_dot2_as_scalar(vector4d lhs, vector4d rhs)

2D dot product: lhs . rhs

vector_dot2_as_vector

vector4d vector_dot2_as_vector(vector4d lhs, vector4d rhs)

2D dot product: lhs . rhs

vector_dot3

double vector_dot3(vector4d lhs, vector4d rhs)

3D dot product: lhs . rhs

vector_dot3_as_scalar

scalard vector_dot3_as_scalar(vector4d lhs, vector4d rhs)

3D dot product: lhs . rhs

vector_dot3_as_vector

vector4d vector_dot3_as_vector(vector4d lhs, vector4d rhs)

3D dot product: lhs . rhs

vector_length_squared

double vector_length_squared(vector4d input)

Returns the squared length/norm of the vector4.

vector_length_squared_as_scalar

scalard vector_length_squared_as_scalar(vector4d input)

Returns the squared length/norm of the vector4.

vector_length_squared_as_vector

vector4d vector_length_squared_as_vector(vector4d input)

Returns the squared length/norm of the vector4.

vector_length_squared2

double vector_length_squared2(vector4d input)

Returns the squared length/norm of the vector2.

vector_length_squared2_as_scalar

scalard vector_length_squared2_as_scalar(vector4d input)

Returns the squared length/norm of the vector2.

vector_length_squared2_as_vector

vector4d vector_length_squared2_as_vector(vector4d input)

Returns the squared length/norm of the vector2.

vector_length_squared3

double vector_length_squared3(vector4d input)

Returns the squared length/norm of the vector3.

vector_length_squared3_as_scalar

scalard vector_length_squared3_as_scalar(vector4d input)

Returns the squared length/norm of the vector3.

vector_length_squared3_as_vector

vector4d vector_length_squared3_as_vector(vector4d input)

Returns the squared length/norm of the vector3.

vector_length

double vector_length(vector4d input)

Returns the length/norm of the vector4.

vector_length_as_scalar

scalard vector_length_as_scalar(vector4d input)

Returns the length/norm of the vector4.

vector_length3

double vector_length3(vector4d input)

Returns the length/norm of the vector3.

vector_length3_as_scalar

scalard vector_length3_as_scalar(vector4d input)

Returns the length/norm of the vector3.

vector_length_reciprocal

double vector_length_reciprocal(vector4d input)

Returns the reciprocal length/norm of the vector4.

vector_length_reciprocal_as_scalar

scalard vector_length_reciprocal_as_scalar(vector4d input)

Returns the reciprocal length/norm of the vector4.

vector_length_reciprocal2

double vector_length_reciprocal2(vector4d input)

Returns the reciprocal length/norm of the vector2.

vector_length_reciprocal2_as_scalar

scalard vector_length_reciprocal2_as_scalar(vector4d input)

Returns the reciprocal length/norm of the vector2.

vector_length_reciprocal3

double vector_length_reciprocal3(vector4d input)

Returns the reciprocal length/norm of the vector3.

vector_length_reciprocal3_as_scalar

scalard vector_length_reciprocal3_as_scalar(vector4d input)

Returns the reciprocal length/norm of the vector3.

vector_distance3

double vector_distance3(vector4d lhs, vector4d rhs)

Returns the distance between two 3D points.

vector_distance3_as_scalar

scalard vector_distance3_as_scalar(vector4d lhs, vector4d rhs)

Returns the distance between two 3D points.

vector_distance_squared3

double vector_distance_squared3(vector4d lhs, vector4d rhs)

Returns the squared distance between two 3D points.

vector_distance_squared3_as_scalar

scalard vector_distance_squared3_as_scalar(vector4d lhs, vector4d rhs)

Returns the squared distance between two 3D points.

vector_normalize2

vector4d vector_normalize2(vector4d 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.

vector4d vector_normalize2(vector4d input, vector4d fallback, double threshold=1.0E-8)

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

vector_normalize3

vector4d vector_normalize3(vector4d 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.

vector4d vector_normalize3(vector4d input, vector4d fallback, double threshold=1.0E-8)

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

vector_normalize

vector4d vector_normalize(vector4d 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.

vector4d vector_normalize(vector4d input, vector4d fallback, double threshold=1.0E-8)

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

vector_fraction

vector4d vector_fraction(vector4d input)

Returns per component the fractional part of the input.

vector_mul_add

vector4d vector_mul_add(vector4d v0, vector4d v1, vector4d v2)

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

vector4d vector_mul_add(vector4d v0, double s1, vector4d v2)

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

vector_neg_mul_sub

vector4d vector_neg_mul_sub(vector4d v0, vector4d v1, vector4d v2)

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

vector4d vector_neg_mul_sub(vector4d v0, double s1, vector4d v2)

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

vector_lerp

vector4d vector_lerp(vector4d start, vector4d end, double alpha)
vector4d vector_lerp(vector4d start, vector4d end, vector4d 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

mask4d vector_equal(vector4d lhs, vector4d rhs)

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

vector_not_equal

mask4d vector_not_equal(vector4d lhs, vector4d rhs)

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

vector_less_than

mask4d vector_less_than(vector4d lhs, vector4d rhs)

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

vector_less_equal

mask4d vector_less_equal(vector4d lhs, vector4d rhs)

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

vector_greater_than

mask4d vector_greater_than(vector4d lhs, vector4d rhs)

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

vector_greater_equal

mask4d vector_greater_equal(vector4d lhs, vector4d rhs)

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

vector_all_less_than

bool vector_all_less_than(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d rhs)

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

vector_all_equal

bool vector_all_equal(vector4d lhs, vector4d rhs)

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

vector_all_equal2

bool vector_all_equal2(vector4d lhs, vector4d rhs)

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

vector_all_equal3

bool vector_all_equal3(vector4d lhs, vector4d rhs)

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

vector_any_equal

bool vector_any_equal(vector4d lhs, vector4d rhs)

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

vector_any_equal2

bool vector_any_equal2(vector4d lhs, vector4d rhs)

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

vector_any_equal3

bool vector_any_equal3(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d 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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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(vector4d lhs, vector4d rhs, double threshold=0.00001)

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

vector_finite

mask4d vector_finite(vector4d input)

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

vector_is_finite

bool vector_is_finite(vector4d input)

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

vector_is_finite2

bool vector_is_finite2(vector4d input)

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

vector_is_finite3

bool vector_is_finite3(vector4d input)

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

Swizzling, permutations, and mixing

vector_select

vector4d vector_select(mask4d mask, vector4d if_true, vector4d 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>
vector4d vector_mix(vector4d input0, vector4d input1)

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

vector_dup_x

vector4d vector_dup_x(vector4d input)

Replicates the [x] component in all components.

vector_dup_y

vector4d vector_dup_y(vector4d input)

Replicates the [y] component in all components.

vector_dup_z

vector4d vector_dup_z(vector4d input)

Replicates the [z] component in all components.

vector_dup_w

vector4d vector_dup_w(vector4d input)

Replicates the [w] component in all components.

Logical

vector_and

vector4d vector_and(vector4d input0, vector4d input1)

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

vector_or

vector4d vector_or(vector4d input0, vector4d input1)

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

vector_xor

vector4d vector_xor(vector4d input0, vector4d input1)

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

Miscellaneous

vector_sign

vector4d vector_sign(vector4d input)

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

vector_copy_sign

vector4d vector_copy_sign(vector4d input, vector4d control_sign)

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

vector_round_symmetric

vector4d vector_round_symmetric(vector4d 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

vector4d vector_round_bankers(vector4d 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

vector4d vector_exp(vector4d input)

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

vector_log

vector4d vector_log(vector4d 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

vector4d vector_eerp(vector4d start, vector4d end, double alpha)
vector4d vector_eerp(vector4d start, vector4d end, vector4d 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

vector4d vector_sin(vector4d input)

Returns per component the sine of the input angle.

vector_asin

vector4d vector_asin(vector4d input)

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

vector_cos

vector4d vector_cos(vector4d input)

Returns per component the cosine of the input angle.

vector_acos

vector4d vector_acos(vector4d 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(vector4d input, vector4d& out_sine, vector4d& out_cosine)

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

vector_tan

vector4d vector_tan(vector4d angle)

Returns per component the tangent of the input angle.

vector_atan

vector4d vector_atan(vector4d 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

vector4d vector_atan2(vector4d y, vector4d 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.