Skip to content
Snippets Groups Projects
vector.h 1.33 KiB
/*! \file Abstract of the vector-lib file
          Contains the skeleton of the vector-lib file. All the functions and structs are defined here.
*/

#ifndef VECTOR_H_ /* Header guard. Prevent the error of double inclusion inside a program. See : https://fr.wikipedia.org/wiki/Include_guard */
#define VECTOR_H_

/**
 * @brief Cartesian vector
 */
typedef struct {
    double x;
    double y;
} vector;

/**
 * @brief Polar vector used for representation only
 */
typedef struct {
    double f; /* Force of the vector */
    double a; /* Angle of the vector */
} polarVector;

vector add_vector(vector v1, vector v2); /* Add a vector to another and return the result as a vector */
vector sub_vector(vector v1, vector v2); /* Substract a vector to another vector and return the result as a vector */
vector mult_by_scalar(vector v1, int scalar); /* Multiply a vector by a scalar */
double dot_multiply(vector v1, vector v2); /* Multiply two vectors with the dot product formula */
double norm(vector v1); /* Get the norm of a given vector */
polarVector to_polar(vector v1); /* Convert a Cartesian vector to a Polar vector */
vector to_cartesian(polarVector v1); /* Convert a Polar vector to a Cartesian vector */

/* For the moment, the cross product hasn't be inplemented because it only work with vectors on 3 dimentionals plan. */

#endif /* VECTOR_H_ */