vec3.lua 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. local ffi = require("ffi")
  2. ffi.cdef
  3. [[
  4. typedef struct
  5. {
  6. float x;
  7. float y;
  8. float z;
  9. } Vec3;
  10. Vec3* vec3(float nx, float ny, float nz);
  11. Vec3* vec3_add(Vec3* self, const Vec3* v);
  12. Vec3* vec3_subtract(Vec3* self, const Vec3* v);
  13. Vec3* vec3_multiply(Vec3* self, const float s);
  14. Vec3* vec3_divide(Vec3* self, const float s);
  15. float vec3_dot(Vec3* self, const Vec3* v);
  16. Vec3* vec3_cross(Vec3* self, const Vec3* v);
  17. bool vec3_equal(Vec3* self, const Vec3* other);
  18. bool vec3_lower(Vec3* self, const Vec3* other);
  19. bool vec3_greater(Vec3* self, const Vec3* other);
  20. float vec3_length(Vec3* self);
  21. float vec3_squared_length(Vec3* self);
  22. void vec3_set_length(Vec3* self, float len);
  23. Vec3* vec3_normalize(Vec3* self);
  24. Vec3* vec3_negate(Vec3* self);
  25. float vec3_get_distance_to(Vec3* self, const Vec3* a);
  26. float vec3_get_angle_between(Vec3* self, const Vec3* a);
  27. void vec3_zero(Vec3* self);
  28. ]]