First move the C2 and H2 pedicate and construction files operating on the RT

This commit is contained in:
Andreas Fabri 2016-03-25 10:52:24 +01:00 committed by Jane Tournois
parent 9e94ee6178
commit 7d35bb0a8b
8 changed files with 133 additions and 106 deletions

View File

@ -418,6 +418,65 @@ scaled_distance_to_lineC2( const FT &px, const FT &py,
return determinant<FT>(px-rx, py-ry, qx-rx, qy-ry);
}
template < class RT >
void
weighted_circumcenter_translateC2(const RT &dqx, const RT &dqy, const RT &dqw,
const RT &drx, const RT &dry, const RT &drw,
RT &dcx, RT &dcy)
{
// Given 3 points P, Q, R, this function takes as input:
// qx-px, qy-py,qw-pw, rx-px, ry-py, rw-pw. And returns cx-px, cy-py,
// where (cx, cy) are the coordinates of the circumcenter C.
// What we do is intersect the radical axis
RT r2 = CGAL_NTS square(drx) + CGAL_NTS square(dry) - drw;
RT q2 = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - dqw;
RT den = RT(2) * determinant(dqx, dqy, drx, dry);
// The 3 points aren't collinear.
// Hopefully, this is already checked at the upper level.
CGAL_assertion ( den != RT(0) );
// One possible optimization here is to precompute 1/den, to avoid one
// division. However, we loose precision, and it's maybe not worth it (?).
dcx = determinant (dry, dqy, r2, q2) / den;
dcy = - determinant (drx, dqx, r2, q2) / den;
}
//template < class RT >
template < class RT, class We>
void
weighted_circumcenterC2( const RT &px, const RT &py, const We &pw,
const RT &qx, const RT &qy, const We &qw,
const RT &rx, const RT &ry, const We &rw,
RT &x, RT &y )
{
RT dqw = RT(qw-pw);
RT drw = RT(rw-pw);
weighted_circumcenter_translateC2(qx-px, qy-py, dqw,rx-px, ry-py,drw,x, y);
x += px;
y += py;
}
template < class RT , class We>
void
radical_axisC2(const RT &px, const RT &py, const We &pw,
const RT &qx, const RT &qy, const We &qw,
RT &a, RT &b, RT& c )
{
a = RT(2)*(px - qx);
b = RT(2)*(py - qy);
c = - CGAL_NTS square(px) - CGAL_NTS square(py)
+ CGAL_NTS square(qx) + CGAL_NTS square(qy)
+RT(pw) - RT(qw);
}
} //namespace CGAL
#endif // CGAL_CONSTRUCTIONS_KERNEL_FTC2_H

View File

@ -635,6 +635,71 @@ side_of_oriented_lineC2(const FT &a, const FT &b, const FT &c,
return CGAL_NTS sign(a*x+b*y+c);
}
template <class FT>
Comparison_result
compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt,
const FT& qx, const FT& qy, const FT& qwt,
const FT& rx, const FT& ry)
{
// returns SMALLER if r is closer to p w.r.t. the power metric
FT d1 = CGAL_NTS square(rx - px) + CGAL_NTS square(ry - py) - pwt;
FT d2 = CGAL_NTS square(rx - qx) + CGAL_NTS square(ry - qy) - qwt;
return CGAL_NTS compare(d1, d2);
}
template <class FT>
Oriented_side
power_testC2( const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt,
const FT &rx, const FT &ry, const FT &rwt,
const FT &tx, const FT &ty, const FT &twt)
{
// Note: maybe this can be further optimized like the usual in_circle() ?
// We translate the 4 points so that T becomes the origin.
FT dpx = px - tx;
FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx;
FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
FT drx = rx - tx;
FT dry = ry - ty;
FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt;
return sign_of_determinant(dpx, dpy, dpz,
dqx, dqy, dqz,
drx, dry, drz);
}
template <class FT>
Oriented_side
power_testC2( const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt,
const FT &tx, const FT &ty, const FT &twt)
{
// Same translation as above.
FT dpx = px - tx;
FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx;
FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
// We do an orthogonal projection on the (x) axis, if possible.
Comparison_result cmpx = CGAL_NTS compare(px, qx);
if (cmpx != EQUAL)
return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz);
// If not possible, then on the (y) axis.
Comparison_result cmpy = CGAL_NTS compare(py, qy);
return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz);
}
} //namespace CGAL
#endif // CGAL_PREDICATES_KERNEL_FTC2_H

View File

@ -69,6 +69,7 @@
#include <CGAL/Homogeneous/distance_predicatesH3.h>
#include <CGAL/Homogeneous/predicates_on_pointsH3.h>
#include <CGAL/Homogeneous/predicates_on_pointsH2.h>
#include <CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Homogeneous/function_objects.h>

View File

@ -1,10 +1,10 @@
// Copyright (c) 1999 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.

View File

@ -30,6 +30,7 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/predicates/sign_of_determinant.h>
#include <CGAL/Homogeneous/Regular_triangulation_rtH3.h>
#include <CGAL/Homogeneous/Regular_triangulation_rtH2.h>
namespace CGAL {
@ -4285,6 +4286,9 @@ namespace HomogeneousKernelFunctors {
return s.rep().orientation();
}
};
template < typename K >
class Power_side_of_power_sphere_3
{

View File

@ -29,11 +29,6 @@
#include <CGAL/Kernel_traits.h>
#include <CGAL/representation_tags.h>
#include <CGAL/predicates/Regular_triangulation_ftC2.h>
#include <CGAL/constructions_on_weighted_points_cartesian_2.h>
#include <CGAL/predicates/Regular_triangulation_rtH2.h>
#include <CGAL/constructions_on_weighted_points_homogeneous_2.h>
namespace CGAL {

View File

@ -1,97 +0,0 @@
// Copyright (c) 1999 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Sylvain Pion
// Mariette Yvinec <Mariette.Yvinec@sophia.inria.fr>
#ifndef CGAL_REGULAR_TRIANGULATION_FTC2_H
#define CGAL_REGULAR_TRIANGULATION_FTC2_H
#include <CGAL/number_utils.h>
// This file contains the low level cartesian predicates
// used by the 2D regular triangulation.
namespace CGAL {
template <class FT>
Comparison_result
compare_power_distanceC2(const FT& px, const FT& py, const FT& pwt,
const FT& qx, const FT& qy, const FT& qwt,
const FT& rx, const FT& ry)
{
// returns SMALLER if r is closer to p w.r.t. the power metric
FT d1 = CGAL_NTS square(rx - px) + CGAL_NTS square(ry - py) - pwt;
FT d2 = CGAL_NTS square(rx - qx) + CGAL_NTS square(ry - qy) - qwt;
return CGAL_NTS compare(d1, d2);
}
template <class FT>
Oriented_side
power_testC2( const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt,
const FT &rx, const FT &ry, const FT &rwt,
const FT &tx, const FT &ty, const FT &twt)
{
// Note: maybe this can be further optimized like the usual in_circle() ?
// We translate the 4 points so that T becomes the origin.
FT dpx = px - tx;
FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx;
FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
FT drx = rx - tx;
FT dry = ry - ty;
FT drz = CGAL_NTS square(drx) + CGAL_NTS square(dry) - rwt + twt;
return sign_of_determinant(dpx, dpy, dpz,
dqx, dqy, dqz,
drx, dry, drz);
}
template <class FT>
Oriented_side
power_testC2( const FT &px, const FT &py, const FT &pwt,
const FT &qx, const FT &qy, const FT &qwt,
const FT &tx, const FT &ty, const FT &twt)
{
// Same translation as above.
FT dpx = px - tx;
FT dpy = py - ty;
FT dpz = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) - pwt + twt;
FT dqx = qx - tx;
FT dqy = qy - ty;
FT dqz = CGAL_NTS square(dqx) + CGAL_NTS square(dqy) - qwt + twt;
// We do an orthogonal projection on the (x) axis, if possible.
Comparison_result cmpx = CGAL_NTS compare(px, qx);
if (cmpx != EQUAL)
return cmpx * sign_of_determinant(dpx, dpz, dqx, dqz);
// If not possible, then on the (y) axis.
Comparison_result cmpy = CGAL_NTS compare(py, qy);
return cmpy * sign_of_determinant(dpy, dpz, dqy, dqz);
}
} //namespace CGAL
#endif // CGAL_REGULAR_TRIANGULATION_FTC2_H