Commit 584eded4 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/embedded-circlep-separate-helper' into 'master'

[md][embedded] Factor out sin/cos precomputation

See merge request !2536
parents b05a5b67 a3e994d6
......@@ -82,21 +82,12 @@ void circlePoints(std::vector<GlobalPosition>& points,
/*!
* \ingroup EmbeddedCoupling
* \brief returns a vector of points on a circle
* \param center the circle center
* \param normal the normal to the circle plane
* \param radius the circle radius
* \brief returns a vector of sin and cos values of a circle parametrization
* \param numPoints the number of points
*/
template<class GlobalPosition, class Scalar>
std::vector<GlobalPosition> circlePoints(const GlobalPosition& center,
const GlobalPosition& normal,
const Scalar radius,
const std::size_t numPoints = 20)
template<class Scalar = double>
std::vector<Scalar> circlePointsSinCos(const std::size_t numPoints)
{
std::vector<GlobalPosition> points;
// precompute the sin/cos
std::vector<Scalar> sincos(2*numPoints);
Scalar t = 0 + 0.1; // add arbitrary offset
for (std::size_t i = 0; i < numPoints; ++i)
......@@ -107,7 +98,27 @@ std::vector<GlobalPosition> circlePoints(const GlobalPosition& center,
t += 2*M_PI/numPoints;
if(t > 2*M_PI) t -= 2*M_PI;
}
return sincos;
}
/*!
* \ingroup EmbeddedCoupling
* \brief returns a vector of points on a circle
* \param center the circle center
* \param normal the normal to the circle plane
* \param radius the circle radius
* \param numPoints the number of points
*/
template<class GlobalPosition, class Scalar>
std::vector<GlobalPosition> circlePoints(const GlobalPosition& center,
const GlobalPosition& normal,
const Scalar radius,
const std::size_t numPoints = 20)
{
// precompute the sin/cos values
const auto sincos = circlePointsSinCos<Scalar>(numPoints);
std::vector<GlobalPosition> points;
circlePoints(points, sincos, center, normal, radius);
return points;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment