liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
vector2.h File Reference

two-dimensional vector More...

#include "a.h"
#include "math.h"
Include dependency graph for vector2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  a_vector2
 instance structure for two-dimensional vector More...

Macros

#define A_VECTOR2_C(x, y)
#define a_vector2_c(x)
#define a_vector2_(_, x)

Typedefs

typedef struct a_vector2 a_vector2
typedef struct a_vector2 a::vector2

Functions

a_real a_vector2_set_dir (a_vector2 *ctx, a_real x, a_real y)
 set the components of a 2D vector and normalize it in place.
void a_vector2_val (a_vector2 const *ctx, a_real *x, a_real *y)
 get the cartesian coordinates of a 2D vector.
void a_vector2_set_val (a_vector2 *ctx, a_real x, a_real y)
 set the cartesian coordinates of a 2D vector.
void a_vector2_pol (a_vector2 const *ctx, a_real *rho, a_real *theta)
 get the polar coordinates of a 2D vector.
void a_vector2_set_pol (a_vector2 *ctx, a_real rho, a_real theta)
 set the polar coordinates of a 2D vector.
void a_vector2_add (a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
 add a 2D vector to a 2D vector.
void a_vector2_sub (a_vector2 const *lhs, a_vector2 const *rhs, a_vector2 *res)
 subtract a 2D vector from a 2D vector.
void a_vector2_mul (a_vector2 const *lhs, a_real rhs, a_vector2 *res)
 multiplie a 2D vector by a scalar.
void a_vector2_div (a_vector2 const *lhs, a_real rhs, a_vector2 *res)
 divide a 2D vector by a scalar.
void a_vector2_neg (a_vector2 const *ctx, a_vector2 *res)
 negate a 2D vector.
a_real a_vector2_unit (a_vector2 *ctx)
 normalize a 2D vector in-place to unit length.
a_real a_vector2_norm (a_vector2 const *ctx)
 compute the magnitude of a 2D vector.
a_real a_vector2_norm2 (a_vector2 const *ctx)
 compute the squared magnitude of a 2D vector.
a_real a_vector2_dot (a_vector2 const *lhs, a_vector2 const *rhs)
 compute the dot product (scalar product) of two 2D vectors.
a_real a_vector2_dist (a_vector2 const *lhs, a_vector2 const *rhs)
 compute the distance between two 2D vectors.
a_real a_vector2_dist2 (a_vector2 const *lhs, a_vector2 const *rhs)
 compute the squared distance between two 2D vectors.
a_real a_vector2_angle (a_vector2 const *lhs, a_vector2 const *rhs)
 compute the angle between two 2D vectors in radians.
a_bool a_vector2_isver (a_vector2 const *lhs, a_vector2 const *rhs)
 check if two 2D vectors are orthogonal.
a_bool a_vector2_ispar (a_vector2 const *lhs, a_vector2 const *rhs)
 check if two 2D vectors are parallel or anti-parallel.
a_real a_vector2_cross (a_vector2 const *lhs, a_vector2 const *rhs)
 compute the cross product (vector product) of two 2D vectors
void a_vector2_outer (a_vector2 const *lhs, a_vector2 const *rhs, a_real res[4])
 compute the outer product (tensor product) of two 2D vectors.
int a_vector2_proj (a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
 project vector onto the direction of vector.
int a_vector2_perp (a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
 project vector onto the line perpendicular to vector.
int a_vector2_refl (a_vector2 const *ctx, a_vector2 const *dir, a_vector2 *res)
 reflect vector across the line with direction vector.
void a_vector2_rot_ (a_vector2 const *ctx, a_real sin, a_real cos, a_vector2 *res)
 rotate a 2D vector by a specified angle (in radians).
void a_vector2_rot (a_vector2 const *ctx, a_real angle, a_vector2 *res)
 rotate a 2D vector by a specified angle (in radians).

Detailed Description

two-dimensional vector