Quaternion.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. function Quaternion() {
  2. Object.defineProperties(this, {
  3. 'x': { enumerable: true, configurable: true, get: Quaternion.prototype.__get_x, set: Quaternion.prototype.__set_x},
  4. 'y': { enumerable: true, configurable: true, get: Quaternion.prototype.__get_y, set: Quaternion.prototype.__set_y},
  5. 'z': { enumerable: true, configurable: true, get: Quaternion.prototype.__get_z, set: Quaternion.prototype.__set_z},
  6. 'w': { enumerable: true, configurable: true, get: Quaternion.prototype.__get_w, set: Quaternion.prototype.__set_w}
  7. })
  8. }
  9. Quaternion.prototype.__get_x = function() {
  10. return Polycode.Quaternion__get_x(this.__ptr)
  11. }
  12. Quaternion.prototype.__set_x = function(val) {
  13. Polycode.Quaternion__set_x(this.__ptr, val)
  14. }
  15. Quaternion.prototype.__get_y = function() {
  16. return Polycode.Quaternion__get_y(this.__ptr)
  17. }
  18. Quaternion.prototype.__set_y = function(val) {
  19. Polycode.Quaternion__set_y(this.__ptr, val)
  20. }
  21. Quaternion.prototype.__get_z = function() {
  22. return Polycode.Quaternion__get_z(this.__ptr)
  23. }
  24. Quaternion.prototype.__set_z = function(val) {
  25. Polycode.Quaternion__set_z(this.__ptr, val)
  26. }
  27. Quaternion.prototype.__get_w = function() {
  28. return Polycode.Quaternion__get_w(this.__ptr)
  29. }
  30. Quaternion.prototype.__set_w = function(val) {
  31. Polycode.Quaternion__set_w(this.__ptr, val)
  32. }
  33. Quaternion.prototype.setFromMatrix = function(_mat) {
  34. Polycode.Quaternion_setFromMatrix(this.__ptr, _mat)
  35. }
  36. Quaternion.prototype.Dot = function(rkQ) {
  37. return Polycode.Quaternion_Dot(this.__ptr, rkQ)
  38. }
  39. Quaternion.prototype.Log = function() {
  40. var retVal = new Quaternion()
  41. retVal.__ptr = Polycode.Quaternion_Log(this.__ptr)
  42. return retVal
  43. }
  44. Quaternion.prototype.Exp = function() {
  45. var retVal = new Quaternion()
  46. retVal.__ptr = Polycode.Quaternion_Exp(this.__ptr)
  47. return retVal
  48. }
  49. Quaternion.prototype.Norm = function() {
  50. return Polycode.Quaternion_Norm(this.__ptr)
  51. }
  52. Quaternion.prototype.Normalize = function() {
  53. return Polycode.Quaternion_Normalize(this.__ptr)
  54. }
  55. Quaternion.prototype.lookAt = function(D,upVector) {
  56. Polycode.Quaternion_lookAt(this.__ptr, D,upVector)
  57. }
  58. Quaternion.prototype.createFromMatrix = function(matrix) {
  59. Polycode.Quaternion_createFromMatrix(this.__ptr, matrix)
  60. }
  61. Quaternion.prototype.Inverse = function() {
  62. var retVal = new Quaternion()
  63. retVal.__ptr = Polycode.Quaternion_Inverse(this.__ptr)
  64. return retVal
  65. }
  66. Quaternion.prototype.set = function(w,x,y,z) {
  67. Polycode.Quaternion_set(this.__ptr, w,x,y,z)
  68. }
  69. Quaternion.prototype.InvSqrt = function(x) {
  70. return Polycode.Quaternion_InvSqrt(this.__ptr, x)
  71. }
  72. Quaternion.prototype.fromAxes = function(az,ay,ax) {
  73. Polycode.Quaternion_fromAxes(this.__ptr, az,ay,ax)
  74. }
  75. Quaternion.prototype.fromAngleAxis = function(rfAngle,rkAxis) {
  76. Polycode.Quaternion_fromAngleAxis(this.__ptr, rfAngle,rkAxis)
  77. }
  78. Quaternion.prototype.toEulerAngles = function() {
  79. var retVal = new Vector3()
  80. retVal.__ptr = Polycode.Quaternion_toEulerAngles(this.__ptr)
  81. return retVal
  82. }
  83. Quaternion.prototype.toAngleAxis = function(rfAngle,rkAxis) {
  84. Polycode.Quaternion_toAngleAxis(this.__ptr, rfAngle,rkAxis)
  85. }
  86. Quaternion.prototype.createFromAxisAngle = function(x,y,z,degrees) {
  87. Polycode.Quaternion_createFromAxisAngle(this.__ptr, x,y,z,degrees)
  88. }
  89. Quaternion.prototype.createMatrix = function() {
  90. var retVal = new Matrix4()
  91. retVal.__ptr = Polycode.Quaternion_createMatrix(this.__ptr)
  92. return retVal
  93. }
  94. Quaternion.prototype.applyTo = function(v) {
  95. var retVal = new Vector3()
  96. retVal.__ptr = Polycode.Quaternion_applyTo(this.__ptr, v)
  97. return retVal
  98. }