![]() |
SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
|
#include <math.h>#include <float.h>#include "shz_scalar.h"#include "shz_trig.h"#include "inline/shz_vector.inl.h"

Go to the source code of this file.
Data Structures | |
| struct | shz_vec2_t |
| struct | shz_vec3_t |
| struct | shz_vec4_t |
Macros | |
Adapters | |
Macros for converting between SH4ZAM and other compatible formats. | |
| #define | shz_vec2_deref(ptr) |
| #define | shz_vec3_deref(ptr) |
| #define | shz_vec4_deref(ptr) |
| #define | shz_vec2_from(value) |
| #define | shz_vec3_from(value) |
| #define | shz_vec4_from(value) |
| #define | shz_vec2_to(type, vector) |
| #define | shz_vec3_to(type, vector) |
| #define | shz_vec4_to(type, vector) |
Type-Generic Routines | |
Generalized vector routines for C and C++. | |
| #define | shz_vec_abs(vec) |
| #define | shz_vec_neg(vec) |
| #define | shz_vec_inv(vec) |
| #define | shz_vec_max(vec) |
| #define | shz_vec_min(vec) |
| #define | shz_vec_clamp(vec, min, max) |
| #define | shz_vec_equal(vec1, vec2) |
| #define | shz_vec_add(vec1, vec2) |
| #define | shz_vec_sub(vec1, vec2) |
| #define | shz_vec_mul(vec1, vec2) |
| #define | shz_vec_div(vec1, vec2) |
| #define | shz_vec_scale(vec, factor) |
| #define | shz_vec_dot(vec1, vec2) |
| #define | shz_vec_dot2(l, r1, r2) |
| #define | shz_vec_dot3(l, r1, r2, r3) |
| #define | shz_vec_magnitude_sqr(vec) |
| #define | shz_vec_magnitude(vec) |
| #define | shz_vec_magnitude_inv(vec) |
| #define | shz_vec_normalize(vec) |
| #define | shz_vec_normalize_safe(vec) |
| #define | shz_vec_distance(vec1, vec2) |
| #define | shz_vec_move(vec, target, maxdist) |
| #define | shz_vec_distance_sqr(vec1, vec2) |
| #define | shz_vec_lerp(vec1, vec2, t) |
| #define | shz_vec_reflect(incidence, normal) |
| #define | shz_vec_refract(incidence, normal, eta) |
| #define | shz_vec_cross(vec1, vec2) |
| #define | shz_vec_project(vec1, vec2) |
| #define | shz_vec_project_safe(vec1, vec2) |
| #define | shz_vec_angles(vec) |
| #define | shz_vec_angle_between(vec1, vec2) |
| #define | shz_vec_swizzle(vec, ...) |
| #define | shz_vec_floor(vec) |
| #define | shz_vec_ceil(vec) |
| #define | shz_vec_round(vec) |
| #define | shz_vec_fract(vec) |
| #define | shz_vec_sign(vec) |
| #define | shz_vec_saturate(vec) |
| #define | shz_vec_minv(a, b) |
| #define | shz_vec_maxv(a, b) |
| #define | shz_vec_stepv(vec, edge) |
| #define | shz_vec_step(vec, edge) |
| #define | shz_vec_smoothstepv(vec, edge0, edge1) |
| #define | shz_vec_smoothstep(vec, edge0, edge1) |
| #define | shz_vec_smoothstepv_safe(vec, edge0, edge1) |
| #define | shz_vec_smoothstep_safe(vec, edge0, edge1) |
Typedefs | |
| typedef shz_vec2_t | shz_vec2 |
| typedef shz_vec3_t | shz_vec3 |
| typedef shz_vec4_t | shz_vec4 |
Vector types and operations.
This file provides types and mathematical routines for representing and operating on vectors.
Definition in file shz_vector.h.
| #define shz_vec2_deref | ( | ptr | ) |
Dereferences the given pointer to a sequence of 2 floats as a shz_vec2_t.
Definition at line 658 of file shz_vector.h.
| #define shz_vec3_deref | ( | ptr | ) |
Dereferences the given pointer to a sequence of 3 floats as a shz_vec3_t.
Definition at line 661 of file shz_vector.h.
| #define shz_vec4_deref | ( | ptr | ) |
Dereferences the given pointer to a sequence of 4 floats as a shz_vec4_t.
Definition at line 664 of file shz_vector.h.
| #define shz_vec2_from | ( | value | ) |
Converts the given value or expression to the equivalent 2D SH4ZAM vector value.
Definition at line 667 of file shz_vector.h.
| #define shz_vec3_from | ( | value | ) |
Converts the given value or expression to the equivalent 3D SH4ZAM vector value.
Definition at line 670 of file shz_vector.h.
| #define shz_vec4_from | ( | value | ) |
Converts the given value or expression to the equivalent 4D SH4ZAM vector value.
Definition at line 673 of file shz_vector.h.
| #define shz_vec2_to | ( | type, | |
| vector ) |
Converts the given 2D vector into a value of the given type.
Definition at line 676 of file shz_vector.h.
| #define shz_vec3_to | ( | type, | |
| vector ) |
Converts the given 3D vector into a value of the given type.
Definition at line 679 of file shz_vector.h.
| #define shz_vec4_to | ( | type, | |
| vector ) |
Converts the given 4D vector into a value of the given type.
Definition at line 682 of file shz_vector.h.
| #define shz_vec_abs | ( | vec | ) |
C type-generic vector absolute value.
Definition at line 694 of file shz_vector.h.
| #define shz_vec_neg | ( | vec | ) |
C type-generic vector negation.
Definition at line 701 of file shz_vector.h.
| #define shz_vec_inv | ( | vec | ) |
C type-generic vector inversion.
Definition at line 708 of file shz_vector.h.
| #define shz_vec_max | ( | vec | ) |
C type-generic vector maximum value.
Definition at line 715 of file shz_vector.h.
| #define shz_vec_min | ( | vec | ) |
C type-generic vector minimum value.
Definition at line 722 of file shz_vector.h.
| #define shz_vec_clamp | ( | vec, | |
| min, | |||
| max ) |
C type-generic vector minimum value.
Definition at line 729 of file shz_vector.h.
| #define shz_vec_equal | ( | vec1, | |
| vec2 ) |
C type-generic vector equals.
Definition at line 736 of file shz_vector.h.
| #define shz_vec_add | ( | vec1, | |
| vec2 ) |
C type-generic vector addition.
Definition at line 743 of file shz_vector.h.
| #define shz_vec_sub | ( | vec1, | |
| vec2 ) |
C type-generic vector subtraction.
Definition at line 750 of file shz_vector.h.
| #define shz_vec_mul | ( | vec1, | |
| vec2 ) |
C type-generic vector multiplication.
Definition at line 757 of file shz_vector.h.
| #define shz_vec_div | ( | vec1, | |
| vec2 ) |
C type-generic vector division.
Definition at line 764 of file shz_vector.h.
| #define shz_vec_scale | ( | vec, | |
| factor ) |
C type-generic vector scaling.
Definition at line 771 of file shz_vector.h.
| #define shz_vec_dot | ( | vec1, | |
| vec2 ) |
C type-generic vector dot product.
Definition at line 778 of file shz_vector.h.
| #define shz_vec_dot2 | ( | l, | |
| r1, | |||
| r2 ) |
C type-generic vector chained double dot product.
Definition at line 785 of file shz_vector.h.
| #define shz_vec_dot3 | ( | l, | |
| r1, | |||
| r2, | |||
| r3 ) |
C type-generic vector chained triple dot product.
Definition at line 792 of file shz_vector.h.
| #define shz_vec_magnitude_sqr | ( | vec | ) |
C type-generic vector squared magnitude.
Definition at line 799 of file shz_vector.h.
| #define shz_vec_magnitude | ( | vec | ) |
C type-generic vector magnitude.
Definition at line 806 of file shz_vector.h.
| #define shz_vec_magnitude_inv | ( | vec | ) |
C type-generic vector inverse magnitude.
Definition at line 813 of file shz_vector.h.
| #define shz_vec_normalize | ( | vec | ) |
C type-generic vector normalization.
Definition at line 820 of file shz_vector.h.
| #define shz_vec_normalize_safe | ( | vec | ) |
C type-generic safe vector normalization.
Definition at line 827 of file shz_vector.h.
| #define shz_vec_distance | ( | vec1, | |
| vec2 ) |
C type-generic vector distance.
Definition at line 834 of file shz_vector.h.
| #define shz_vec_move | ( | vec, | |
| target, | |||
| maxdist ) |
C type-generic vector move.
Definition at line 841 of file shz_vector.h.
| #define shz_vec_distance_sqr | ( | vec1, | |
| vec2 ) |
C type-generic vector squared distance.
Definition at line 848 of file shz_vector.h.
| #define shz_vec_lerp | ( | vec1, | |
| vec2, | |||
| t ) |
C type-generic linear interpolation between two vectors.
Definition at line 855 of file shz_vector.h.
| #define shz_vec_reflect | ( | incidence, | |
| normal ) |
C type-generic vector reflection.
Definition at line 862 of file shz_vector.h.
| #define shz_vec_refract | ( | incidence, | |
| normal, | |||
| eta ) |
C type-generic vector refraction.
Definition at line 869 of file shz_vector.h.
| #define shz_vec_cross | ( | vec1, | |
| vec2 ) |
C type-generic vector cross-product.
Definition at line 876 of file shz_vector.h.
| #define shz_vec_project | ( | vec1, | |
| vec2 ) |
C type-generic vector projection.
Definition at line 882 of file shz_vector.h.
| #define shz_vec_project_safe | ( | vec1, | |
| vec2 ) |
C type-generic safe vector projection.
Definition at line 889 of file shz_vector.h.
| #define shz_vec_angles | ( | vec | ) |
C type-generic angle-from-vector extraction.
Definition at line 896 of file shz_vector.h.
| #define shz_vec_angle_between | ( | vec1, | |
| vec2 ) |
C type-generic angle between two vectors.
Definition at line 902 of file shz_vector.h.
| #define shz_vec_swizzle | ( | vec, | |
| ... ) |
C type-generic vector swizzling.
Definition at line 908 of file shz_vector.h.
| #define shz_vec_floor | ( | vec | ) |
C type-generic component-wise floor.
Definition at line 915 of file shz_vector.h.
| #define shz_vec_ceil | ( | vec | ) |
C type-generic component-wise ceil.
Definition at line 922 of file shz_vector.h.
| #define shz_vec_round | ( | vec | ) |
C type-generic component-wise round.
Definition at line 929 of file shz_vector.h.
| #define shz_vec_fract | ( | vec | ) |
C type-generic component-wise fract.
Definition at line 936 of file shz_vector.h.
| #define shz_vec_sign | ( | vec | ) |
C type-generic component-wise sign.
Definition at line 943 of file shz_vector.h.
| #define shz_vec_saturate | ( | vec | ) |
C type-generic component-wise saturate.
Definition at line 950 of file shz_vector.h.
| #define shz_vec_minv | ( | a, | |
| b ) |
C type-generic pairwise minimum.
Definition at line 957 of file shz_vector.h.
| #define shz_vec_maxv | ( | a, | |
| b ) |
C type-generic pairwise maximum.
Definition at line 964 of file shz_vector.h.
| #define shz_vec_stepv | ( | vec, | |
| edge ) |
C type-generic component-wise step.
Definition at line 971 of file shz_vector.h.
| #define shz_vec_step | ( | vec, | |
| edge ) |
C type-generic step.
Definition at line 978 of file shz_vector.h.
| #define shz_vec_smoothstepv | ( | vec, | |
| edge0, | |||
| edge1 ) |
C type-generic component-wise smoothstep.
Definition at line 985 of file shz_vector.h.
| #define shz_vec_smoothstep | ( | vec, | |
| edge0, | |||
| edge1 ) |
C type-generic smoothstep.
Definition at line 992 of file shz_vector.h.
| #define shz_vec_smoothstepv_safe | ( | vec, | |
| edge0, | |||
| edge1 ) |
C type-generic component-wise smoothstep_safe.
Definition at line 999 of file shz_vector.h.
| #define shz_vec_smoothstep_safe | ( | vec, | |
| edge0, | |||
| edge1 ) |
C type-generic smoothstep_safe.
Definition at line 1006 of file shz_vector.h.
| typedef shz_vec2_t shz_vec2 |
Alternate typedef for the shz_vec2 struct for those who hate POSIX-style.
Definition at line 49 of file shz_vector.h.
| typedef shz_vec3_t shz_vec3 |
Alternate typedef for the shz_vec3 struct for those who hate POSIX-style.
Definition at line 74 of file shz_vector.h.
| typedef shz_vec4_t shz_vec4 |
Alternate typedef for the shz_vec4 struct for those who hate POSIX-style.
Definition at line 105 of file shz_vector.h.
| shz_vec2_t shz_vec2_init | ( | float | x, |
| float | y ) |
Returns a 2D vector with the given x, and y coordinates.
| shz_vec3_t shz_vec3_init | ( | float | x, |
| float | y, | ||
| float | z ) |
Returns a 3D vector with the given x, y, and z coordinates.
| shz_vec4_t shz_vec4_init | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | w ) |
Returns a 4D vector with the given x, y, z, and w coordinates.
| shz_vec2_t shz_vec2_fill | ( | float | v | ) |
Returns a 2D vector with the value of each component equal to v.
| shz_vec3_t shz_vec3_fill | ( | float | v | ) |
Returns a 3D vector with the value of each compoonent equal to v.
| shz_vec4_t shz_vec4_fill | ( | float | v | ) |
Returns a 4D vector with the value of each component equal to v.
| shz_vec2_t shz_vec2_abs | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the absolute values of the given vector's components.
| shz_vec3_t shz_vec3_abs | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the absolute values of the given vector's components.
| shz_vec4_t shz_vec4_abs | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the absolute values of the given vector's components.
| shz_vec2_t shz_vec2_neg | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the negative values of the given vector's components.
| shz_vec3_t shz_vec3_neg | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the negative values of the given vector's components.
| shz_vec4_t shz_vec4_neg | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the negative values of the given vector's components.
| shz_vec2_t shz_vec2_inv | ( | shz_vec2_t | vec | ) |
Returns the 4D vector whose components have been inverted or reciprocated.
| shz_vec3_t shz_vec3_inv | ( | shz_vec3_t | vec | ) |
Returns the 4D vector whose components have been inverted or reciprocated.
| shz_vec4_t shz_vec4_inv | ( | shz_vec4_t | vec | ) |
Returns the 4D vector whose components have been inverted or reciprocated.
| float shz_vec2_max | ( | shz_vec2_t | vec | ) |
Returns the maximum value of both of the given vector's components.
| float shz_vec3_max | ( | shz_vec3_t | vec | ) |
Returns the maximum value of the given vector's 3 components.
| float shz_vec4_max | ( | shz_vec4_t | vec | ) |
Returns the maximum value of the given vector's 4 componetns.
| float shz_vec2_min | ( | shz_vec2_t | vec | ) |
Retuns the minimum value of both of the given vector's components.
| float shz_vec3_min | ( | shz_vec3_t | vec | ) |
Returns the minimum value of the given vector's 3 components.
| float shz_vec4_min | ( | shz_vec4_t | vec | ) |
Returns the minimum value of the given vector's 4 components.
| shz_vec2_t shz_vec2_clamp | ( | shz_vec2_t | vec, |
| float | min, | ||
| float | max ) |
Clamps the values of the given 2D vec between min and max, returning a new vector.
| shz_vec3_t shz_vec3_clamp | ( | shz_vec3_t | vec, |
| float | min, | ||
| float | max ) |
Clamps the values of the given 3D vec between min and max, returning a new vector.
| shz_vec4_t shz_vec4_clamp | ( | shz_vec4_t | vec, |
| float | min, | ||
| float | max ) |
Clamps the values of the given 4D vec between min and max, returning a new vector.
| shz_vec2_t shz_vec2_floor | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the floor of the given vector's components.
| shz_vec3_t shz_vec3_floor | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the floor of the given vector's components.
| shz_vec4_t shz_vec4_floor | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the floor of the given vector's components.
| shz_vec2_t shz_vec2_ceil | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the ceil of the given vector's components.
| shz_vec3_t shz_vec3_ceil | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the ceil of the given vector's components.
| shz_vec4_t shz_vec4_ceil | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the ceil of the given vector's components.
| shz_vec2_t shz_vec2_round | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the rounded values of the given vector's components.
| shz_vec3_t shz_vec3_round | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the rounded values of the given vector's components.
| shz_vec4_t shz_vec4_round | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the rounded values of the given vector's components.
| shz_vec2_t shz_vec2_fract | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the fractional parts of the given vector's components.
| shz_vec3_t shz_vec3_fract | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the fractional parts of the given vector's components.
| shz_vec4_t shz_vec4_fract | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the fractional parts of the given vector's components.
| shz_vec2_t shz_vec2_sign | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are the signs (-1, 0, or 1) of the given vector's components.
| shz_vec3_t shz_vec3_sign | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are the signs (-1, 0, or 1) of the given vector's components.
| shz_vec4_t shz_vec4_sign | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are the signs (-1, 0, or 1) of the given vector's components.
| shz_vec2_t shz_vec2_saturate | ( | shz_vec2_t | vec | ) |
Returns a 2D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components.
| shz_vec3_t shz_vec3_saturate | ( | shz_vec3_t | vec | ) |
Returns a 3D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components.
| shz_vec4_t shz_vec4_saturate | ( | shz_vec4_t | vec | ) |
Returns a 4D vector whose components are saturated (clamped to [0, 1]) values of the given vector's components.
| shz_vec2_t shz_vec2_minv | ( | shz_vec2_t | a, |
| shz_vec2_t | b ) |
Returns a 2D vector whose components are the pairwise minimums of the two given vectors' components.
| shz_vec3_t shz_vec3_minv | ( | shz_vec3_t | a, |
| shz_vec3_t | b ) |
Returns a 3D vector whose components are the pairwise minimums of the two given vectors' components.
| shz_vec4_t shz_vec4_minv | ( | shz_vec4_t | a, |
| shz_vec4_t | b ) |
Returns a 4D vector whose components are the pairwise minimums of the two given vectors' components.
| shz_vec2_t shz_vec2_maxv | ( | shz_vec2_t | a, |
| shz_vec2_t | b ) |
Returns a 2D vector whose components are the pairwise maximums of the two given vectors' components.
| shz_vec3_t shz_vec3_maxv | ( | shz_vec3_t | a, |
| shz_vec3_t | b ) |
Returns a 3D vector whose components are the pairwise maximums of the two given vectors' components.
| shz_vec4_t shz_vec4_maxv | ( | shz_vec4_t | a, |
| shz_vec4_t | b ) |
Returns a 4D vector whose components are the pairwise maximums of the two given vectors' components.
| bool shz_vec2_equal | ( | shz_vec2_t | a, |
| shz_vec2_t | b ) |
Returns true if the values of each element within the two 2D vectors are approximately equal based on relative or absolute tolerance.
| bool shz_vec3_equal | ( | shz_vec3_t | a, |
| shz_vec3_t | b ) |
Returns true if the values of each element within the two 3D vectors are approximately equal based on relative or absolute tolerance.
| bool shz_vec4_equal | ( | shz_vec4_t | a, |
| shz_vec4_t | b ) |
Returns true if the values of each element within the two 4D vectors are approximately equal based on relative or absolute tolerance.
| shz_vec2_t shz_vec2_stepv | ( | shz_vec2_t | vec, |
| shz_vec2_t | edge ) |
For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f.
| shz_vec3_t shz_vec3_stepv | ( | shz_vec3_t | vec, |
| shz_vec3_t | edge ) |
For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f.
| shz_vec4_t shz_vec4_stepv | ( | shz_vec4_t | vec, |
| shz_vec4_t | edge ) |
For each component: returns 0.0f if vec[i] < edge[i], otherwise 1.0f.
| shz_vec2_t shz_vec2_step | ( | shz_vec2_t | vec, |
| float | edge ) |
For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f.
| shz_vec3_t shz_vec3_step | ( | shz_vec3_t | vec, |
| float | edge ) |
For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f.
| shz_vec4_t shz_vec4_step | ( | shz_vec4_t | vec, |
| float | edge ) |
For each component: returns 0.0f if vec[i] < edge, otherwise 1.0f.
| shz_vec2_t shz_vec2_smoothstepv | ( | shz_vec2_t | vec, |
| shz_vec2_t | edge0, | ||
| shz_vec2_t | edge1 ) |
For each component: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between.
| shz_vec3_t shz_vec3_smoothstepv | ( | shz_vec3_t | vec, |
| shz_vec3_t | edge0, | ||
| shz_vec3_t | edge1 ) |
For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between.
| shz_vec4_t shz_vec4_smoothstepv | ( | shz_vec4_t | vec, |
| shz_vec4_t | edge0, | ||
| shz_vec4_t | edge1 ) |
For each component i: returns 0.0f at/below edge0[i], 1.0f at/above edge1[i], smoothly varying in-between.
| shz_vec2_t shz_vec2_smoothstep | ( | shz_vec2_t | vec, |
| float | edge0, | ||
| float | edge1 ) |
For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between.
| shz_vec3_t shz_vec3_smoothstep | ( | shz_vec3_t | vec, |
| float | edge0, | ||
| float | edge1 ) |
For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between.
| shz_vec4_t shz_vec4_smoothstep | ( | shz_vec4_t | vec, |
| float | edge0, | ||
| float | edge1 ) |
For each component: returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between.
| shz_vec2_t shz_vec2_add | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns a 2D vector whose components are the sums of the given vectors' components.
| shz_vec3_t shz_vec3_add | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns a 3D vector whose components are the sums of the given vectors' components.
| shz_vec4_t shz_vec4_add | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns a 4D vector whose components are the sums of the given vectors' components.
| shz_vec2_t shz_vec2_sub | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns a 2D vector whose components are equal to the values of vec1 minus vec2.
| shz_vec3_t shz_vec3_sub | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns a 3D vector whose components are equal to the values of vec1 minus vec2.
| shz_vec4_t shz_vec4_sub | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns a 4D vector whose components are equal to the values of vec1 minus vec2.
| shz_vec2_t shz_vec2_mul | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns a 2D vector whose component values are those of vec1 times vec2.
| shz_vec3_t shz_vec3_mul | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns a 3D vector whose component values are those of vec1 times vec2.
| shz_vec4_t shz_vec4_mul | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns a 4D vector whose component values are those of vec1 times vec2.
| shz_vec2_t shz_vec2_div | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns a 2D vector whose component values are those of vec1 divided by vec2.
| shz_vec3_t shz_vec3_div | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns a 3D vector whose component values are those of vec1 divided by vec2.
| shz_vec4_t shz_vec4_div | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns a 4D vector whose component values are those of vec1 divided by vec2.
| shz_vec2_t shz_vec2_scale | ( | shz_vec2_t | vec, |
| float | factor ) |
Returns a 2D vector whose component values are those of the given vector multiplied by a factor.
| shz_vec3_t shz_vec3_scale | ( | shz_vec3_t | vec, |
| float | factor ) |
Returns a 3D vector whose component values are those of the given vector multiplied by a factor.
| shz_vec4_t shz_vec4_scale | ( | shz_vec4_t | vec, |
| float | factor ) |
Returns a 4D vector whose component values are those of the given vector multiplied by a factor.
| float shz_vec2_magnitude_sqr | ( | shz_vec2_t | vec | ) |
Returns the squared magnitude of the given 2D vector.
| float shz_vec4_magnitude_sqr | ( | shz_vec4_t | vec | ) |
Returns the squared magnitude of the given 4D vector.
| float shz_vec3_magnitude_sqr | ( | shz_vec3_t | vec | ) |
Returns the squared magnitude of the given 3D vector.
| float shz_vec2_magnitude | ( | shz_vec2_t | vec | ) |
Returns the magnitude of the given 2D vector.
| float shz_vec3_magnitude | ( | shz_vec3_t | vec | ) |
Returns the magnitude of the given 3D vector.
| float shz_vec4_magnitude | ( | shz_vec4_t | vec | ) |
Returns the magnitude of the given 4D vector.
| float shz_vec2_magnitude_inv | ( | shz_vec2_t | vec | ) |
Returns the inverse magnitude of the given 2D vector.
| float shz_vec3_magnitude_inv | ( | shz_vec3_t | vec | ) |
Returns the inverse magnitude of the given 3D vector.
| float shz_vec4_magnitude_inv | ( | shz_vec4_t | vec | ) |
Returns the inverse magnitude of the given 4D vector.
| shz_vec2_t shz_vec2_normalize | ( | shz_vec2_t | vec | ) |
Returns a normalized unit vector from the given 2D vector.
| shz_vec3_t shz_vec3_normalize | ( | shz_vec3_t | vec | ) |
Returns a normalized unit vector from the given 3D vector.
| shz_vec4_t shz_vec4_normalize | ( | shz_vec4_t | vec | ) |
Returns a normalized unit vector from the given 4D vector.
| shz_vec2_t shz_vec2_normalize_safe | ( | shz_vec2_t | vec | ) |
SAFELY returns a normalized unit vector from the given 2D vector.
If the vector's magnitude is not > 0.0f, safely returns a zero vector.
| shz_vec3_t shz_vec3_normalize_safe | ( | shz_vec3_t | vec | ) |
SAFELY returns a normalized unit vector from the given 3D vector.
If the vector's magnitude is not > 0.0f, safely returns a zero vector.
| shz_vec4_t shz_vec4_normalize_safe | ( | shz_vec4_t | vec | ) |
SAFELY returns a normalized unit vector from the given 4D vector.
If the vector's magnitude is not > 0.0f, safely returns a zero vector.
| float shz_vec2_dot | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns the dot product between the two given 2D vectors.
| shz_vec2_t shz_vec2_dot2 | ( | shz_vec2_t | l, |
| shz_vec2_t | r1, | ||
| shz_vec2_t | r2 ) |
Returns the two dot products taken between the 2D vector l and 2D vectors r1 and r2.
| shz_vec3_t shz_vec2_dot3 | ( | shz_vec2_t | l, |
| shz_vec2_t | r1, | ||
| shz_vec2_t | r2, | ||
| shz_vec2_t | r3 ) |
Returns the three dot products taken between the 2D vector l and 2D vectors r1, r2, and r3.
| float shz_vec3_dot | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns the dot product between the two given 3D vectors.
| shz_vec2_t shz_vec3_dot2 | ( | shz_vec3_t | l, |
| shz_vec3_t | r1, | ||
| shz_vec3_t | r2 ) |
Returns the two dot products taken between the 3D vector l and 3D vectors r1 and r2.
| shz_vec3_t shz_vec3_dot3 | ( | shz_vec3_t | l, |
| shz_vec3_t | r1, | ||
| shz_vec3_t | r2, | ||
| shz_vec3_t | r3 ) |
Returns the three dot products taken between the 3D vector l and 3D vectors r1, r2, and r3.
| float shz_vec4_dot | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns the dot product between the two given 4D vectors.
| shz_vec2_t shz_vec4_dot2 | ( | shz_vec4_t | l, |
| shz_vec4_t | r1, | ||
| shz_vec4_t | r2 ) |
Returns the two dot products taken between the 4D vector l and 4D vectors r1 and r2.
| shz_vec3_t shz_vec4_dot3 | ( | shz_vec4_t | l, |
| shz_vec4_t | r1, | ||
| shz_vec4_t | r2, | ||
| shz_vec4_t | r3 ) |
Returns the three dot products taken between the 4D vector l and 4D vectors r1, r2, and r3.
| float shz_vec2_distance | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns the distance between the two given 2D vectors.
| float shz_vec3_distance | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns the distance between the two given 3D vectors.
| float shz_vec4_distance | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns the distance between the two given 4D vectors.
| float shz_vec2_distance_sqr | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns the squared-distance between the two given 2D vectors.
| float shz_vec3_distance_sqr | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns the squared-distance between the two given 3D vectors.
| float shz_vec4_distance_sqr | ( | shz_vec4_t | vec1, |
| shz_vec4_t | vec2 ) |
Returns the squared-distance between the two given 4D vectors.
| shz_vec2_t shz_vec2_move | ( | shz_vec2_t | vec, |
| shz_vec2_t | target, | ||
| float | max_distance ) |
Returns the given 2D vector, translated towards the target by the given max_distance.
| shz_vec3_t shz_vec3_move | ( | shz_vec3_t | vec, |
| shz_vec3_t | target, | ||
| float | max_distance ) |
Returns the given 3D vector, translated towards the target by the given max_distance.
| shz_vec4_t shz_vec4_move | ( | shz_vec4_t | vec, |
| shz_vec4_t | target, | ||
| float | max_distance ) |
Returns the given 4D vector, translated towards the target by the given max_distance.
| shz_vec2_t shz_vec2_lerp | ( | shz_vec2_t | a, |
| shz_vec2_t | b, | ||
| float | t ) |
Returns a 2D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t.
| shz_vec3_t shz_vec3_lerp | ( | shz_vec3_t | a, |
| shz_vec3_t | b, | ||
| float | t ) |
Returns a 3D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t.
| shz_vec4_t shz_vec4_lerp | ( | shz_vec4_t | a, |
| shz_vec4_t | b, | ||
| float | t ) |
Returns a 4D vector that is linearly interpolated from a to b by the given 0.0f-1.0f factor, t.
| shz_vec2_t shz_vec2_reflect | ( | shz_vec2_t | incidence, |
| shz_vec2_t | normal ) |
Reflects the given 2D incidence vector against a surface with the given normal, returning the result.
| shz_vec3_t shz_vec3_reflect | ( | shz_vec3_t | incidence, |
| shz_vec3_t | normal ) |
Reflects the given 3D incidence vector against a surface with the given normal, returning the result.
| shz_vec4_t shz_vec4_reflect | ( | shz_vec4_t | incidence, |
| shz_vec4_t | normal ) |
Reflects the given 4D incidence vector against a surface with the given normal, returning the result.
| shz_vec2_t shz_vec2_refract | ( | shz_vec2_t | incidence, |
| shz_vec2_t | normal, | ||
| float | eta ) |
Refracts the given 2D incidence vector against a surface with the given normal using the given refraction index ratio, eta.
| shz_vec3_t shz_vec3_refract | ( | shz_vec3_t | incidence, |
| shz_vec3_t | normal, | ||
| float | eta ) |
Refracts the given 3D incidence vector against a surface with the given normal using the given refraction index ratio, eta.
| shz_vec4_t shz_vec4_refract | ( | shz_vec4_t | incidence, |
| shz_vec4_t | normal, | ||
| float | eta ) |
Refracts the given 4D incidence vector against a surface with the given normal using the given refraction index ratio, eta.
| float shz_vec2_cross | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns the cross product, as a scalar, between two 2D vectors.
| shz_vec3_t shz_vec3_cross | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns the vector produced by taking the cross-product of the two given 3D vectors.
| shz_vec2_t shz_vec2_project | ( | shz_vec2_t | vec, |
| shz_vec2_t | onto ) |
Returns the resulting vector from projecting the given 2D vector along the given (unit) axis.
| shz_vec3_t shz_vec3_project | ( | shz_vec3_t | vec, |
| shz_vec3_t | onto ) |
Returns the resulting vector from projecting the given 3D vector along the given (unit) axis.
| shz_vec4_t shz_vec4_project | ( | shz_vec4_t | vec, |
| shz_vec4_t | onto ) |
Returns the resulting vector from projecting the given 4D vector along the given (unit) axis.
| shz_vec2_t shz_vec2_project_safe | ( | shz_vec2_t | vec, |
| shz_vec2_t | onto ) |
Returns the resulting vector from projecting the given 2D vector along the given (unit) axis.
vec has a magnitude of 0.0f. | shz_vec3_t shz_vec3_project_safe | ( | shz_vec3_t | vec, |
| shz_vec3_t | onto ) |
Returns the resulting vector from projecting the given 3D vector along the given (unit) axis.
vec has a magnitude of 0.0f. | shz_vec4_t shz_vec4_project_safe | ( | shz_vec4_t | vec, |
| shz_vec4_t | onto ) |
Returns the resulting vector from projecting the given 4D vector along the given (unit) axis.
vec has a magnitude of 0.0f. | shz_vec3_t shz_vec3_reject | ( | shz_vec3_t | vec, |
| shz_vec3_t | onto ) |
Returns the rejection of the given vector, vec, onto another vector, onto.
| float shz_vec3_triple | ( | shz_vec3_t | a, |
| shz_vec3_t | b, | ||
| shz_vec3_t | c ) |
Returns the 3D vector "triple product" between vector's a, b, and c.
| shz_vec3_t shz_vec3_perp | ( | shz_vec3_t | vec | ) |
Returns a vector which is perpendicular to the given vector.
| shz_vec3_t shz_vec3_barycenter | ( | shz_vec3_t | p, |
| shz_vec3_t | a, | ||
| shz_vec3_t | b, | ||
| shz_vec3_t | c ) |
Computes barycentric coordinates <u, v, w> for point p, within the plane of the triangle with vertices a, b, and c.
| void shz_vec3_orthonormalize | ( | shz_vec3_t | in1, |
| shz_vec3_t | in2, | ||
| shz_vec3_t * | out1, | ||
| shz_vec3_t * | out2 ) |
Returns 2 3D vectors which are normalized and orthogonal to the two input vectors.
| shz_vec3_t shz_vec3_cubic_hermite | ( | shz_vec3_t | vec, |
| shz_vec3_t | tangent1, | ||
| shz_vec3_t | vec2, | ||
| shz_vec3_t | tangent2, | ||
| float | amounht ) |
Calculates the cubic hermite interpolation between two vectors and their tangents.
| float shz_vec2_angle_between | ( | shz_vec2_t | vec1, |
| shz_vec2_t | vec2 ) |
Returns the angle formed between the given 2D vectors in radians.
| float shz_vec3_angle_between | ( | shz_vec3_t | vec1, |
| shz_vec3_t | vec2 ) |
Returns the angle formed between the given 3D vectors in radians.
| float shz_vec2_angle | ( | shz_vec2_t | vec | ) |
Returns the angle formed between the positive X axis and the given 2D vector, in radians.
| shz_vec3_t shz_vec3_angles | ( | shz_vec3_t | vec | ) |
Returns the angles formed between the positive X axis and the given 3D vector, in radians.
| shz_vec2_t shz_vec2_from_sincos | ( | shz_sincos_t | sincos | ) |
Returns the 2D unit vector representing a rotation from the positive X axis.
| shz_vec3_t shz_vec3_from_sincos | ( | shz_sincos_t | azimuth, |
| shz_sincos_t | elevation ) |
Returns the 3D unit vector representing the given rotation angles relative to the positive X axis.
| shz_vec2_t shz_vec2_from_angle | ( | float | radians | ) |
Returns the 2D unit vector representing a rotation from the positive X axis in radians.
| shz_vec3_t shz_vec3_from_angles | ( | float | azimuth, |
| float | elevation ) |
Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in radians.
| shz_vec2_t shz_vec2_from_angle_deg | ( | float | degrees | ) |
Returns the 2D unit vector representing a rotation from the positive X axis in degrees.
| shz_vec3_t shz_vec3_from_angles_deg | ( | float | azimuth, |
| float | elevation ) |
Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in degrees.
| shz_vec2_t shz_vec2_rotate | ( | shz_vec2_t | vec, |
| float | radians ) |
Rotates the given 2D vector about the Z axis by the given angle in radians.
| shz_vec3_t shz_vec2_vec3 | ( | shz_vec2_t | vec, |
| float | z ) |
Extends a 2D vector to 3D, using z as the value of the Z component.
| shz_vec4_t shz_vec2_vec4 | ( | shz_vec2_t | vec, |
| float | z, | ||
| float | w ) |
Extends a 2D vector to 4D, using z and w as the values of the Z and W components.
| shz_vec4_t shz_vec3_vec4 | ( | shz_vec3_t | vec, |
| float | w ) |
Extends a 3D vector to 4D, using w as the value of the W component.
| shz_vec2_t shz_vec2_swizzle | ( | shz_vec2_t | vec, |
| unsigned | x_idx, | ||
| unsigned | y_idx ) |
Returns a 2D vector whose elements are equal to the source vector's values at the given indices.
| shz_vec3_t shz_vec3_swizzle | ( | shz_vec3_t | vec, |
| unsigned | x_idx, | ||
| unsigned | y_idx, | ||
| unsigned | z_idx ) |
Returns a 3D vector whose elements are equal to the source vector's values at the given indices.
| shz_vec4_t shz_vec4_swizzle | ( | shz_vec4_t | vec, |
| unsigned | x_idx, | ||
| unsigned | y_idx, | ||
| unsigned | z_idx, | ||
| unsigned | w_idx ) |
Returns a new 2D vector whose elements are equal to the source vector's values at the given indices.