From 4e40afd8f16773c85a8124b72665754721189837 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Thu, 9 Nov 2023 09:37:10 +1300 Subject: [PATCH] Rename for consistency -> "Angle::SinCos" -> "Angle::sinCos" --- NEWS.md | 2 +- include/geos/algorithm/Angle.h | 2 +- src/operation/buffer/OffsetSegmentGenerator.cpp | 6 +++--- src/util/GeometricShapeFactory.cpp | 6 +++--- tests/unit/algorithm/AngleTest.cpp | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index a77bd1d326..c58399ad5d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ 20xx-xx-xx - New things: - - Add Angle::SinCos to avoid small errors, e.g. with buffer operations (GH-978, Mike Taves) + - Add Angle::sinCos to avoid small errors, e.g. with buffer operations (GH-978, Mike Taves) - Breaking Changes diff --git a/include/geos/algorithm/Angle.h b/include/geos/algorithm/Angle.h index 2c1a5edaba..f4f2f604e9 100644 --- a/include/geos/algorithm/Angle.h +++ b/include/geos/algorithm/Angle.h @@ -228,7 +228,7 @@ class GEOS_DLL Angle { /// @param rSin the result of sin(ang) /// @param rCos the result of cos(ang) /// - static inline void SinCos(const double ang, double& rSin, double& rCos) { + static inline void sinCos(const double ang, double& rSin, double& rCos) { // calculate both; may be optimized with FSINCOS instruction rSin = std::sin(ang); rCos = std::cos(ang); diff --git a/src/operation/buffer/OffsetSegmentGenerator.cpp b/src/operation/buffer/OffsetSegmentGenerator.cpp index db7061b276..41e22a91c1 100644 --- a/src/operation/buffer/OffsetSegmentGenerator.cpp +++ b/src/operation/buffer/OffsetSegmentGenerator.cpp @@ -222,7 +222,7 @@ OffsetSegmentGenerator::addLineEndCap(const Coordinate& p0, const Coordinate& p1 // segment endpoints Coordinate squareCapSideOffset; double sinangle, cosangle; - Angle::SinCos(angle, sinangle, cosangle); + Angle::sinCos(angle, sinangle, cosangle); squareCapSideOffset.x = fabs(distance) * cosangle; squareCapSideOffset.y = fabs(distance) * sinangle; @@ -283,7 +283,7 @@ OffsetSegmentGenerator::addDirectedFillet(const Coordinate& p, double startAngle double sinangle, cosangle; Coordinate pt; for (int i = 0; i < nSegs; i++) { - Angle::SinCos(startAngle + directionFactor * i * angleInc, sinangle, cosangle); + Angle::sinCos(startAngle + directionFactor * i * angleInc, sinangle, cosangle); pt.x = p.x + radius * cosangle; pt.y = p.y + radius * sinangle; segList.addPt(pt); @@ -583,7 +583,7 @@ Coordinate OffsetSegmentGenerator::project(const Coordinate& pt, double d, double dir) { double sindir, cosdir; - Angle::SinCos(dir, sindir, cosdir); + Angle::sinCos(dir, sindir, cosdir); double x = pt.x + d * cosdir; double y = pt.y + d * sindir; return Coordinate(x, y); diff --git a/src/util/GeometricShapeFactory.cpp b/src/util/GeometricShapeFactory.cpp index f4d714650b..4a63e0ac3e 100644 --- a/src/util/GeometricShapeFactory.cpp +++ b/src/util/GeometricShapeFactory.cpp @@ -138,7 +138,7 @@ GeometricShapeFactory::createCircle() uint32_t iPt = 0; double sinang, cosang; for(uint32_t i = 0; i < nPts; i++) { - Angle::SinCos(i * Angle::PI_TIMES_2 / nPts, sinang, cosang); + Angle::sinCos(i * Angle::PI_TIMES_2 / nPts, sinang, cosang); double x = xRadius * cosang + centreX; double y = yRadius * sinang + centreY; (*pts)[iPt++] = coord(x, y); @@ -170,7 +170,7 @@ GeometricShapeFactory::createArc(double startAng, double angExtent) uint32_t iPt = 0; double sinang, cosang; for(uint32_t i = 0; i < nPts; i++) { - Angle::SinCos(startAng + i * angInc, sinang, cosang); + Angle::sinCos(startAng + i * angInc, sinang, cosang); double x = xRadius * cosang + centreX; double y = yRadius * sinang + centreY; (*pts)[iPt++] = coord(x, y); @@ -201,7 +201,7 @@ GeometricShapeFactory::createArcPolygon(double startAng, double angExtent) (*pts)[iPt++] = coord(centreX, centreY); double sinang, cosang; for(uint32_t i = 0; i < nPts; i++) { - Angle::SinCos(startAng + i * angInc, sinang, cosang); + Angle::sinCos(startAng + i * angInc, sinang, cosang); double x = xRadius * cosang + centreX; double y = yRadius * sinang + centreY; (*pts)[iPt++] = coord(x, y); diff --git a/tests/unit/algorithm/AngleTest.cpp b/tests/unit/algorithm/AngleTest.cpp index 372b8ebeb0..02eae99e89 100644 --- a/tests/unit/algorithm/AngleTest.cpp +++ b/tests/unit/algorithm/AngleTest.cpp @@ -174,7 +174,7 @@ void object::test<6> for (int angdeg = -720; angdeg <= 720; angdeg++) { const double ang = Angle::toRadians(angdeg); - Angle::SinCos(ang, rSin, rCos); + Angle::sinCos(ang, rSin, rCos); double cSin = std::sin(ang); double cCos = std::cos(ang); @@ -192,7 +192,7 @@ void object::test<6> // use radian increments that don't snap to exact degrees or zero for (double angrad = -6.3; angrad < 6.3; angrad += 0.013) { - Angle::SinCos(angrad, rSin, rCos); + Angle::sinCos(angrad, rSin, rCos); ensure_equals(std::to_string(angrad), rSin, std::sin(angrad)); ensure_equals(std::to_string(angrad), rCos, std::cos(angrad));