| @@ -509,7 +509,7 @@ struct GraphEditorPanel::ConnectorComponent : public Component, | |||||
| arrowL, 0.0f); | arrowL, 0.0f); | ||||
| arrow.applyTransform (AffineTransform() | arrow.applyTransform (AffineTransform() | ||||
| .rotated (MathConstants<float>::pi * 0.5f - (float) atan2 (p2.x - p1.x, p2.y - p1.y)) | |||||
| .rotated (MathConstants<float>::halfPi - (float) atan2 (p2.x - p1.x, p2.y - p1.y)) | |||||
| .translated ((p1 + p2) * 0.5f)); | .translated ((p1 + p2) * 0.5f)); | ||||
| linePath.addPath (arrow); | linePath.addPath (arrow); | ||||
| @@ -461,7 +461,7 @@ Path ProjucerLookAndFeel::getArrowPath (Rectangle<float> arrowZone, const int di | |||||
| if (filled) | if (filled) | ||||
| path.closeSubPath(); | path.closeSubPath(); | ||||
| path.applyTransform (AffineTransform::rotation (direction * (MathConstants<float>::pi / 2.0f), | |||||
| path.applyTransform (AffineTransform::rotation (direction * MathConstants<float>::halfPi, | |||||
| arrowZone.getCentreX(), arrowZone.getCentreY())); | arrowZone.getCentreX(), arrowZone.getCentreY())); | ||||
| return path; | return path; | ||||
| @@ -326,7 +326,6 @@ inline int64 abs64 (const int64 n) noexcept | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_HAS_CONSTEXPR | #if JUCE_HAS_CONSTEXPR | ||||
| /** Commonly used mathematical constants */ | /** Commonly used mathematical constants */ | ||||
| @@ -339,6 +338,9 @@ struct MathConstants | |||||
| /** A predefined value for 2 * Pi */ | /** A predefined value for 2 * Pi */ | ||||
| static constexpr FloatType twoPi = static_cast<FloatType> (2 * 3.141592653589793238L); | static constexpr FloatType twoPi = static_cast<FloatType> (2 * 3.141592653589793238L); | ||||
| /** A predefined value for Pi / 2 */ | |||||
| static constexpr FloatType halfPi = static_cast<FloatType> (3.141592653589793238L / 2); | |||||
| /** A predfined value for Euler's number */ | /** A predfined value for Euler's number */ | ||||
| static constexpr FloatType euler = static_cast<FloatType> (2.71828182845904523536L); | static constexpr FloatType euler = static_cast<FloatType> (2.71828182845904523536L); | ||||
| }; | }; | ||||
| @@ -355,6 +357,9 @@ struct MathConstants | |||||
| /** A predefined value for 2 * Pi */ | /** A predefined value for 2 * Pi */ | ||||
| static const FloatType twoPi; | static const FloatType twoPi; | ||||
| /** A predefined value for Pi / 2 */ | |||||
| static const FloatType halfPi; | |||||
| /** A predfined value for Euler's number */ | /** A predfined value for Euler's number */ | ||||
| static const FloatType euler; | static const FloatType euler; | ||||
| }; | }; | ||||
| @@ -365,6 +370,9 @@ const FloatType MathConstants<FloatType>::pi = static_cast<FloatType> (3.1415926 | |||||
| template <typename FloatType> | template <typename FloatType> | ||||
| const FloatType MathConstants<FloatType>::twoPi = static_cast<FloatType> (2 * 3.141592653589793238L); | const FloatType MathConstants<FloatType>::twoPi = static_cast<FloatType> (2 * 3.141592653589793238L); | ||||
| template <typename FloatType> | |||||
| const FloatType MathConstants<FloatType>::halfPi = static_cast<FloatType> (3.141592653589793238L / 2); | |||||
| template <typename FloatType> | template <typename FloatType> | ||||
| const FloatType MathConstants<FloatType>::euler = static_cast<FloatType> (2.71828182845904523536L); | const FloatType MathConstants<FloatType>::euler = static_cast<FloatType> (2.71828182845904523536L); | ||||
| @@ -407,6 +407,7 @@ Array<IIR::Coefficients<FloatType>> | |||||
| auto omegap = std::tan (MathConstants<double>::pi * fp); | auto omegap = std::tan (MathConstants<double>::pi * fp); | ||||
| auto omegas = std::tan (MathConstants<double>::pi * fs); | auto omegas = std::tan (MathConstants<double>::pi * fs); | ||||
| constexpr auto halfPi = MathConstants<double>::halfPi; | |||||
| auto k = omegap / omegas; | auto k = omegap / omegas; | ||||
| auto k1 = epsp / epss; | auto k1 = epsp / epss; | ||||
| @@ -446,35 +447,35 @@ Array<IIR::Coefficients<FloatType>> | |||||
| for (int i = 1; i <= L; ++i) | for (int i = 1; i <= L; ++i) | ||||
| { | { | ||||
| auto ui = (2 * i - 1.0) / (double) N; | auto ui = (2 * i - 1.0) / (double) N; | ||||
| pa.add (omegap * std::pow (epsp, -1.0 / (double) N) * j * exp (ui * 0.5 * MathConstants<double>::pi * j)); | |||||
| pa.add (omegap * std::pow (epsp, -1.0 / (double) N) * j * exp (ui * halfPi * j)); | |||||
| } | } | ||||
| } | } | ||||
| else if (type == 1) | else if (type == 1) | ||||
| { | { | ||||
| auto v0 = std::asinh (1.0 / epsp) / (0.5 * N * MathConstants<double>::pi); | |||||
| auto v0 = std::asinh (1.0 / epsp) / (N * halfPi); | |||||
| if (r == 1) | if (r == 1) | ||||
| pa.add (-omegap * std::sinh (v0 * 0.5 * MathConstants<double>::pi)); | |||||
| pa.add (-omegap * std::sinh (v0 * halfPi)); | |||||
| for (int i = 1; i <= L; ++i) | for (int i = 1; i <= L; ++i) | ||||
| { | { | ||||
| auto ui = (2 * i - 1.0) / (double) N; | auto ui = (2 * i - 1.0) / (double) N; | ||||
| pa.add (omegap * j * std::cos ((ui - j * v0) * 0.5 * MathConstants<double>::pi)); | |||||
| pa.add (omegap * j * std::cos ((ui - j * v0) * halfPi)); | |||||
| } | } | ||||
| } | } | ||||
| else if (type == 2) | else if (type == 2) | ||||
| { | { | ||||
| auto v0 = std::asinh (epss) / (N * 0.5 * MathConstants<double>::pi); | |||||
| auto v0 = std::asinh (epss) / (N * halfPi); | |||||
| if (r == 1) | if (r == 1) | ||||
| pa.add(-1.0 / (k / omegap * std::sinh (v0 * 0.5 * MathConstants<double>::pi))); | |||||
| pa.add(-1.0 / (k / omegap * std::sinh (v0 * halfPi))); | |||||
| for (int i = 1; i <= L; ++i) | for (int i = 1; i <= L; ++i) | ||||
| { | { | ||||
| auto ui = (2 * i - 1.0) / (double) N; | auto ui = (2 * i - 1.0) / (double) N; | ||||
| pa.add (1.0 / (k / omegap * j * std::cos ((ui - j * v0) * 0.5 * MathConstants<double>::pi))); | |||||
| za.add (1.0 / (k / omegap * j * std::cos (ui * 0.5 * MathConstants<double>::pi))); | |||||
| pa.add (1.0 / (k / omegap * j * std::cos ((ui - j * v0) * halfPi))); | |||||
| za.add (1.0 / (k / omegap * j * std::cos (ui * halfPi))); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -591,7 +592,7 @@ typename FilterDesign<FloatType>::IIRPolyphaseAllpassStructure | |||||
| while (std::abs (delta) > 1e-100) | while (std::abs (delta) > 1e-100) | ||||
| { | { | ||||
| delta = std::pow (-1, m) * std::pow (q, m * m) | delta = std::pow (-1, m) * std::pow (q, m * m) | ||||
| * std::cos (2 * m * MathConstants<double>::pi * i / (double) n); | |||||
| * std::cos (m * MathConstants<double>::twoPi * i / (double) n); | |||||
| den += delta; | den += delta; | ||||
| ++m; | ++m; | ||||
| } | } | ||||
| @@ -53,7 +53,7 @@ void SpecialFunctions::ellipticIntegralK (double k, double& K, double& Kp) noexc | |||||
| { | { | ||||
| constexpr int M = 4; | constexpr int M = 4; | ||||
| K = MathConstants<double>::pi * 0.5; | |||||
| K = MathConstants<double>::halfPi; | |||||
| auto lastK = k; | auto lastK = k; | ||||
| for (int i = 0; i < M; ++i) | for (int i = 0; i < M; ++i) | ||||
| @@ -62,7 +62,7 @@ void SpecialFunctions::ellipticIntegralK (double k, double& K, double& Kp) noexc | |||||
| K *= 1 + lastK; | K *= 1 + lastK; | ||||
| } | } | ||||
| Kp = MathConstants<double>::pi * 0.5; | |||||
| Kp = MathConstants<double>::halfPi; | |||||
| auto last = std::sqrt (1 - k * k); | auto last = std::sqrt (1 - k * k); | ||||
| for (int i = 0; i < M; ++i) | for (int i = 0; i < M; ++i) | ||||
| @@ -86,7 +86,8 @@ Complex<double> SpecialFunctions::cde (Complex<double> u, double k) noexcept | |||||
| *++kei = next; | *++kei = next; | ||||
| } | } | ||||
| std::complex<double> last = std::cos (0.5 * u * MathConstants<double>::pi); | |||||
| // NB: the spurious cast to double here is a workaround for a very odd link-time failure | |||||
| std::complex<double> last = std::cos (u * (double) MathConstants<double>::halfPi); | |||||
| for (int i = M - 1; i >= 0; --i) | for (int i = M - 1; i >= 0; --i) | ||||
| last = (1.0 + ke[i + 1]) / (1.0 / last + ke[i + 1] * last); | last = (1.0 + ke[i + 1]) / (1.0 / last + ke[i + 1] * last); | ||||
| @@ -108,7 +109,8 @@ Complex<double> SpecialFunctions::sne (Complex<double> u, double k) noexcept | |||||
| *++kei = next; | *++kei = next; | ||||
| } | } | ||||
| std::complex<double> last = std::sin (0.5 * u * MathConstants<double>::pi); | |||||
| // NB: the spurious cast to double here is a workaround for a very odd link-time failure | |||||
| std::complex<double> last = std::sin (u * (double) MathConstants<double>::halfPi); | |||||
| for (int i = M - 1; i >= 0; --i) | for (int i = M - 1; i >= 0; --i) | ||||
| last = (1.0 + ke[i + 1]) / (1.0 / last + ke[i + 1] * last); | last = (1.0 + ke[i + 1]) / (1.0 / last + ke[i + 1] * last); | ||||
| @@ -155,7 +155,7 @@ void LadderFilter<Type>::setSampleRate (Type newValue) noexcept | |||||
| jassert (newValue > Type (0)); | jassert (newValue > Type (0)); | ||||
| cutoffFreqScaler = Type (-2.0 * juce::MathConstants<double>::pi) / newValue; | cutoffFreqScaler = Type (-2.0 * juce::MathConstants<double>::pi) / newValue; | ||||
| static constexpr Type smootherRampTimeSec (0.05); | |||||
| static constexpr Type smootherRampTimeSec = Type (0.05); | |||||
| cutoffTransformSmoother.reset (newValue, smootherRampTimeSec); | cutoffTransformSmoother.reset (newValue, smootherRampTimeSec); | ||||
| scaledResonanceSmoother.reset (newValue, smootherRampTimeSec); | scaledResonanceSmoother.reset (newValue, smootherRampTimeSec); | ||||
| @@ -784,7 +784,7 @@ void Path::addBubble (Rectangle<float> bodyArea, | |||||
| } | } | ||||
| lineTo (bodyArea.getRight() - cornerSizeW, bodyArea.getY()); | lineTo (bodyArea.getRight() - cornerSizeW, bodyArea.getY()); | ||||
| addArc (bodyArea.getRight() - cornerSizeW2, bodyArea.getY(), cornerSizeW2, cornerSizeH2, 0, MathConstants<float>::pi * 0.5f); | |||||
| addArc (bodyArea.getRight() - cornerSizeW2, bodyArea.getY(), cornerSizeW2, cornerSizeH2, 0, MathConstants<float>::halfPi); | |||||
| if (Rectangle<float> (bodyArea.getRight(), targetLimit.getY(), | if (Rectangle<float> (bodyArea.getRight(), targetLimit.getY(), | ||||
| maximumArea.getRight() - bodyArea.getRight(), targetLimit.getHeight()).contains (arrowTip)) | maximumArea.getRight() - bodyArea.getRight(), targetLimit.getHeight()).contains (arrowTip)) | ||||
| @@ -795,7 +795,7 @@ void Path::addBubble (Rectangle<float> bodyArea, | |||||
| } | } | ||||
| lineTo (bodyArea.getRight(), bodyArea.getBottom() - cornerSizeH); | lineTo (bodyArea.getRight(), bodyArea.getBottom() - cornerSizeH); | ||||
| addArc (bodyArea.getRight() - cornerSizeW2, bodyArea.getBottom() - cornerSizeH2, cornerSizeW2, cornerSizeH2, MathConstants<float>::pi * 0.5f, MathConstants<float>::pi); | |||||
| addArc (bodyArea.getRight() - cornerSizeW2, bodyArea.getBottom() - cornerSizeH2, cornerSizeW2, cornerSizeH2, MathConstants<float>::halfPi, MathConstants<float>::pi); | |||||
| if (Rectangle<float> (targetLimit.getX(), bodyArea.getBottom(), | if (Rectangle<float> (targetLimit.getX(), bodyArea.getBottom(), | ||||
| targetLimit.getWidth(), maximumArea.getBottom() - bodyArea.getBottom()).contains (arrowTip)) | targetLimit.getWidth(), maximumArea.getBottom() - bodyArea.getBottom()).contains (arrowTip)) | ||||
| @@ -1669,7 +1669,7 @@ private: | |||||
| if (uy < 0) | if (uy < 0) | ||||
| startAngle = -startAngle; | startAngle = -startAngle; | ||||
| startAngle += MathConstants<double>::pi * 0.5; | |||||
| startAngle += MathConstants<double>::halfPi; | |||||
| deltaAngle = acos (jlimit (-1.0, 1.0, ((ux * vx) + (uy * vy)) | deltaAngle = acos (jlimit (-1.0, 1.0, ((ux * vx) + (uy * vy)) | ||||
| / (length * juce_hypot (vx, vy)))); | / (length * juce_hypot (vx, vy)))); | ||||
| @@ -2024,10 +2024,10 @@ void LookAndFeel_V2::drawGroupComponentOutline (Graphics& g, int width, int heig | |||||
| p.startNewSubPath (x + textX + textW, y); | p.startNewSubPath (x + textX + textW, y); | ||||
| p.lineTo (x + w - cs, y); | p.lineTo (x + w - cs, y); | ||||
| p.addArc (x + w - cs2, y, cs2, cs2, 0, MathConstants<float>::pi * 0.5f); | |||||
| p.addArc (x + w - cs2, y, cs2, cs2, 0, MathConstants<float>::halfPi); | |||||
| p.lineTo (x + w, y + h - cs); | p.lineTo (x + w, y + h - cs); | ||||
| p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, MathConstants<float>::pi * 0.5f, MathConstants<float>::pi); | |||||
| p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, MathConstants<float>::halfPi, MathConstants<float>::pi); | |||||
| p.lineTo (x + cs, y + h); | p.lineTo (x + cs, y + h); | ||||
| p.addArc (x, y + h - cs2, cs2, cs2, MathConstants<float>::pi, MathConstants<float>::pi * 1.5f); | p.addArc (x, y + h - cs2, cs2, cs2, MathConstants<float>::pi, MathConstants<float>::pi * 1.5f); | ||||
| @@ -2948,7 +2948,7 @@ void LookAndFeel_V2::drawGlassPointer (Graphics& g, | |||||
| p.lineTo (x, y + diameter * 0.6f); | p.lineTo (x, y + diameter * 0.6f); | ||||
| p.closeSubPath(); | p.closeSubPath(); | ||||
| p.applyTransform (AffineTransform::rotation (direction * (MathConstants<float>::pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); | |||||
| p.applyTransform (AffineTransform::rotation (direction * MathConstants<float>::halfPi, x + diameter * 0.5f, y + diameter * 0.5f)); | |||||
| { | { | ||||
| ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, | ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, | ||||
| @@ -1071,8 +1071,8 @@ void LookAndFeel_V4::drawRotarySlider (Graphics& g, int x, int y, int width, int | |||||
| } | } | ||||
| auto thumbWidth = lineW * 2.0f; | auto thumbWidth = lineW * 2.0f; | ||||
| Point<float> thumbPoint (bounds.getCentreX() + arcRadius * std::cos (toAngle - MathConstants<float>::pi * 0.5f), | |||||
| bounds.getCentreY() + arcRadius * std::sin (toAngle - MathConstants<float>::pi * 0.5f)); | |||||
| Point<float> thumbPoint (bounds.getCentreX() + arcRadius * std::cos (toAngle - MathConstants<float>::halfPi), | |||||
| bounds.getCentreY() + arcRadius * std::sin (toAngle - MathConstants<float>::halfPi)); | |||||
| g.setColour (slider.findColour (Slider::thumbColourId)); | g.setColour (slider.findColour (Slider::thumbColourId)); | ||||
| g.fillEllipse (Rectangle<float> (thumbWidth, thumbWidth).withCentre (thumbPoint)); | g.fillEllipse (Rectangle<float> (thumbWidth, thumbWidth).withCentre (thumbPoint)); | ||||
| @@ -1089,8 +1089,8 @@ void LookAndFeel_V4::drawPointer (Graphics& g, const float x, const float y, con | |||||
| p.lineTo (x, y + diameter * 0.6f); | p.lineTo (x, y + diameter * 0.6f); | ||||
| p.closeSubPath(); | p.closeSubPath(); | ||||
| p.applyTransform (AffineTransform::rotation (direction * (MathConstants<float>::pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); | |||||
| p.applyTransform (AffineTransform::rotation (direction * MathConstants<float>::halfPi, | |||||
| x + diameter * 0.5f, y + diameter * 0.5f)); | |||||
| g.setColour (colour); | g.setColour (colour); | ||||
| g.fillPath (p); | g.fillPath (p); | ||||
| } | } | ||||