Skip to content

Commit

Permalink
#7 Refactor circumcenter calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-ogre committed Aug 22, 2023
1 parent 23b928b commit 498b7eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CDT/include/CDTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ CDT_EXPORT bool isEncroachingOnEdge(

/// Position of ABC triangle circumcenter
template <typename T>
CDT_EXPORT V2d<T> circumcenter(V2d<T> a, V2d<T> b, const V2d<T>& c);
CDT_EXPORT V2d<T> circumcenter(V2d<T> a, V2d<T> b, V2d<T> c);

/// Doubled surface area of a triangle ABC
template <typename T>
Expand Down
11 changes: 6 additions & 5 deletions CDT/include/CDTUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,16 @@ bool isEncroachingOnEdge(
}

template <typename T>
V2d<T> circumcenter(V2d<T> a, V2d<T> b, const V2d<T>& c)
V2d<T> circumcenter(V2d<T> a, V2d<T> b, V2d<T> c)
{
const T denom = 0.5 / orient2D(c, a, b);
const T denom = T(2) * orient2D(a, b, c);
assert(denom != T(0));
a.x -= c.x, a.y -= c.y;
b.x -= c.x, b.y -= c.y;
const T aLenSq = lengthSquared(a), bLenSq = lengthSquared(b);
return V2d<T>::make(
c.x + (b.y * aLenSq - a.y * bLenSq) * denom,
c.y + (a.x * bLenSq - b.x * aLenSq) * denom);
c.x += (b.y * aLenSq - a.y * bLenSq) / denom;
c.y += (a.x * bLenSq - b.x * aLenSq) / denom;
return c;
}

template <typename T>
Expand Down

0 comments on commit 498b7eb

Please sign in to comment.