Vector2.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function Vector2() {
  2. Object.defineProperties(this, {
  3. 'x': { enumerable: true, configurable: true, get: Vector2.prototype.__get_x, set: Vector2.prototype.__set_x},
  4. 'y': { enumerable: true, configurable: true, get: Vector2.prototype.__get_y, set: Vector2.prototype.__set_y}
  5. })
  6. }
  7. Vector2.prototype.__get_x = function() {
  8. return Polycode.Vector2__get_x(this.__ptr)
  9. }
  10. Vector2.prototype.__set_x = function(val) {
  11. Polycode.Vector2__set_x(this.__ptr, val)
  12. }
  13. Vector2.prototype.__get_y = function() {
  14. return Polycode.Vector2__get_y(this.__ptr)
  15. }
  16. Vector2.prototype.__set_y = function(val) {
  17. Polycode.Vector2__set_y(this.__ptr, val)
  18. }
  19. Vector2.prototype.set = function(x,y) {
  20. Polycode.Vector2_set(this.__ptr, x,y)
  21. }
  22. Vector2.prototype.distance = function(vec2) {
  23. return Polycode.Vector2_distance(this.__ptr, vec2)
  24. }
  25. Vector2.prototype.length = function() {
  26. return Polycode.Vector2_length(this.__ptr)
  27. }
  28. Vector2.prototype.dot = function(u) {
  29. return Polycode.Vector2_dot(this.__ptr, u)
  30. }
  31. Vector2.prototype.crossProduct = function(vec2) {
  32. return Polycode.Vector2_crossProduct(this.__ptr, vec2)
  33. }
  34. Vector2.prototype.angle = function(vec2) {
  35. return Polycode.Vector2_angle(this.__ptr, vec2)
  36. }
  37. Vector2.prototype.Normalize = function() {
  38. Polycode.Vector2_Normalize(this.__ptr)
  39. }