Aversive/Modules/base/math/vect2
De Wikidroids
Return to Aversive/Modules/base
Module math/vect2
This module provide functions and data structures to handle 2 dimensionals vectors in both cartesian and polar coordinates.
The vectors use the scalar Real for their coordinates. By default we choose double to be the Real scalar.
typedef double Real
The cartesian vector structure.
typedef struct _vect2_cart { Real x; Real y; }vect2_cart;
The polar vector structure.
typedef struct _vect2_cart { Real x; Real y; }vect2_cart;
Vect2 module functions follows :
- Arguments : ( reference to source, reference to target )
- No memory allocation.
Module interface :
- Convert a polar vector to a cartesian one.
void vect2_pol2cart( vect2_pol* vp, vect2_cart* vc )
- Convert a cartesian vector to a polar one.
void vect2_cart2pol( vect2_cart* vp, vect2_pol* vc )
- Add 2 polar vectors.
void vect2_add_pol( vect2_pol* v1, vect2_pol* v2, vect2_pol* vresultat )
This function convert the 2 entry vectors to cartesian, sum them and then convert the result to polar. So please think before using it.
- Substract 2 polar vectors.
void vect2_sub_pol( vect2_pol* v1, vect2_pol* v2, vect2_pol* vresultat )
This function convert the 2 entry vectors to cartesian, substract them and then convert the result to polar. So please think before using it.
- Add 2 cartesian vectors.
void vect2_add_cart( vect2_cart* v1, vect2_cart* v2, vect2_cart vresultat )
- Substract 2 cartesian vectors.
void vect2_sub_cart( vect2_cart* v1, vect2_cart* v2, vect2_cart vresultat )
- Scale a polar vector by a scalar.
void vect2_scale_pol( vect2_pol* v1, Real alpha, vect2_pol* vresult )
- Scale a cartesian vector by a scalar.
void vect2_scale_cart( vect2_cart* v1, Real alpha, vect2_cart* vresult )