源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

91 linhas
2.6 KiB

4 semanas atrás
  1. --[[
  2. =================================
  3. @Author: ZensYue
  4. @DateTime: 2016-12-26 20:52:39
  5. @Description:
  6. =================================
  7. ]]
  8. EllipseConfig = EllipseConfig or BaseClass()
  9. EllipseConfig.PI = 3.14
  10. local math_sin = math.sin
  11. local math_cos = math.cos
  12. --[[
  13. <*
  14. @Author: ZensYue
  15. @Description:
  16. @param: ellipse_config
  17. center_pos
  18. a
  19. b
  20. moveInAnticlockwise
  21. time 1
  22. hide_start_time ()
  23. hide_end_time ()
  24. *>
  25. ]]
  26. --L≈π(a+b)(64 - 3λ^4)/(64 - 16λ^2)
  27. function EllipseConfig:__init(ellipse_config)
  28. ellipse_config = DeepCopy(ellipse_config)
  29. self.centerPosition = ellipse_config.center_pos
  30. self.a = ellipse_config.a
  31. self.b = ellipse_config.b
  32. self.z = ellipse_config.z
  33. -- self.YI = (a-b)/(a+b)
  34. -- self.L = P*(a+b)*(64 - 3*self.YI*self.YI*self.YI*self.YI)/(64 - 16*self.YI*self.YI)
  35. self.moveInAnticlockwise = ellipse_config.moveInAnticlockwise
  36. self.time = ellipse_config.time
  37. self.hide_start_time = ellipse_config.hide_start_time or 0
  38. self.hide_end_time = ellipse_config.hide_end_time or 0
  39. self.cur_time = 0
  40. self:GetCircumference()
  41. end
  42. --[[
  43. <*
  44. @Author: ZensYue
  45. @Description: x坐标
  46. @param: t [0,1]
  47. *>
  48. ]]
  49. function EllipseConfig:GetPositionXAtOval(t)
  50. if(self.moveInAnticlockwise == false) then
  51. return self.a * math_cos(2* EllipseConfig.PI * (1 - t))+self.centerPosition.x
  52. else
  53. return self.a * math_cos(2* EllipseConfig.PI * t)+self.centerPosition.x
  54. end
  55. end
  56. --[[
  57. <*
  58. @Author: ZensYue
  59. @Description: y坐标
  60. @param: t [0,1]
  61. *>
  62. ]]
  63. function EllipseConfig:GetPositionYAtOval(t)
  64. if(self.moveInAnticlockwise == false) then
  65. return self.b * math_sin(2* EllipseConfig.PI * (1 - t))+self.centerPosition.y
  66. else
  67. return self.b * math_sin(2* EllipseConfig.PI * t)+self.centerPosition.y
  68. end
  69. end
  70. --Z轴
  71. function EllipseConfig:GetPositionZAtOval(t)
  72. if(self.moveInAnticlockwise == false) then
  73. return self.z * math_sin(2* EllipseConfig.PI * (1 - t))+self.centerPosition.z
  74. else
  75. return self.z * math_sin(2* EllipseConfig.PI * t)+self.centerPosition.z
  76. end
  77. end
  78. --[[
  79. <*
  80. @Author: ZensYue
  81. @Description:
  82. *>
  83. ]]
  84. function EllipseConfig:GetCircumference()
  85. self.circumference = EllipseConfig.PI * (self.a+self.b)
  86. end