movement.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file movement.h
  3. * @brief universal movement functions.
  4. */
  5. /**
  6. * @def MOVEMENT_H
  7. */
  8. #ifndef MOVEMENT_H
  9. #define MOVEMENT_H
  10. #define ASTEROID_SPEED_MAX 2.0f
  11. #define ASTEROID_SPEED_INIT 0.7f
  12. #define SPEED_INIT 0.5f
  13. #define SPEED_LIMIT_HIGH 4.0f
  14. #define SPEED_LIMIT_LOW 0.0f
  15. #define SPEED_LIMIT_EPSILON 0.0001f
  16. #define SPEED_STOP 0.1f
  17. #define SPEED_ACCEL 0.075f
  18. #define SPEED_BRAKE 0.033f
  19. #define SPEED_INERTION 0.008f
  20. #define SPEED_VECTOR_CHANGE 2.0f
  21. #define SPEED_BRAKE_VECTOR 2.315f
  22. #define TURN_RATE 0.06f
  23. /**
  24. * @fn forward(float *x, float *y, float speed, float heading)
  25. * moves the object forward
  26. * @param x - pointer to object's X position
  27. * @param y - pointer to object's Y position
  28. * @param speed - value how much to move the object on X and Y
  29. * @param heading - value where to move the objects
  30. */
  31. void forward(float *x, float *y, float speed, float heading);
  32. /**
  33. * @fn void backward(float *x, float *y, float speed, float heading)
  34. * moves the object forward(not error)
  35. * @param x - pointer to object's X position
  36. * @param y - pointer to object's Y position
  37. * @param speed - value how much to move the object on X and Y
  38. * @param heading - value where to move the objects
  39. */
  40. void backward(float *x, float *y, float speed, float heading);
  41. /**
  42. * @fn void accel(float *speed)
  43. * increase the speed of object by SPEED_ACCEL and check for limits.
  44. * @param speed - pointer to speed to change
  45. */
  46. void accel(float *speed);
  47. /**
  48. * @fn void brake(float *speed)
  49. * decrease the speed of object by SPEED_BRAKE and check for limits.
  50. * @param speed - pointer to value to change
  51. */
  52. void brake(float *speed);
  53. /**
  54. * @fn void inertion(float *speed)
  55. * decrease the speed of object by SPEED_INERTION and check for limits.
  56. * @param speed - pointer to value to change
  57. */
  58. void inertion(float *speed);
  59. /**
  60. * float normolize(float angle)
  61. * normolizes the angle between [-2/pi; 2/pi]
  62. * @param angle - angle to normolize
  63. * @return normolized angle
  64. */
  65. float normolize(float angle);
  66. /**
  67. * @fn float gelu(float x)
  68. * activation gelu function
  69. * @param x - takes in value to "activate"
  70. * @return new value between [-3;5]
  71. */
  72. float gelu(float x);
  73. /**
  74. * @fn void left(float *arg)
  75. * rotates object by TURN_RATE in CCW direction
  76. * @param arg - pointer to the objects current twist
  77. */
  78. void left(float *arg);
  79. /**
  80. * @fn void right(float *arg)
  81. * rotates object by TURN_RATE in CW direction
  82. * @param arg - pointer to the objects current twist
  83. */
  84. void right(float *arg);
  85. #endif /* MOVEMENT_H */