Vector2#
-
struct nvVector2#
2D vector type.
Macros#
-
static inline nvVector2 *NV_VEC2_NEW(nv_float x, nv_float y)#
Initialize and store vector on HEAP.
- Parameters:
x – X component
y – Y component
- Returns:
Methods#
-
static inline bool nvVector2_eq(nvVector2 a, nvVector2 b)#
Check if two vectors are equal.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
bool
-
static inline nvVector2 nvVector2_add(nvVector2 a, nvVector2 b)#
Add two vectors.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
-
static inline nvVector2 nvVector2_sub(nvVector2 a, nvVector2 b)#
Subtract two vectors.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
-
static inline nvVector2 nvVector2_mul(nvVector2 v, nv_float s)#
Multiply vector by scalar.
- Parameters:
v – Vector
s – Scalar
- Returns:
-
static inline nvVector2 nvVector2_div(nvVector2 v, nv_float s)#
Divide vector by scalar.
- Parameters:
v – Vector
s – Scalar
- Returns:
-
static inline nvVector2 nvVector2_neg(nvVector2 v)#
Negate a vector.
- Parameters:
v – Vector to negate
- Returns:
-
static inline nvVector2 nvVector2_rotate(nvVector2 v, nv_float a)#
Rotate vector around the origin.
- Parameters:
v – Vector to rotate
a – Angle in radians
- Returns:
-
static inline nvVector2 nvVector2_perp(nvVector2 v)#
Perpendicular vector (+90 degrees).
- Parameters:
v – Vector
a – Angle in radians
- Returns:
-
static inline nvVector2 nvVector2_perpr(nvVector2 v)#
Perpendicular vector (-90 degrees).
- Parameters:
v – Vector
- Returns:
-
static inline nv_float nvVector2_len2(nvVector2 v)#
Calculate squared length (magnitude) of a vector.
- Parameters:
v – Vector
- Returns:
nv_float
-
static inline nv_float nvVector2_len(nvVector2 v)#
Calculate length (magnitude) of a vector.
- Parameters:
v – Vector
- Returns:
nv_float
-
static inline nv_float nvVector2_dot(nvVector2 a, nvVector2 b)#
Dot product of two vectors.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
nv_float
-
static inline nv_float nvVector2_cross(nvVector2 a, nvVector2 b)#
Z component of cross product of two vectors.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
nv_float
-
static inline nv_float nvVector2_dist2(nvVector2 a, nvVector2 b)#
Squared distance from one vector to another.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
nv_float