💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.3 KiB

  1. /*
  2. * Copyright (C) 2020 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_NEST_HPP
  20. #define ANTKEEPER_NEST_HPP
  21. #include "geometry/mesh.hpp"
  22. #include "utility/fundamental-types.hpp"
  23. #include <array>
  24. #include <vector>
  25. class nest
  26. {
  27. public:
  28. struct chamber;
  29. struct shaft
  30. {
  31. std::array<float, 2> depth; ///< start and end shaft depth
  32. float chirality; ///< 1 = right-handed, -1 = left-handed
  33. float rotation; ///< starting helix angle, in radians
  34. std::array<float, 2> radius; ///< start and end helix radius
  35. std::array<float, 2> pitch; ///< start and end helix pitch
  36. std::array<float2, 2> translation; ///< start and end helix translation
  37. std::vector<chamber> chambers;
  38. float current_depth;
  39. };
  40. struct chamber
  41. {
  42. shaft* shaft; ///< parent shaft
  43. float depth; ///< chamber depth, relative to parent shaft
  44. float rotation; ///< chamber rotation, relative to helix angle
  45. float sector_angle; ///<
  46. float inner_radius;
  47. float outer_radius;
  48. };
  49. /**
  50. * Creates a nest.
  51. */
  52. nest();
  53. float3 extend_shaft(shaft& shaft);
  54. float3 expand_chamber(chamber& chamber);
  55. void regenerate();
  56. void set_tunnel_radius(float radius);
  57. shaft* get_central_shaft();
  58. /**
  59. * Calculates the position on a shaft at the specified depth.
  60. */
  61. float3 get_shaft_position(const shaft& shaft, float depth) const;
  62. float get_shaft_angle(const shaft& shaft, float depth) const;
  63. float get_shaft_depth(const shaft& shaft, float turns) const;
  64. private:
  65. float tunnel_radius;
  66. shaft central_shaft;
  67. float dig_radius;
  68. };
  69. inline nest::shaft* nest::get_central_shaft()
  70. {
  71. return &central_shaft;
  72. }
  73. #endif // ANTKEEPER_NEST_HPP