💿🐜 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.

93 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 <vmq/vmq.hpp>
  23. #include <array>
  24. #include <vector>
  25. using namespace vmq::types;
  26. using namespace vmq::operators;
  27. class nest
  28. {
  29. public:
  30. struct chamber;
  31. struct shaft
  32. {
  33. std::array<float, 2> depth; ///< start and end shaft depth
  34. float chirality; ///< 1 = right-handed, -1 = left-handed
  35. float rotation; ///< starting helix angle, in radians
  36. std::array<float, 2> radius; ///< start and end helix radius
  37. std::array<float, 2> pitch; ///< start and end helix pitch
  38. std::array<float2, 2> translation; ///< start and end helix translation
  39. std::vector<chamber> chambers;
  40. float current_depth;
  41. };
  42. struct chamber
  43. {
  44. shaft* shaft; ///< parent shaft
  45. float depth; ///< chamber depth, relative to parent shaft
  46. float rotation; ///< chamber rotation, relative to helix angle
  47. float sector_angle; ///<
  48. float inner_radius;
  49. float outer_radius;
  50. };
  51. /**
  52. * Creates a nest.
  53. */
  54. nest();
  55. float3 extend_shaft(shaft& shaft);
  56. float3 expand_chamber(chamber& chamber);
  57. void regenerate();
  58. void set_tunnel_radius(float radius);
  59. shaft* get_central_shaft();
  60. /**
  61. * Calculates the position on a shaft at the specified depth.
  62. */
  63. float3 get_shaft_position(const shaft& shaft, float depth) const;
  64. float get_shaft_angle(const shaft& shaft, float depth) const;
  65. float get_shaft_depth(const shaft& shaft, float turns) const;
  66. private:
  67. float tunnel_radius;
  68. shaft central_shaft;
  69. float dig_radius;
  70. };
  71. inline nest::shaft* nest::get_central_shaft()
  72. {
  73. return &central_shaft;
  74. }
  75. #endif // ANTKEEPER_NEST_HPP