#pragma once
#include "../../util/util/lib.hpp"
namespace tifa_libs {
// calculate area of triangle by the length of 3 edges
// numerical stability improved
template <class FP>
CEXP FP area_T_abc(FP a, FP b, FP c) NE {
if (a < b) swap(a, b);
if (a < c) swap(a, c);
if (b < c) swap(b, c);
return std::sqrt(a + (b + c)) * std::sqrt(c - (a - b)) * std::sqrt(c + (a - b)) * std::sqrt(a + (b - c)) / 4;
}
} // namespace tifa_libs
#line 2 "src/geo2d/area_triedges/lib.hpp"
#line 2 "src/util/util/lib.hpp"
// https://github.com/Tiphereth-A/CP-lib
#include <bits/extc++.h>
// clang-format off
namespace tifa_libs {
#define CEXP constexpr
#define CEXPE constexpr explicit
#define CR const&
#define CP const*
#define PC *const
#define CPC const*const
#define TPN typename
#define NE noexcept
#define CNE const noexcept
#define ND [[nodiscard]]
#define cT_(...) std::conditional_t<sizeof(__VA_ARGS__) <= sizeof(size_t) * 2, __VA_ARGS__, __VA_ARGS__ CR>
// NOLINTNEXTLINE(misc-const-correctness)
#define flt_(T, i, l, r, ...) for (T i = (l), i##e = (r)__VA_OPT__(, ) __VA_ARGS__; i < i##e; ++i)
#define retif_(cond, if_true, ...) if cond return if_true __VA_OPT__(; else return __VA_ARGS__)
#ifdef ONLINE_JUDGE
#undef assert
#define assert(x) 42
#endif
using namespace std::ranges;
using namespace std::literals;
template <class T>
CEXP T abs(T x) NE { retif_((x < 0), -x, x); }
} // namespace tifa_libs
// clang-format on
#line 4 "src/geo2d/area_triedges/lib.hpp"
namespace tifa_libs {
// calculate area of triangle by the length of 3 edges
// numerical stability improved
template <class FP>
CEXP FP area_T_abc(FP a, FP b, FP c) NE {
if (a < b) swap(a, b);
if (a < c) swap(a, c);
if (b < c) swap(b, c);
return std::sqrt(a + (b + c)) * std::sqrt(c - (a - b)) * std::sqrt(c + (a - b)) * std::sqrt(a + (b - c)) / 4;
}
} // namespace tifa_libs