Some 2d cartesian vector functions
Former-commit-id: f5de4b53cee352d5c1866dfc0a771f462b50af7a
This commit is contained in:
parent
41366c175d
commit
4bfd0ce717
|
@ -8,6 +8,27 @@
|
|||
|
||||
//static inline double vectors_h_sq(double x) {return x*x;}
|
||||
|
||||
static inline cart2_t cart2_add(const cart2_t a, const cart2_t b) {
|
||||
cart2_t res = {a.x+b.x, a.y+b.y};
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline cart2_t cart2_substract(const cart2_t a, const cart2_t b) {
|
||||
cart2_t res = {a.x-b.x, a.y-b.y};
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline cart2_t cart2_scale(const double c, const cart2_t v) {
|
||||
cart2_t res = {c * v.x, c * v.y};
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline double cart2norm(const cart2_t v) {
|
||||
return sqrt(v.x*v.x + v.y*v.y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline double cart3norm(const cart3_t v) {
|
||||
return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue