Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
Loading...
Searching...
No Matches
vector2.c File Reference
#include <vecmat.h>

Go to the source code of this file.

Functions

vector2 vec2_zero (void)
 Returns a vector2 with both components set to 0.0f.
vector2 vec2_one (void)
 Returns a vector2 with both components set to 1.0f.
vector2 vec2_x_axis (const vm_float_t x)
 Returns a vector2 along the x-axis (y = 0.0f).
vector2 vec2_y_axis (const vm_float_t y)
 Returns a vector2 along the y-axis (x = 0.0f).
vector2 vec2_x_scale (const vm_float_t x)
 Returns a vector2 representing x-axis scaling (y = 1.0f).
vector2 vec2_y_scale (const vm_float_t y)
 Returns a vector2 representing y-axis scaling (x = 1.0f).
vector2 vec2_scale (const vector2 v, const vm_float_t s)
 Scales a vector by a scalar component-wise.
vector2 vec2_add (const vector2 a, const vector2 b)
 Adds two vectors component-wise.
vector2 vec2_sub (const vector2 a, const vector2 b)
 Subtracts the second vector from the first component-wise.
vector2 vec2_mul_scalar (const vector2 v, const vm_float_t s)
 Multiplies a vector by a scalar component-wise.
vector2 vec2_div_scalar (const vector2 v, const vm_float_t s)
 Divides a vector by a scalar component-wise.
vector2 vec2_mul (const vector2 a, const vector2 b)
 Multiplies two vectors component-wise (Hadamard product).
vector2 vec2_neg (const vector2 v)
 Negates the vector (multiplies each component by -1.0f).
vector2 vec2_abs (const vector2 v)
 Returns the absolute values of each component.
vector2 vec2_cross (const vector2 a, const vector2 b)
 Computes the 2D cross-product as a vector.
vector2 vec2_normalize (const vector2 v)
 Normalizes the vector to unit length.
vector2 vec2_min (const vector2 a, const vector2 b)
 Returns the component-wise minimum of two vectors.
vector2 vec2_max (const vector2 a, const vector2 b)
 Returns the component-wise maximum of two vectors.
vector2 vec2_sign (const vector2 v)
 Returns the sign of each component (+1.0f, -1.0f, or 0.0f).
vector2 vec2_floor (const vector2 v)
 Applies floor to each component.
vector2 vec2_ceil (const vector2 v)
 Applies ceil to each component.
vector2 vec2_round (const vector2 v)
 Applies round to each component.
vector2 vec2_perpendicular (const vector2 v)
 Returns the perpendicular vector (90 degrees counterclockwise).
vector2 vec2_reflect (const vector2 v, const vector2 normal)
 Reflects vector v across the normal, storing the result in res.
vector2 vec2_project (const vector2 a, const vector2 b)
 Projects the first vector onto the second.
vector2 vec2_tangent (const vector2 v)
 Returns the tangent vector perpendicular to the input (90 degrees clockwise).
vector2 vec2_rotate (const vector2 v, const vm_float_t angle)
 Rotates the input vector counterclockwise by the given angle (radians).
vector2 vec2_slide (const vector2 v, const vector2 normal)
 Slides the input vector tangent to the normal (removes normal component).
vector2 vec2_clamp (const vector2 v, const vector2 min, const vector2 max)
 Clamps vector v component-wise between min and max.
vm_float_t vec2_dot (const vector2 a, const vector2 b)
 Computes the dot product of two vectors.
vm_float_t vec2_length (const vector2 v)
 Computes the length (magnitude) of the vector.
vm_float_t vec2_aspect_ratio (const vector2 v)
 Computes the aspect ratio of the vector (x / y).
vm_float_t vec2_distance (const vector2 a, const vector2 b)
 Computes the Euclidean distance between two vectors (treated as points).
vm_float_t vec2_angle (const vector2 a, const vector2 b)
 Computes the angle between two vectors (in radians, range [0, PI]).
vector2 vec2_lerp (const vector2 a, const vector2 b, const vm_float_t t)
 Linearly interpolates from a to b by t.
vector2 vec2_div (const vector2 a, const vector2 b)
 Divides two vectors component-wise.
vector2 vec2_add_scalar (const vector2 v, const vm_float_t s)
 Adds a scalar to each component.
vector2 vec2_sub_scalar (const vector2 v, const vm_float_t s)
 Subtracts a scalar from each component.
vector2 vec2_clamp_scalar (const vector2 v, const vm_float_t min, const vm_float_t max)
 Clamps each component to the scalar range [min, max].
vector2 vec2_saturate (const vector2 v)
 Clamps each component to the range [0, 1].
vector2 vec2_fract (const vector2 v)
 Returns the fractional part of each component.
vector2 vec2_refract (const vector2 incident, const vector2 normal, const vm_float_t eta)
 Computes the refraction of incident across normal with ratio eta.
vector2 vec2_reject (const vector2 a, const vector2 b)
 Returns the component of a orthogonal to b.
vector2 vec2_splat (const vm_float_t s)
 Returns a vector with every component set to s.
vector2 vec2_from_angle (const vm_float_t angle)
 Returns the unit vector at the given angle in radians.
vector2 vec2_rotate_around (const vector2 v, const vector2 pivot, const vm_float_t angle)
 Rotates v around pivot by angle radians.
vector2 vec2_move_toward (const vector2 current, const vector2 target, const vm_float_t max_delta)
 Moves current toward target by at most max_delta.
vector2 vec2_limit_length (const vector2 v, const vm_float_t max_len)
 Clamps the vector length to max_len.
vector3 vec2_to_vec3 (const vector2 v, const vm_float_t z)
 Converts a vector2 to a vector3 using z.
vm_float_t vec2_length_squared (const vector2 v)
 Returns the squared Euclidean length.
vm_float_t vec2_length_manhattan (const vector2 v)
 Returns the Manhattan (L1) length.
vm_float_t vec2_length_chebyshev (const vector2 v)
 Returns the Chebyshev (L-inf) length.
vm_float_t vec2_distance_squared (const vector2 a, const vector2 b)
 Returns the squared Euclidean distance between a and b.
vm_float_t vec2_cross_scalar (const vector2 a, const vector2 b)
 Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).
vm_float_t vec2_heading (const vector2 v)
 Returns the heading angle of the vector in radians.
vm_float_t vec2_min_component (const vector2 v)
 Returns the smallest component.
vm_float_t vec2_max_component (const vector2 v)
 Returns the largest component.
vm_float_t vec2_sum (const vector2 v)
 Returns the sum of all components.
bool vec2_is_zero (const vector2 v)
 Returns true if every component is zero.
bool vec2_is_normalized (const vector2 v)
 Returns true if the vector has unit length.
bool vec2_near (const vector2 a, const vector2 b, const vm_float_t eps)
 Returns true if a and b are within eps of each other.

Function Documentation

◆ vec2_abs()

vector2 vec2_abs ( const vector2 v)

Returns the absolute values of each component.

See vec2_abs_ptr instead.

Parameters
vThe input vector.
Returns
The absolute value vector2.

Definition at line 190 of file vector2.c.

References vec2_abs_ptr().

◆ vec2_add()

vector2 vec2_add ( const vector2 a,
const vector2 b )

Adds two vectors component-wise.

See vec2_add_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The sum vector2.

Definition at line 96 of file vector2.c.

References vec2_add_ptr().

◆ vec2_add_scalar()

vector2 vec2_add_scalar ( const vector2 v,
const vm_float_t s )

Adds a scalar to each component.

See vec2_add_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2.

Definition at line 543 of file vector2.c.

References vec2_add_scalar_ptr().

◆ vec2_angle()

vm_float_t vec2_angle ( const vector2 a,
const vector2 b )

Computes the angle between two vectors (in radians, range [0, PI]).

Returns 0.0f if either vector has zero length.

Parameters
aThe first vector.
bThe second vector.
Returns
The angle scalar.

Definition at line 492 of file vector2.c.

References vec2_dot(), vec2_length(), and VECMAT_ACOS.

◆ vec2_aspect_ratio()

vm_float_t vec2_aspect_ratio ( const vector2 v)

Computes the aspect ratio of the vector (x / y).

Returns 0.0f if y == 0.0f.

Parameters
vThe input vector.
Returns
The aspect ratio scalar.

Definition at line 463 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_ceil()

vector2 vec2_ceil ( const vector2 v)

Applies ceil to each component.

See vec2_ceil_ptr instead.

Parameters
vThe input vector.
Returns
The ceiled vector2.

Definition at line 298 of file vector2.c.

References vec2_ceil_ptr().

◆ vec2_clamp()

vector2 vec2_clamp ( const vector2 v,
const vector2 min,
const vector2 max )

Clamps vector v component-wise between min and max.

See vec2_clamp_ptr instead.

Parameters
vThe input vector.
minThe minimum bounds vector.
maxThe maximum bounds vector.
Returns
The clamped vector2.

Definition at line 425 of file vector2.c.

References vec2_clamp_ptr().

◆ vec2_clamp_scalar()

vector2 vec2_clamp_scalar ( const vector2 v,
const vm_float_t min,
const vm_float_t max )

Clamps each component to the scalar range [min, max].

See vec2_clamp_scalar_ptr instead.

Parameters
vInput vector.
minLower bound.
maxUpper bound.
Returns
The resulting vector2.

Definition at line 576 of file vector2.c.

References vec2_clamp_scalar_ptr().

◆ vec2_cross()

vector2 vec2_cross ( const vector2 a,
const vector2 b )

Computes the 2D cross-product as a vector.

See vec2_cross_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The cross-product vector2.

Definition at line 206 of file vector2.c.

References vec2_cross_ptr().

◆ vec2_cross_scalar()

vm_float_t vec2_cross_scalar ( const vector2 a,
const vector2 b )

Returns the 2D cross product as a scalar (a.x*b.y - a.y*b.x).

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 792 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_distance()

vm_float_t vec2_distance ( const vector2 a,
const vector2 b )

Computes the Euclidean distance between two vectors (treated as points).

Parameters
aThe first point.
bThe second point.
Returns
The distance scalar.

Definition at line 476 of file vector2.c.

References VECMAT_SQRT, vector2::x, and vector2::y.

◆ vec2_distance_squared()

vm_float_t vec2_distance_squared ( const vector2 a,
const vector2 b )

Returns the squared Euclidean distance between a and b.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting scalar.

Definition at line 778 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_div()

vector2 vec2_div ( const vector2 a,
const vector2 b )

Divides two vectors component-wise.

See vec2_div_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2.

Definition at line 527 of file vector2.c.

References vec2_div_ptr().

◆ vec2_div_scalar()

vector2 vec2_div_scalar ( const vector2 v,
const vm_float_t s )

Divides a vector by a scalar component-wise.

See vec2_div_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar divisor (non-zero).
Returns
The divided vector2.

Definition at line 144 of file vector2.c.

References vec2_div_scalar_ptr().

◆ vec2_dot()

vm_float_t vec2_dot ( const vector2 a,
const vector2 b )

Computes the dot product of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The dot product scalar.

Definition at line 439 of file vector2.c.

References vector2::x, and vector2::y.

Referenced by vec2_angle(), vec2_length(), vec2_length_squared(), vec2_project_ptr(), vec2_reflect_ptr(), vec2_refract_ptr(), and vec2_slide_ptr().

◆ vec2_floor()

vector2 vec2_floor ( const vector2 v)

Applies floor to each component.

See vec2_floor_ptr instead.

Parameters
vThe input vector.
Returns
The floored vector2.

Definition at line 283 of file vector2.c.

References vec2_floor_ptr().

◆ vec2_fract()

vector2 vec2_fract ( const vector2 v)

Returns the fractional part of each component.

See vec2_fract_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 606 of file vector2.c.

References vec2_fract_ptr().

◆ vec2_from_angle()

vector2 vec2_from_angle ( const vm_float_t angle)

Returns the unit vector at the given angle in radians.

See vec2_from_angle_ptr instead.

Parameters
angleAngle in radians.
Returns
The resulting vector2.

Definition at line 667 of file vector2.c.

References VECMAT_COS, and VECMAT_SIN.

◆ vec2_heading()

vm_float_t vec2_heading ( const vector2 v)

Returns the heading angle of the vector in radians.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 803 of file vector2.c.

References VECMAT_ATAN2, vector2::x, and vector2::y.

◆ vec2_is_normalized()

bool vec2_is_normalized ( const vector2 v)

Returns true if the vector has unit length.

Parameters
vInput vector.
Returns
True if the vector has unit length.

Definition at line 858 of file vector2.c.

References vec2_length_squared(), VECMAT_EPSILON, and VECMAT_FABS.

◆ vec2_is_zero()

bool vec2_is_zero ( const vector2 v)

Returns true if every component is zero.

Parameters
vInput vector.
Returns
True if every component is zero.

Definition at line 847 of file vector2.c.

References VECMAT_EPSILON, VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_length()

vm_float_t vec2_length ( const vector2 v)

Computes the length (magnitude) of the vector.

Parameters
vThe input vector.
Returns
The length scalar.

Definition at line 450 of file vector2.c.

References vec2_dot(), and VECMAT_SQRT.

Referenced by vec2_angle(), vec2_limit_length_ptr(), and vec2_normalize_ptr().

◆ vec2_length_chebyshev()

vm_float_t vec2_length_chebyshev ( const vector2 v)

Returns the Chebyshev (L-inf) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 766 of file vector2.c.

References VECMAT_FABS, VECMAT_FMAX, vector2::x, and vector2::y.

◆ vec2_length_manhattan()

vm_float_t vec2_length_manhattan ( const vector2 v)

Returns the Manhattan (L1) length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 755 of file vector2.c.

References VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_length_squared()

vm_float_t vec2_length_squared ( const vector2 v)

Returns the squared Euclidean length.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 744 of file vector2.c.

References vec2_dot().

Referenced by vec2_is_normalized().

◆ vec2_lerp()

vector2 vec2_lerp ( const vector2 a,
const vector2 b,
const vm_float_t t )

Linearly interpolates from a to b by t.

See vec2_lerp_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
tInterpolation factor.
Returns
The resulting vector2.

Definition at line 511 of file vector2.c.

References vec2_lerp_ptr().

◆ vec2_limit_length()

vector2 vec2_limit_length ( const vector2 v,
const vm_float_t max_len )

Clamps the vector length to max_len.

See vec2_limit_length_ptr instead.

Parameters
vInput vector.
max_lenMaximum length.
Returns
The resulting vector2.

Definition at line 715 of file vector2.c.

References vec2_limit_length_ptr().

◆ vec2_max()

vector2 vec2_max ( const vector2 a,
const vector2 b )

Returns the component-wise maximum of two vectors.

See vec2_max_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The maximum vector2.

Definition at line 253 of file vector2.c.

References vec2_max_ptr().

◆ vec2_max_component()

vm_float_t vec2_max_component ( const vector2 v)

Returns the largest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 825 of file vector2.c.

References VECMAT_FMAX, vector2::x, and vector2::y.

◆ vec2_min()

vector2 vec2_min ( const vector2 a,
const vector2 b )

Returns the component-wise minimum of two vectors.

See vec2_min_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The minimum vector2.

Definition at line 237 of file vector2.c.

References vec2_min_ptr().

◆ vec2_min_component()

vm_float_t vec2_min_component ( const vector2 v)

Returns the smallest component.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 814 of file vector2.c.

References VECMAT_FMIN, vector2::x, and vector2::y.

◆ vec2_move_toward()

vector2 vec2_move_toward ( const vector2 current,
const vector2 target,
const vm_float_t max_delta )

Moves current toward target by at most max_delta.

See vec2_move_toward_ptr instead.

Parameters
currentCurrent position.
targetTarget position.
max_deltaMaximum distance to move.
Returns
The resulting vector2.

Definition at line 699 of file vector2.c.

References vec2_move_toward_ptr().

◆ vec2_mul()

vector2 vec2_mul ( const vector2 a,
const vector2 b )

Multiplies two vectors component-wise (Hadamard product).

See vec2_mul_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The product vector2.

Definition at line 160 of file vector2.c.

References vec2_mul_ptr().

◆ vec2_mul_scalar()

vector2 vec2_mul_scalar ( const vector2 v,
const vm_float_t s )

Multiplies a vector by a scalar component-wise.

See vec2_mul_scalar_ptr instead.

Parameters
vThe input vector.
sThe scalar multiplier.
Returns
The scaled vector2.

Definition at line 128 of file vector2.c.

References vec2_mul_scalar_ptr().

◆ vec2_near()

bool vec2_near ( const vector2 a,
const vector2 b,
const vm_float_t eps )

Returns true if a and b are within eps of each other.

Parameters
aFirst input vector.
bSecond input vector.
epsDistance tolerance.
Returns
True if a and b are within eps.

Definition at line 871 of file vector2.c.

References VECMAT_FABS, vector2::x, and vector2::y.

◆ vec2_neg()

vector2 vec2_neg ( const vector2 v)

Negates the vector (multiplies each component by -1.0f).

See vec2_neg_ptr instead.

Parameters
vThe input vector.
Returns
The negated vector2.

Definition at line 175 of file vector2.c.

References vec2_neg_ptr().

◆ vec2_normalize()

vector2 vec2_normalize ( const vector2 v)

Normalizes the vector to unit length.

See vec2_normalize_ptr instead.

Parameters
vThe input vector.
Returns
The normalized vector2 (unchanged if zero length).

Definition at line 221 of file vector2.c.

References vec2_normalize_ptr().

◆ vec2_one()

vector2 vec2_one ( void )

Returns a vector2 with both components set to 1.0f.

Returns
The one vector2.

Definition at line 22 of file vector2.c.

◆ vec2_perpendicular()

vector2 vec2_perpendicular ( const vector2 v)

Returns the perpendicular vector (90 degrees counterclockwise).

See vec2_perpendicular_ptr instead.

Parameters
vThe input vector.
Returns
The perpendicular vector2.

Definition at line 329 of file vector2.c.

References vec2_perpendicular_ptr().

◆ vec2_project()

vector2 vec2_project ( const vector2 a,
const vector2 b )

Projects the first vector onto the second.

See vec2_project_ptr instead.

Parameters
aThe vector to project.
bThe projection direction vector.
Returns
The projected vector2.

Definition at line 361 of file vector2.c.

References vec2_project_ptr().

◆ vec2_reflect()

vector2 vec2_reflect ( const vector2 v,
const vector2 normal )

Reflects vector v across the normal, storing the result in res.

See vec2_reflect_ptr instead.

Parameters
vThe incident vector.
normalThe unit normal vector.
Returns
The reflected vector2.

Definition at line 345 of file vector2.c.

References vec2_reflect_ptr().

◆ vec2_refract()

vector2 vec2_refract ( const vector2 incident,
const vector2 normal,
const vm_float_t eta )

Computes the refraction of incident across normal with ratio eta.

See vec2_refract_ptr instead.

Parameters
incidentIncident vector.
normalSurface normal.
etaRatio of indices of refraction.
Returns
The resulting vector2.

Definition at line 623 of file vector2.c.

References vec2_refract_ptr().

◆ vec2_reject()

vector2 vec2_reject ( const vector2 a,
const vector2 b )

Returns the component of a orthogonal to b.

See vec2_reject_ptr instead.

Parameters
aFirst input vector.
bSecond input vector.
Returns
The resulting vector2.

Definition at line 639 of file vector2.c.

References vec2_reject_ptr().

◆ vec2_rotate()

vector2 vec2_rotate ( const vector2 v,
const vm_float_t angle )

Rotates the input vector counterclockwise by the given angle (radians).

See vec2_rotate_ptr instead.

Parameters
vThe input vector.
angleThe rotation angle in radians.
Returns
The rotated vector2.

Definition at line 392 of file vector2.c.

References vec2_rotate_ptr().

◆ vec2_rotate_around()

vector2 vec2_rotate_around ( const vector2 v,
const vector2 pivot,
const vm_float_t angle )

Rotates v around pivot by angle radians.

See vec2_rotate_around_ptr instead.

Parameters
vInput vector.
pivotRotation pivot.
angleAngle in radians.
Returns
The resulting vector2.

Definition at line 682 of file vector2.c.

References vec2_rotate_around_ptr().

◆ vec2_round()

vector2 vec2_round ( const vector2 v)

Applies round to each component.

See vec2_round_ptr instead.

Parameters
vThe input vector.
Returns
The rounded vector2.

Definition at line 313 of file vector2.c.

References vec2_round_ptr().

◆ vec2_saturate()

vector2 vec2_saturate ( const vector2 v)

Clamps each component to the range [0, 1].

See vec2_saturate_ptr instead.

Parameters
vInput vector.
Returns
The resulting vector2.

Definition at line 591 of file vector2.c.

References vec2_saturate_ptr().

◆ vec2_scale()

vector2 vec2_scale ( const vector2 v,
const vm_float_t s )

Scales a vector by a scalar component-wise.

See vec2_scale_ptr instead.

Parameters
vThe input vector.
sThe scalar multiplier.
Returns
The scaled vector2.

Definition at line 80 of file vector2.c.

References vec2_scale_ptr().

◆ vec2_sign()

vector2 vec2_sign ( const vector2 v)

Returns the sign of each component (+1.0f, -1.0f, or 0.0f).

See vec2_sign_ptr instead.

Parameters
vThe input vector.
Returns
The sign vector2.

Definition at line 268 of file vector2.c.

References vec2_sign_ptr().

◆ vec2_slide()

vector2 vec2_slide ( const vector2 v,
const vector2 normal )

Slides the input vector tangent to the normal (removes normal component).

See vec2_slide_ptr instead.

Parameters
vThe input vector.
normalThe unit normal vector.
Returns
The slid vector2.

Definition at line 408 of file vector2.c.

References vec2_slide_ptr().

◆ vec2_splat()

vector2 vec2_splat ( const vm_float_t s)

Returns a vector with every component set to s.

See vec2_splat_ptr instead.

Parameters
sScalar value.
Returns
The resulting vector2.

Definition at line 654 of file vector2.c.

◆ vec2_sub()

vector2 vec2_sub ( const vector2 a,
const vector2 b )

Subtracts the second vector from the first component-wise.

See vec2_sub_ptr instead.

Parameters
aThe first vector.
bThe second vector.
Returns
The difference vector2.

Definition at line 112 of file vector2.c.

References vec2_sub_ptr().

◆ vec2_sub_scalar()

vector2 vec2_sub_scalar ( const vector2 v,
const vm_float_t s )

Subtracts a scalar from each component.

See vec2_sub_scalar_ptr instead.

Parameters
vInput vector.
sScalar value.
Returns
The resulting vector2.

Definition at line 559 of file vector2.c.

References vec2_sub_scalar_ptr().

◆ vec2_sum()

vm_float_t vec2_sum ( const vector2 v)

Returns the sum of all components.

Parameters
vInput vector.
Returns
The resulting scalar.

Definition at line 836 of file vector2.c.

References vector2::x, and vector2::y.

◆ vec2_tangent()

vector2 vec2_tangent ( const vector2 v)

Returns the tangent vector perpendicular to the input (90 degrees clockwise).

See vec2_tangent_ptr instead.

Parameters
vThe input vector.
Returns
The tangent vector2.

Definition at line 376 of file vector2.c.

References vec2_tangent_ptr().

◆ vec2_to_vec3()

vector3 vec2_to_vec3 ( const vector2 v,
const vm_float_t z )

Converts a vector2 to a vector3 using z.

See vec2_to_vec3_ptr instead.

Parameters
vInput vector.
zZ component.
Returns
The resulting vector3.

Definition at line 731 of file vector2.c.

References vec2_to_vec3_ptr().

◆ vec2_x_axis()

vector2 vec2_x_axis ( const vm_float_t x)

Returns a vector2 along the x-axis (y = 0.0f).

Parameters
xThe x component value.
Returns
The x-axis vector2.

Definition at line 33 of file vector2.c.

◆ vec2_x_scale()

vector2 vec2_x_scale ( const vm_float_t x)

Returns a vector2 representing x-axis scaling (y = 1.0f).

Parameters
xThe x scale factor.
Returns
The x-scale vector2.

Definition at line 55 of file vector2.c.

◆ vec2_y_axis()

vector2 vec2_y_axis ( const vm_float_t y)

Returns a vector2 along the y-axis (x = 0.0f).

Parameters
yThe y component value.
Returns
The y-axis vector2.

Definition at line 44 of file vector2.c.

◆ vec2_y_scale()

vector2 vec2_y_scale ( const vm_float_t y)

Returns a vector2 representing y-axis scaling (x = 1.0f).

Parameters
yThe y scale factor.
Returns
The y-scale vector2.

Definition at line 66 of file vector2.c.

◆ vec2_zero()

vector2 vec2_zero ( void )

Returns a vector2 with both components set to 0.0f.

Returns
The zero vector2.

Definition at line 12 of file vector2.c.