vec2ο
Header: cglm/vec2.h
Table of contents (click to go):ο
Macros:
GLM_VEC2_ONE_INIT
GLM_VEC2_ZERO_INIT
GLM_VEC2_ONE
GLM_VEC2_ZERO
Functions:
Functions documentationο
-
void glm_vec2(float *v, vec2 dest)ο
init vec2 using vec3 or vec4
- Parameters:
- [in] v vector[out] dest destination
-
void glm_vec2_copy(vec2 a, vec2 dest)ο
copy all members of [a] to [dest]
- Parameters:
- [in] a source[out] dest destination
-
void glm_vec2_zero(vec2 v)ο
makes all members 0.0f (zero)
- Parameters:
- [in, out] v vector
-
void glm_vec2_one(vec2 v)ο
makes all members 1.0f (one)
- Parameters:
- [in, out] v vector
-
float glm_vec2_dot(vec2 a, vec2 b)ο
dot product of vec2
- Parameters:
- [in] a vector1[in] b vector2
- Returns:
dot product
-
void glm_vec2_cross(vec2 a, vec2 b, vec2 d)ο
cross product of two vector (RH)
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest destination
- Returns:
Z component of cross product
-
float glm_vec2_norm2(vec2 v)ο
norm * norm (magnitude) of vector
we can use this func instead of calling norm * norm, because it would call sqrtf function twice but with this func we can avoid func call, maybe this is not good name for this func
- Parameters:
- [in] v vector
- Returns:
square of norm / magnitude
-
float glm_vec2_norm(vec2 vec)ο
- euclidean norm (magnitude), also called L2 normthis will give magnitude of vector in euclidean space
- Parameters:
- [in] vec vector
-
void glm_vec2_add(vec2 a, vec2 b, vec2 dest)ο
add a vector to b vector store result in dest
- Parameters:
- [in] a vector1[in] b vector2[out] dest destination vector
-
void glm_vec2_adds(vec2 a, float s, vec2 dest)ο
add scalar to v vector store result in dest (d = v + vec(s))
- Parameters:
- [in] v vector[in] s scalar[out] dest destination vector
-
void glm_vec2_sub(vec2 v1, vec2 v2, vec2 dest)ο
subtract b vector from a vector store result in dest (d = v1 - v2)
- Parameters:
- [in] a vector1[in] b vector2[out] dest destination vector
-
void glm_vec2_subs(vec2 v, float s, vec2 dest)ο
subtract scalar from v vector store result in dest (d = v - vec(s))
- Parameters:
- [in] v vector[in] s scalar[out] dest destination vector
-
void glm_vec2_mul(vec2 a, vec2 b, vec2 d)ο
multiply two vector (component-wise multiplication)
- Parameters:
- [in] a vector[in] b scalar[out] d result = (a[0] * b[0], a[1] * b[1], a[2] * b[2])
-
void glm_vec2_scale(vec2 v, float s, vec2 dest)ο
multiply/scale vec2 vector with scalar: result = v * s
- Parameters:
- [in] v vector[in] s scalar[out] dest destination vector
-
void glm_vec2_scale_as(vec2 v, float s, vec2 dest)ο
make vec2 vector scale as specified: result = unit(v) * s
- Parameters:
- [in] v vector[in] s scalar[out] dest destination vector
-
void glm_vec2_div(vec2 a, vec2 b, vec2 dest)ο
div vector with another component-wise division: d = a / b
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest result = (a[0] / b[0], a[1] / b[1], a[2] / b[2])
-
void glm_vec2_divs(vec2 v, float s, vec2 dest)ο
div vector with scalar: d = v / s
- Parameters:
- [in] v vector[in] s scalar[out] dest result = (a[0] / s, a[1] / s, a[2] / s])
-
void glm_vec2_addadd(vec2 a, vec2 b, vec2 dest)ο
- add two vectors and add result to sumit applies += operator so dest must be initialized
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest dest += (a + b)
-
void glm_vec2_subadd(vec2 a, vec2 b, vec2 dest)ο
- sub two vectors and add result to sumit applies += operator so dest must be initialized
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest dest += (a - b)
-
void glm_vec2_muladd(vec2 a, vec2 b, vec2 dest)ο
- mul two vectors and add result to sumit applies += operator so dest must be initialized
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest dest += (a * b)
-
void glm_vec2_muladds(vec2 a, float s, vec2 dest)ο
- mul vector with scalar and add result to sumit applies += operator so dest must be initialized
- Parameters:
- [in] a vector[in] s scalar[out] dest dest += (a * b)
-
void glm_vec2_maxadd(vec2 a, vec2 b, vec2 dest)ο
- add max of two vector to result/destit applies += operator so dest must be initialized
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest dest += (a * b)
-
void glm_vec2_minadd(vec2 a, vec2 b, vec2 dest)ο
- add min of two vector to result/destit applies += operator so dest must be initialized
- Parameters:
- [in] a vector 1[in] b vector 2[out] dest dest += (a * b)
-
void glm_vec2_negate(vec2 v)ο
negate vector components
- Parameters:
- [in, out] v vector
-
void glm_vec2_negate_to(vec2 v, vec2 dest)ο
negate vector components and store result in dest
- Parameters:
- [in] v vector[out] dest negated vector
-
void glm_vec2_normalize(vec2 v)ο
normalize vec2 and store result in same vec
- Parameters:
- [in, out] v vector
-
void glm_vec2_normalize_to(vec2 vec, vec2 dest)ο
normalize vec2 to dest
- Parameters:
- [in] vec source[out] dest destination
-
void glm_vec2_rotate(vec2 v, float angle, vec2 dest)ο
rotate vec2 around axis by angle using Rodriguesβ rotation formula
- Parameters:
- [in] v vector[in] axis axis vector[out] dest destination
-
void glm_vec2_center(vec2 v1, vec2 v2, vec2 dest)ο
find center point of two vector
- Parameters:
- [in] v1 vector1[in] v2 vector2[out] dest center point
-
float glm_vec2_distance2(vec2 v1, vec2 v2)ο
squared distance between two vectors
- Parameters:
- [in] mat vector1[in] row1 vector2
- Returns:
- squared distance (distance * distance)
-
float glm_vec2_distance(vec2 v1, vec2 v2)ο
distance between two vectors
- Parameters:
- [in] mat vector1[in] row1 vector2
- Returns:
- distance
-
void glm_vec2_maxv(vec2 v1, vec2 v2, vec2 dest)ο
max values of vectors
- Parameters:
- [in] v1 vector1[in] v2 vector2[out] dest destination
-
void glm_vec2_minv(vec2 v1, vec2 v2, vec2 dest)ο
min values of vectors
- Parameters:
- [in] v1 vector1[in] v2 vector2[out] dest destination
-
void glm_vec2_clamp(vec2 v, float minVal, float maxVal)ο
constrain a value to lie between two further values
- Parameters:
- [in, out] v vector[in] minVal minimum value[in] maxVal maximum value
-
void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)ο
linear interpolation between two vector
formula: from + s * (to - from)- Parameters:
- [in] from from value[in] to to value[in] t interpolant (amount) clamped between 0 and 1[out] dest destination
-
void glm_vec2_make(const float *__restrict src, vec2 dest)ο
Create two dimensional vector from pointer
Note
@src must contain at least 2 elements.
- Parameters:
- [in] src pointer to an array of floats[out] dest destination vector
-
void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest)ο
Reflection vector using an incident ray and a surface normal
- Parameters:
- [in] I incident vector[in] N βοΈ normalized βοΈ normal vector[out] dest destination: reflection result
-
bool glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest)ο
Computes refraction vector for an incident vector and a surface normal.
Calculates the refraction vector based on Snellβs law. If total internal reflection occurs (angle too great given eta), dest is set to zero and returns false. Otherwise, computes refraction vector, stores it in dest, and returns true.
- Parameters:
- [in] I βοΈ normalized βοΈ incident vector[in] N βοΈ normalized βοΈ normal vector[in] eta ratio of indices of refraction (incident/transmitted)[out] dest refraction vector if refraction occurs; zero vector otherwise
- Returns:
returns true if refraction occurs; false if total internal reflection occurs.