You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
718 B
33 lines
718 B
#include <math.h> |
|
|
|
#ifndef VECT_H |
|
#define VECT_H |
|
|
|
// origin-centred vector |
|
typedef struct { |
|
double x; |
|
double y; |
|
} Vect; |
|
|
|
/* Return the magnitude of two vectors */ |
|
double vect_mag(Vect v); |
|
|
|
/* Return the angle of a vector in radians (using atan2) */ |
|
double vect_dir(Vect V); |
|
|
|
/* Return the dot product of two vectors */ |
|
double vect_dot(Vect V, Vect B); |
|
|
|
/* return a vector multiplied by a scalar */ |
|
Vect vect_scalar(Vect V, double s); |
|
|
|
/* Return the sum of two vectors */ |
|
Vect vect_add(Vect v1, Vect v2); |
|
|
|
/* Return the projection of vector one onto vector two */ |
|
Vect project_vect(Vect one, Vect two); |
|
|
|
/* Return the scalar projection of V onto P */ |
|
double vect_scalar_projection(Vect V, Vect P); |
|
|
|
#endif
|
|
|