vector.c 772 B

123456789101112131415161718192021222324252627282930313233
  1. #include "vector.h"
  2. Vector vector_add(Vector a, Vector b) {
  3. return (Vector){.x = a.x + b.x, .y = a.y + b.y};
  4. }
  5. Vector vector_sub(Vector a, Vector b) {
  6. return (Vector){.x = a.x - b.x, .y = a.y - b.y};
  7. }
  8. Vector vector_mul(Vector a, Vector b) {
  9. return (Vector){.x = a.x * b.x, .y = a.y * b.y};
  10. }
  11. Vector vector_div(Vector a, Vector b) {
  12. return (Vector){.x = a.x / b.x, .y = a.y / b.y};
  13. }
  14. Vector vector_addf(Vector a, float b) {
  15. return (Vector){.x = a.x + b, .y = a.y + b};
  16. }
  17. Vector vector_subf(Vector a, float b) {
  18. return (Vector){.x = a.x - b, .y = a.y - b};
  19. }
  20. Vector vector_mulf(Vector a, float b) {
  21. return (Vector){.x = a.x * b, .y = a.y * b};
  22. }
  23. Vector vector_divf(Vector a, float b) {
  24. return (Vector){.x = a.x / b, .y = a.y / b};
  25. }