Skip to content

Commit

Permalink
Merge branch 'google3'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmr committed Feb 2, 2018
2 parents 27b8441 + df4faa9 commit cdf1a05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ target_link_libraries(
${GFLAGS_LIBRARIES} ${GLOG_LIBRARIES} ${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})

# Allow other CMake projects to use this one with:
# list(APPEND CMAKE_MODULE_PATH "<path_to_s2geometry_folder>/third_party/cmake")
# add_subdirectory(<path_to_s2geometry_folder> s2geometry)
# target_link_libraries(<target_name> s2)
target_include_directories(s2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)

# We don't need to install all headers, only those
# transitively included by s2 headers we are exporting.
install(FILES src/s2/_fp_contract_off.h
Expand Down
9 changes: 5 additions & 4 deletions src/s2/s2loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "s2/_fp_contract_off.h"
#include "s2/mutable_s2shape_index.h"
#include "s2/s1angle.h"
#include "s2/s1chord_angle.h"
#include "s2/s2debug.h"
#include "s2/s2latlng_rect.h"
#include "s2/s2pointutil.h"
Expand Down Expand Up @@ -729,7 +730,7 @@ T S2Loop::GetSurfaceIntegral(T f_tri(const S2Point&, const S2Point&,
// The exact value is fairly arbitrary since it depends on the stability of
// the "f_tri" function. The value below is quite conservative but could be
// reduced further if desired.
static const double kMaxLength = M_PI - 1e-5;
const auto kMaxLength = S1ChordAngle::Radians(M_PI - 1e-5);

// The default constructor for T must initialize the value to zero.
// (This is true for built-in types such as "double".)
Expand All @@ -746,18 +747,18 @@ T S2Loop::GetSurfaceIntegral(T f_tri(const S2Point&, const S2Point&,
// 2. Either O == V_0, or O is approximately perpendicular to V_0.
// 3. "sum" is the oriented integral of f over the area defined by
// (O, V_0, V_1, ..., V_i).
DCHECK(i == 1 || origin.Angle(vertex(i)) < kMaxLength);
DCHECK(i == 1 || S1ChordAngle(origin, vertex(i)) < kMaxLength);
DCHECK(origin == vertex(0) || std::fabs(origin.DotProd(vertex(0))) < 1e-15);

if (vertex(i+1).Angle(origin) > kMaxLength) {
if (S1ChordAngle(vertex(i + 1), origin) > kMaxLength) {
// We are about to create an unstable edge, so choose a new origin O'
// for the triangle fan.
S2Point old_origin = origin;
if (origin == vertex(0)) {
// The following point is well-separated from V_i and V_0 (and
// therefore V_i+1 as well).
origin = S2::RobustCrossProd(vertex(0), vertex(i)).Normalize();
} else if (vertex(i).Angle(vertex(0)) < kMaxLength) {
} else if (S1ChordAngle(vertex(i), vertex(0)) < kMaxLength) {
// All edges of the triangle (O, V_0, V_i) are stable, so we can
// revert to using V_0 as the origin.
origin = vertex(0);
Expand Down
2 changes: 1 addition & 1 deletion src/s2/third_party/absl/base/log_severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ constexpr const char* LogSeverityName(absl::LogSeverity s) {
: s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
}

// Note that out-of-range large severities normalize to kError, not kFatal.
// Note that out-of-range severities normalize to kInfo or kError, never kFatal.
constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) {
return s < absl::LogSeverity::kInfo
? absl::LogSeverity::kInfo
Expand Down

0 comments on commit cdf1a05

Please # to comment.