30 const auto a12 = a2 - a1;
46 assert(
size(vertices) >= 3);
53 const auto pRef =
Average(vertices);
55 for (
auto i = decltype(
size(vertices)){0}; i <
size(vertices); ++i)
59 const auto p2 = vertices[i];
62 const auto e1 = p2 - p1;
63 const auto e2 = p3 - p1;
66 const auto triangleArea =
Area{
Cross(e1, e2) * RealInverseOfTwo};
71 const auto aveP = (p1 + p2 + p3) * RealInverseOfThree;
72 c += triangleArea * aveP;
82 std::vector<Length2> vertices;
85 const auto integralTurns =
static_cast<long int>(turns);
86 const auto wholeNum = (turns ==
static_cast<Real>(integralTurns));
87 const auto deltaAngle = (
Pi * 2_rad * turns) /
static_cast<Real>(slices);
88 auto i = decltype(slices){0};
91 const auto angleInRadians =
Real{(start + (
static_cast<Real>(i) * deltaAngle)) /
Radian};
92 const auto x = radius *
cos(angleInRadians);
93 const auto y = radius *
sin(angleInRadians);
94 vertices.emplace_back(x, y);
100 vertices.push_back(vertices[0]);
104 const auto angleInRadians =
Real{(start + (
static_cast<Real>(i) * deltaAngle)) /
Radian};
105 const auto x = radius *
cos(angleInRadians);
106 const auto y = radius *
sin(angleInRadians);
107 vertices.emplace_back(x, y);
115 return Area{radius * radius *
Pi};
123 const auto count =
size(vertices);
124 for (
auto i = decltype(count){0}; i < count; ++i)
127 const auto this_v = vertices[i];
135 return abs(sum) * RealInverseOfTwo;
140 assert(
size(vertices) > 2);
150 const auto count =
size(vertices);
151 for (
auto i = decltype(count){0}; i < count; ++i)
153 const auto this_v = vertices[i];
155 const auto fact_b =
Cross(this_v, next_v);
158 return fact_a * fact_b;
162 return fact_a * fact_b;
168 return (secondMomentOfAreaX + secondMomentOfAreaY) * RealInverseOfTwelve;
176 #if 0 // Using std::fma appears to be slower!
178 const auto xRevPerpRelB =
StripUnit(revPerpRelB.x);
179 const auto yRevPerpRelB =
StripUnit(revPerpRelB.y);
180 const auto angVelB =
StripUnit(velB.angular);
181 const auto xLinVelB =
StripUnit(velB.linear.x);
182 const auto yLinVelB =
StripUnit(velB.linear.y);
183 const auto xFmaB = std::fma(xRevPerpRelB, angVelB, xLinVelB);
184 const auto yFmaB = std::fma(yRevPerpRelB, angVelB, yLinVelB);
187 const auto xRevPerpRelA =
StripUnit(revPerpRelA.x);
188 const auto yRevPerpRelA =
StripUnit(revPerpRelA.y);
189 const auto angVelA =
StripUnit(velA.angular);
190 const auto xLinVelA =
StripUnit(velA.linear.x);
191 const auto yLinVelA =
StripUnit(velA.linear.y);
192 const auto xFmaA = std::fma(xRevPerpRelA, angVelA, xLinVelA);
193 const auto yFmaA = std::fma(yRevPerpRelA, angVelA, yLinVelA);
195 const auto deltaFmaX = xFmaB - xFmaA;
196 const auto deltaFmaY = yFmaB - yFmaA;
202 return (velB.linear + velBrot) - (velA.linear + velArot);