Vector2¶
-
struct nvVector2¶
2D vector type.
-
NV_VECTOR2(x, y)¶
Initialize nvVector2 literal.
- Parameters:
x – X component
y – Y component
- Returns:
Methods¶
-
static inline nv_bool nvVector2_eq(nvVector2 a, nvVector2 b)¶
Check if two vectors are equal.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
nv_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
-
static inline nv_float nvVector2_dist(nvVector2 a, nvVector2 b)¶
Distance from one vector to another.
- Parameters:
a – Left-hand vector
b – Right-hand vector
- Returns:
nv_float
-
static inline nvVector2 nvVector2_normalize(nvVector2 v)¶
Normalize a vector.
- Parameters:
v – Vector to normalize
- Returns: