Tatooine
split_behavior.h
Go to the documentation of this file.
1#ifndef TATOOINE_DETAIL_AUTONOMOUS_PARTICLE_SPLIT_BEHAVIOR_H
2#define TATOOINE_DETAIL_AUTONOMOUS_PARTICLE_SPLIT_BEHAVIOR_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/math.h>
6#include <tatooine/vec.h>
7
8#include <array>
9//==============================================================================
11//==============================================================================
12template <floating_point Real, std::size_t NumDimensions>
14//==============================================================================
16template <floating_point Real>
17struct split_behaviors<Real, 2> {
18 static auto constexpr one = Real(1);
19 static auto constexpr half = one / Real(2);
20 static auto constexpr third = one / Real(3);
21 static auto constexpr quarter = one / Real(4);
22 static auto constexpr sixth = one / Real(6);
23 static auto constexpr three_quarters = 3 * quarter;
24 static auto constexpr two_thirds = 2 * third;
25 static auto constexpr three_sixths = 3 * sixth;
26 static auto constexpr sqrt2 = gcem::sqrt<Real>(2);
27 static auto constexpr sqrt5 = gcem::sqrt<Real>(5);
29 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 struct two_splits {
32 static auto constexpr split_cond = sqrt2;
33 static constexpr auto radii =
34 std::array{vec_t{1 / sqrt2, 1 / sqrt2 / sqrt2},
35 vec_t{1 / sqrt2, 1 / sqrt2 / sqrt2}};
36 static constexpr auto offsets =
37 std::array{vec_t{0, sqrt2 / 2 / sqrt2}, vec_t{0, -sqrt2 / 2 / sqrt2}};
38 };
39 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41 struct three_splits {
42 static auto constexpr split_cond = Real(2);
43 static constexpr auto radii = std::array{
44 vec_t{half, quarter}, vec_t{one, half}, vec_t{half, quarter}};
45 static constexpr auto offsets = std::array{
46 vec_t{0, -three_quarters}, vec_t{0, 0}, vec_t{0, three_quarters}};
47 };
48 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 struct three_in_square_splits {
51 static auto constexpr split_cond = Real(3);
52 static constexpr auto radii =
53 std::array{vec_t{one, third}, vec_t{one, third}, vec_t{one, third}};
54 static constexpr auto offsets =
55 std::array{vec_t{0, -two_thirds}, vec_t{0, 0}, vec_t{0, two_thirds}};
56 };
57 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 struct five_splits {
60 static auto constexpr r1 = one + sqrt5; // larger radius when splitting
61 static auto constexpr r2 = one; // smaller radius when splitting
62 static auto constexpr r3 = one / (one + sqrt5); // outer radius
63 static auto constexpr x3 = r1 - r3; // outer offset
64 static auto constexpr r4 =
65 half * sqrt5 - one / (one + sqrt5); // middle radius
66 static auto constexpr x4 =
67 one + half * sqrt5 - one / (one + sqrt5); // middle offset
68
69 static auto constexpr split_cond = r1;
70 static auto constexpr radii = std::array{
71 vec_t{r3, r3 / r1}, vec_t{r4, r4 / r1}, vec_t{r2, r2 / r1},
72 vec_t{r4, r4 / r1}, vec_t{r3, r3 / r1},
73 };
74 static auto constexpr offsets = std::array{
75 vec_t{0, x3 / r1}, vec_t{0, x4 / r1}, vec_t{0, 0},
76 vec_t{0, -x4 / r1}, vec_t{0, -x3 / r1},
77 };
78 };
79 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81 struct three_and_four_splits {
82 static auto constexpr r01 = Real(2);
83 static auto constexpr r02 = Real(1);
84
85 static auto constexpr x1 = Real(0);
86 static auto constexpr y1 = Real(0);
87 static auto constexpr r1 = Real(1);
88
89 static auto constexpr x2 = 3 * half;
90 static auto constexpr y2 = Real(0);
91 static auto constexpr r2 = half;
92
93 static auto constexpr x4 = Real(1.077350269);
94 static auto constexpr y4 = Real(0.5977169814);
95 static auto constexpr r4 = Real(0.2320508081);
96
97 static auto constexpr split_cond = r01 / r02;
98
99 static auto constexpr radii = std::array{
100 vec_t{r1, r1 / r01}, vec_t{r2, r2 / r01}, vec_t{r2, r2 / r01},
101 vec_t{r4, r4 / r01}, vec_t{r4, r4 / r01}, vec_t{r4, r4 / r01},
102 vec_t{r4, r4 / r01},
103 };
104 static auto constexpr offsets = std::array{
105 vec_t{0, 0}, vec_t{y2, x2 / r01}, vec_t{y2, -x2 / r01},
106 vec_t{y4, x4 / r01}, vec_t{y4, -x4 / r01}, vec_t{-y4, x4 / r01},
107 vec_t{-y4, -x4 / r01},
108 };
109 };
110 //============================================================================
112 struct seven_splits {
113 static auto constexpr rr = Real(4.493959210);
114 static auto constexpr rr1 = Real(0.9009688678);
115 static auto constexpr rr2 = Real(0.6234898004);
116
117 static auto constexpr split_cond = rr;
118
119 static auto constexpr radii = std::array{
120 vec_t{1, 1 / rr},
121 vec_t{(1 / rr), (1 / rr) / rr},
122 vec_t{(1 / rr), (1 / rr) / rr},
123 vec_t{rr1, rr1 / rr},
124 vec_t{rr1, rr1 / rr},
125 vec_t{rr2, rr2 / rr},
126 vec_t{rr2, rr2 / rr},
127 };
128 static auto constexpr offsets = std::array{
129 vec_t{0, 0},
130 vec_t{0, (1 + 2 * rr1 + 2 * rr2 + (1 / rr)) / rr},
131 vec_t{0, (-1 - 2 * rr1 - 2 * rr2 - (1 / rr)) / rr},
132 vec_t{0, (1 + rr1) / rr},
133 vec_t{0, (-1 - rr1) / rr},
134 vec_t{0, (1 + 2 * rr1 + rr2) / rr},
135 vec_t{0, (-1 - 2 * rr1 - rr2) / rr},
136 };
137 };
138 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139 // struct centered_four {
140 // static auto constexpr x5 = Real(0.4830517593887872);
141 // static auto constexpr split_cond = Real(2);
142 // static auto constexpr radii =
143 // std::array{vec_t{x5, x5 / 2},
144 // vec_t{x5, x5 / 2},
145 // vec_t{x5, x5 / 2},
146 // vec_t{x5, x5 / 2},
147 // vec_t{real_type(1) / real_type(2), real_type(1) / real_type(4)},
148 // vec_t{real_type(1) / real_type(2), real_type(1) / real_type(4)}};
149 // static auto constexpr offsets = std::array{
150 // vec_t{-x5, -x5 / 2}, vec_t{x5, -x5 / 2}, vec_t{-x5, x5 / 2},
151 // vec_t{x5, x5 / 2}, vec_t{0, real_type(3) / 4}, vec_t{0, -real_type(3) /
152 // 4}};
153 //};
154};
155//==============================================================================
157template <floating_point Real>
158struct split_behaviors<Real, 3> {
159 static auto constexpr half = 1 / Real(2);
160 static auto constexpr quarter = 1 / Real(4);
161 static auto constexpr three_quarters = 3 * quarter;
163 struct three_splits {
164 static auto constexpr split_cond = Real(2);
165 static constexpr auto radii =
166 std::array{vec_t{half, half, quarter}, vec_t{1, 1, half},
167 vec_t{half, half, quarter}};
168 static constexpr auto offsets =
169 std::array{vec_t{0, 0, -three_quarters}, vec_t{0, 0, 0},
170 vec_t{0, 0, three_quarters}};
171 };
172};
173//==============================================================================
174} // namespace tatooine::detail::autonomous_particle
175//==============================================================================
176#endif
Definition: post_triangulation.h:10
Definition: vec.h:12