From 257800e6fabace91463b81d857ee33e46fe20547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 25 Aug 2016 00:19:39 +0200 Subject: [PATCH] Math: reordered Bezier members to saner order. --- src/Magnum/Math/Bezier.h | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Magnum/Math/Bezier.h b/src/Magnum/Math/Bezier.h index 9588b13ed..f4c729514 100644 --- a/src/Magnum/Math/Bezier.h +++ b/src/Magnum/Math/Bezier.h @@ -95,22 +95,25 @@ template class Bezier { */ template constexpr explicit Bezier(const Bezier& other) noexcept: Bezier{typename Implementation::GenerateSequence::Type(), other} {} + /** @brief Equality comparison */ + bool operator==(const Bezier& other) const { + for(std::size_t i = 0; i != order + 1; ++i) + if((*this)[i] != other[i]) return false; + return true; + } + + /** @brief Non-equality comparison */ + bool operator!=(const Bezier& other) const { + return !operator==(other); + } + /** - * @brief Subdivide the curve at given position + * @brief Control point access * - * Returns two Bézier curves following the original curve, split at - * given interpolation factor. Uses the [De Casteljau's algorithm](https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm). - * @see @ref value() + * @p i should not be larger than @ref Order. */ - std::pair, Bezier> subdivide(Float t) const { - const auto iPoints = calculateIntermediatePoints(t); - Bezier left, right; - for(std::size_t i = 0; i <= order; ++i) - left[i] = iPoints[0][i]; - for(std::size_t i = 0, j = order; i <= order; --j, ++i) - right[i] = iPoints[i][j]; - return {left, right}; - } + Vector& operator[](std::size_t i) { return _data[i]; } + constexpr Vector operator[](std::size_t i) const { return _data[i]; } /**< @overload */ /** * @brief Interpolate the curve at given position @@ -124,23 +127,20 @@ template class Bezier { } /** - * @brief Control point access + * @brief Subdivide the curve at given position * - * @p i should not be larger than @ref Order. + * Returns two Bézier curves following the original curve, split at + * given interpolation factor. Uses the [De Casteljau's algorithm](https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm). + * @see @ref value() */ - Vector& operator[](std::size_t i) { return _data[i]; } - constexpr Vector operator[](std::size_t i) const { return _data[i]; } /**< @overload */ - - /** @brief Equality comparison */ - bool operator==(const Bezier& other) const { - for(std::size_t i = 0; i != order + 1; ++i) - if((*this)[i] != other[i]) return false; - return true; - } - - /** @brief Non-equality comparison */ - bool operator!=(const Bezier& other) const { - return !operator==(other); + std::pair, Bezier> subdivide(Float t) const { + const auto iPoints = calculateIntermediatePoints(t); + Bezier left, right; + for(std::size_t i = 0; i <= order; ++i) + left[i] = iPoints[0][i]; + for(std::size_t i = 0, j = order; i <= order; --j, ++i) + right[i] = iPoints[i][j]; + return {left, right}; } private: