Added tests for Weighted_point_23 and related functions

This commit is contained in:
Mael Rouxel-Labbé 2017-04-07 03:44:12 +02:00
parent 2ae17980fe
commit 18169be82a
14 changed files with 675 additions and 14 deletions

View File

@ -26,8 +26,10 @@
#include "_test_cls_vector_2.h"
#include "_test_fct_vector_2.h"
#include "_test_cls_point_2.h"
#include "_test_cls_weighted_point_2.h"
#include "_test_fct_point_vector_2.h"
#include "_test_fct_point_2.h"
#include "_test_fct_weighted_point_2.h"
#include "_test_fct_line_2.h"
#include "_test_fct_segment_2.h"
#include "_test_further_fct_point_2.h"
@ -52,8 +54,10 @@ _test_2(const R& r)
_test_cls_vector_2(r)
&& _test_fct_vector_2(r)
&& _test_cls_point_2(r)
&& _test_cls_weighted_point_2(r)
&& _test_fct_point_vector_2(r)
&& _test_fct_point_2(r)
&& _test_fct_weighted_point_2(r)
&& _test_fct_line_2(r)
&& _test_fct_segment_2(r)
&& _test_further_fct_point_2(r)

View File

@ -26,8 +26,10 @@
#include "_test_cls_vector_3.h"
#include "_test_fct_vector_3.h"
#include "_test_cls_point_3.h"
#include "_test_cls_weighted_point_3.h"
#include "_test_fct_point_vector_3.h"
#include "_test_fct_point_3.h"
#include "_test_fct_weighted_point_3.h"
#include "_test_fct_plane_3.h"
#include "_test_further_fct_point_plane_3.h"
#include "_test_cls_direction_3.h"
@ -49,8 +51,10 @@ _test_3(const R& r)
_test_cls_vector_3(r)
&& _test_fct_vector_3(r)
&& _test_cls_point_3(r)
&& _test_cls_weighted_point_3(r)
&& _test_fct_point_vector_3(r)
&& _test_fct_point_3(r)
&& _test_fct_weighted_point_3(r)
&& _test_fct_plane_3(r)
&& _test_further_fct_point_plane_3(r)
&& _test_cls_direction_3(r)

View File

@ -23,8 +23,17 @@
#ifndef CGAL__TEST_CLS_POINT_2_H
#define CGAL__TEST_CLS_POINT_2_H
#include <CGAL/assertions.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Origin.h>
#include <CGAL/Vector_2.h>
#include <CGAL/Weighted_point_2.h>
#include <boost/type_traits/is_convertible.hpp>
#include <cassert>
#include <iostream>
template <class R>
bool
@ -52,6 +61,9 @@ _test_cls_point_2(const R& )
CGAL::Point_2<R> p6( p5 );
p1 = p4;
CGAL::Weighted_point_2<R> wp(p1);
CGAL::Point_2<R> p7(wp);
std::cout << '.';
assert( p3 == CGAL::Point_2<R>(FT(n1), FT(n2)) );

View File

@ -24,7 +24,13 @@
#define CGAL__TEST_CLS_POINT_3_H
#include <CGAL/Bbox_3.h>
#include <CGAL/Point_3.h>
#include <CGAL/Origin.h>
#include <CGAL/Vector_3.h>
#include <CGAL/Weighted_point_3.h>
#include <cassert>
#include <iostream>
template <class R>
bool
@ -53,6 +59,9 @@ _test_cls_point_3(const R& )
CGAL::Point_3<R> p6( p5 );
p1 = p4;
CGAL::Weighted_point_3<R> wp(p1);
CGAL::Point_3<R> p7(wp);
std::cout << '.';
assert( p3 == CGAL::Point_3<R>(FT(n1), FT(n2), FT(n3)) );

View File

@ -0,0 +1,80 @@
// Copyright (c) 1999
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). 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 Lesser 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 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) : Mael Rouxel-Labbé
#ifndef CGAL__TEST_CLS_WEIGHTED_POINT_2_H
#define CGAL__TEST_CLS_WEIGHTED_POINT_2_H
#include <CGAL/Origin.h>
#include <CGAL/Point_2.h>
#include <CGAL/use.h>
#include <CGAL/Weighted_point_2.h>
#include <cassert>
#include <iostream>
using CGAL::internal::use;
template <class R>
bool _test_cls_weighted_point_2(const R& )
{
std::cout << "Testing class Weighted_point_2" ;
typedef typename R::RT RT;
typedef typename R::FT FT;
RT n1(-35 );
RT n2( 50 );
RT n4( 5);
FT iw = -1;
CGAL::Point_2<R> p0(n1, n2, n4);
// constructions
typename R::Weighted_point_2 iwp;
CGAL::Weighted_point_2<R> wp0; // default
CGAL::Weighted_point_2<R> wp1(CGAL::ORIGIN); // with origin
CGAL::Weighted_point_2<R> wp2(p0); // with Point_2
CGAL::Weighted_point_2<R> wp3(p0, iw); // with Point_2 and weight
CGAL::Weighted_point_2<R> wp4(iwp); // with R::Weighted_point_2
CGAL::Weighted_point_2<R> wp5(wp3); // with CGAL::Weighted_point_2< R >
CGAL::Weighted_point_2<R> wp6(n1, n2); // with coordinates
use(wp0); use(wp4); use(wp5);
// assignement
wp1 = wp6;
std::cout << ".";
// accessors
CGAL::Point_2<R> p1 = wp2.point();
assert(p1 == p0);
FT w = wp3.weight();
assert(w == iw);
// no need to test the other operations as they use Point_2 operations (which
// are tested in _test_cls_point_2.h)
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_CLS_WEIGHTED_POINT_2_H

View File

@ -0,0 +1,81 @@
// Copyright (c) 2017
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). 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 Lesser 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 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) : Mael Rouxel-Labbé
#ifndef CGAL__TEST_CLS_WEIGHTED_POINT_3_H
#define CGAL__TEST_CLS_WEIGHTED_POINT_3_H
#include <CGAL/Origin.h>
#include <CGAL/Point_3.h>
#include <CGAL/use.h>
#include <CGAL/Weighted_point_3.h>
#include <cassert>
#include <iostream>
using CGAL::internal::use;
template <class R>
bool _test_cls_weighted_point_3(const R& )
{
std::cout << "Testing class Weighted_point_3" ;
typedef typename R::RT RT;
typedef typename R::FT FT;
RT n1(-35);
RT n2( 50);
RT n3( 20);
RT n4( 5);
FT iw = -1;
CGAL::Point_3<R> p0(n1, n2, n3, n4);
// constructions
typename R::Weighted_point_3 iwp;
CGAL::Weighted_point_3<R> wp0; // default
CGAL::Weighted_point_3<R> wp1(CGAL::ORIGIN); // with origin
CGAL::Weighted_point_3<R> wp2(p0); // with Point_3
CGAL::Weighted_point_3<R> wp3(p0, iw); // with Point_3 and weight
CGAL::Weighted_point_3<R> wp4(iwp); // with R::Weighted_point_3
CGAL::Weighted_point_3<R> wp5(wp3); // with CGAL::Weighted_point_3< R >
CGAL::Weighted_point_3<R> wp6(n1, n2, n3); // with coordinates
use(wp0); use(wp4); use(wp5);
// assignement
wp1 = wp6;
std::cout << ".";
// accessors
CGAL::Point_3<R> p1 = wp2.point();
assert(p1 == p0);
FT w = wp3.weight();
assert(w == iw);
// no need to test the other operations as they use Point_3 operations (which
// are tested in _test_cls_point_3.h)
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_CLS_WEIGHTED_POINT_3_H

View File

@ -27,10 +27,11 @@ template <class R>
bool
_test_fct_constructions_2(const R&)
{
typedef typename R::RT RT;
typedef CGAL::Point_2<R> Point;
typedef CGAL::Triangle_2<R> Triangle;
typedef CGAL::Vector_2<R> Vector;
typedef typename R::RT RT;
typedef CGAL::Point_2<R> Point;
typedef CGAL::Weighted_point_2<R> Weighted_Point;
typedef CGAL::Triangle_2<R> Triangle;
typedef CGAL::Vector_2<R> Vector;
RT RT0(0);
RT RT1(1);
@ -44,6 +45,15 @@ _test_fct_constructions_2(const R&)
Point pse = p + Vector( RT1,-RT1 );
Point psw = p + Vector(-RT1,-RT1 );
Weighted_Point wpne(pne);
Weighted_Point wpnw(pnw);
Weighted_Point wpse(pse);
Weighted_Point wpsw(psw);
Weighted_Point wpnw_b(pnw, 4);
Weighted_Point wpse_b(pse, 4);
Weighted_Point wpsw_b(psw, 0);
// midpoint
assert( CGAL::midpoint( pne, psw) == p);
assert( CGAL::midpoint( pnw, pse) == p);
@ -76,7 +86,11 @@ _test_fct_constructions_2(const R&)
assert( CGAL::barycenter( pne, 0, psw, 0, pse, 0, pnw) == pnw);
assert( CGAL::barycenter( pne, 1, psw, 1, pse, 1, pnw, 1) == p);
// general position intersection point
// weighted circumcenter
assert( CGAL::weighted_circumcenter( wpne, wpse, wpnw ) == p);
assert( CGAL::weighted_circumcenter( wpsw, wpse, wpnw ) == p);
assert( CGAL::weighted_circumcenter( wpnw_b, wpse_b, wpsw_b ) == psw);
return true;
}

View File

@ -27,13 +27,14 @@ template <class R>
bool
_test_fct_constructions_3(const R&)
{
typedef typename R::RT RT;
typedef typename R::Point_3 Point;
typedef typename R::Segment_3 Segment;
typedef typename R::Plane_3 Plane;
typedef typename R::Vector_3 Vector;
typedef typename R::Triangle_3 Triangle;
typedef typename R::Tetrahedron_3 Tetrahedron;
typedef typename R::RT RT;
typedef typename R::Point_3 Point;
typedef typename R::Weighted_point_3 Weighted_point;
typedef typename R::Segment_3 Segment;
typedef typename R::Plane_3 Plane;
typedef typename R::Vector_3 Vector;
typedef typename R::Triangle_3 Triangle;
typedef typename R::Tetrahedron_3 Tetrahedron;
RT RT0(0);
RT RT1(1);
@ -55,6 +56,18 @@ _test_fct_constructions_3(const R&)
Point p3 = p + Vector( RT1, RT0, RT0 );
Point p4 = p + Vector( RT0, RT1, RT0 );
Weighted_point wp000(p000);
Weighted_point wp010(p010);
Weighted_point wp001(p001);
Weighted_point wp111(p111);
Weighted_point wp2(p2);
Weighted_point wp3(p3);
Weighted_point wp000_b(p000, 0);
Weighted_point wp100_b(p100, 4);
Weighted_point wp010_b(p010, 4);
Weighted_point wp001_b(p001, 4);
// midpoint
assert( CGAL::midpoint( p111, p000) == p);
assert( CGAL::midpoint( p110, p001) == p);
@ -106,7 +119,14 @@ _test_fct_constructions_3(const R&)
assert( (vz1 * orth) > 0 );
assert( parallel(Segment(p0, p0+orth), Segment(p0, p0+vz1)) );
// projection onto a plane
// weighted circumcenter
assert( CGAL::weighted_circumcenter( wp2, wp3 ) == CGAL::midpoint(p2, p3) );
assert( CGAL::weighted_circumcenter( wp000, wp001, wp111) == p);
assert( CGAL::weighted_circumcenter( wp000, wp001, wp010, wp111) == p);
assert( CGAL::weighted_circumcenter( wp000_b, wp100_b) == wp000_b);
assert( CGAL::weighted_circumcenter( wp000_b, wp100_b, wp010_b) == wp000_b);
assert( CGAL::weighted_circumcenter( wp000_b, wp100_b, wp010_b, wp001_b) == wp000_b);
return true;
}

View File

@ -23,6 +23,9 @@
#ifndef CGAL__TEST_FCT_POINT_2_H
#define CGAL__TEST_FCT_POINT_2_H
#include <cassert>
#include <iostream>
template <class R>
bool
_test_fct_point_2(const R& )

View File

@ -0,0 +1,116 @@
// Copyright (c) 2017
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). 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 Lesser 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 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) : Mael Rouxel-Labbé
#ifndef CGAL__TEST_FCT_WEIGHTED_POINT_2_H
#define CGAL__TEST_FCT_WEIGHTED_POINT_2_H
#include <CGAL/Line_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Weighted_point_2.h>
#include <CGAL/use.h>
#include <cassert>
#include <iostream>
template <class R>
bool
_test_fct_weighted_point_2(const R& )
{
std::cout << "Testing functions Weighted_point_2" ;
typedef typename R::RT RT;
CGAL::Point_2<R> p1( RT(18), RT(12), RT(3) ); // ( 6, 4)
CGAL::Point_2<R> p2( RT(18), RT(15), RT(3) ); // ( 6, 5)
CGAL::Point_2<R> p3( RT(18), RT( 9), RT(3) ); // ( 6, 3)
CGAL::Point_2<R> p4( RT(28), RT(40), RT(4) ); // ( 7,10)
CGAL::Point_2<R> p5( RT(12), RT(-4), RT(4) ); // ( 3,-1)
CGAL::Point_2<R> p6( RT(28), RT(12), RT(4) ); // ( 7, 3)
CGAL::Point_2<R> p7( RT(18), RT( 6), RT(3) ); // ( 6, 2)
CGAL::Point_2<R> p8( RT(24), RT( 9), RT(3) ); // ( 8, 3)
CGAL::Point_2<R> p9( RT( 6), RT(10), RT(1) ); // ( 6,10)
CGAL::Point_2<R> p10( RT(-3), RT(8), RT(1) ); // ( -3,8)
CGAL::Weighted_point_2<R> wp1( p1, 0);
CGAL::Weighted_point_2<R> wp2( p2, 0);
CGAL::Weighted_point_2<R> wp3( p3, 0);
CGAL::Weighted_point_2<R> wp4( p4, 0);
CGAL::Weighted_point_2<R> wp5( p5, 0);
CGAL::Weighted_point_2<R> wp6( p6, 0);
CGAL::Weighted_point_2<R> wp7( p7, 0);
CGAL::Weighted_point_2<R> wp8( p8, 0);
CGAL::Weighted_point_2<R> wp9( p9, 0);
CGAL::Weighted_point_2<R> wp1_b( p1, 4);
CGAL::Weighted_point_2<R> wp2_b( p2, -2);
CGAL::Weighted_point_2<R> wp3_b( p3, 3);
CGAL::Weighted_point_2<R> wp4_b( p4, 5);
CGAL::Weighted_point_2<R> wp5_b( p5, 28);
CGAL::Weighted_point_2<R> wp6_b( p6, -8);
CGAL::Weighted_point_2<R> wp7_b( p7, 8);
CGAL::Weighted_point_2<R> wp8_b( p8, 6);
CGAL::Weighted_point_2<R> wp10_b( p10, -8);
assert( CGAL::compare_power_distance(p1, wp1, wp1) == CGAL::compare_distance(p1, p1, p1));
assert( CGAL::compare_power_distance(p1, wp2, wp4) == CGAL::compare_distance(p1, p2, p4));
assert( CGAL::compare_power_distance(p7, wp9, wp3) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p7, wp9, wp7) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p6, wp3, wp8) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p2, wp5, wp5) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p8, wp6, wp9) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p6, wp5, wp4) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p3, wp4_b, wp5_b) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p6, wp6_b, wp2_b) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p1, wp7_b, wp1_b) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p3, wp3_b, wp5_b) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p7, wp2_b, wp4_b) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p2, wp1_b, wp2_b) == CGAL::SMALLER);
std::cout << ".";
CGAL::Line_2<R> l = CGAL::radical_axis(wp4_b, wp7_b);
for(int i=-5; i<5; ++i)
{
CGAL::Point_2<R> p = R().construct_point_on_2_object()(l, i);
assert(CGAL::compare_power_distance(p, wp4_b, wp7_b) == CGAL::EQUAL);
}
std::cout << ".";
assert(power_side_of_oriented_power_circle(wp1, wp1_b) == CGAL::ON_POSITIVE_SIDE );
assert(power_side_of_oriented_power_circle(wp2_b, wp2_b) == CGAL::ON_ORIENTED_BOUNDARY );
assert(power_side_of_oriented_power_circle(wp6, wp6_b) == CGAL::ON_NEGATIVE_SIDE );
assert(power_side_of_oriented_power_circle(wp7_b, wp4_b, wp8_b) == CGAL::ON_POSITIVE_SIDE );
assert(power_side_of_oriented_power_circle(wp7_b, wp4_b, wp7_b) == CGAL::ON_ORIENTED_BOUNDARY );
assert(power_side_of_oriented_power_circle(wp7_b, wp4_b, wp5_b) == CGAL::ON_NEGATIVE_SIDE );
assert(power_side_of_oriented_power_circle(wp1_b, wp4_b, wp5_b, wp10_b) == CGAL::ON_POSITIVE_SIDE );
assert(power_side_of_oriented_power_circle(wp1_b, wp4_b, wp5_b, wp5_b) == CGAL::ON_ORIENTED_BOUNDARY );
assert(power_side_of_oriented_power_circle(wp1_b, wp4_b, wp5_b, wp6_b) == CGAL::ON_NEGATIVE_SIDE );
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_FCT_WEIGHTED_POINT_2_H

View File

@ -0,0 +1,208 @@
// Copyright (c) 1999
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). 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 Lesser 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 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) : Mael Rouxel-Labbé
#ifndef CGAL__TEST_FCT_WEIGHTED_POINT_3_H
#define CGAL__TEST_FCT_WEIGHTED_POINT_3_H
#include <CGAL/Segment_3.h>
#include <CGAL/Point_3.h>
#include <CGAL/Weighted_point_3.h>
#include <cassert>
#include <iostream>
template <class R>
bool
_test_fct_weighted_point_3(const R& )
{
std::cout << "Testing functions Weighted_point_3" ;
typedef typename R::RT RT;
CGAL::Point_3<R> p1(RT(18), RT(15), RT(-21), RT(3) ); // 6, 5, -7
CGAL::Point_3<R> p2(RT(18), RT(15), RT( 12), RT(3) ); // 6, 5, 4
CGAL::Point_3<R> p3(RT(18), RT(12), RT(-21), RT(3) ); // 6, 4, -7
CGAL::Point_3<R> p4(RT(28), RT(40), RT( 20), RT(4) ); // 7, 10, 5
CGAL::Point_3<R> p5(RT(12), RT(-4), RT(-20), RT(4) ); // 3, -1, -5
CGAL::Point_3<R> p6(RT(18), RT(18), RT(-21), RT(3) ); // 6, 6, -7
CGAL::Weighted_point_3<R> wp1( p1, RT(0));
CGAL::Weighted_point_3<R> wp2( p2, RT(0));
CGAL::Weighted_point_3<R> wp3( p3, RT(0));
CGAL::Weighted_point_3<R> wp4( p4, RT(0));
CGAL::Weighted_point_3<R> wp5( p5, RT(0));
CGAL::Weighted_point_3<R> wp6( p6, RT(0));
CGAL::Weighted_point_3<R> wp1_b( p1, RT(-20));
CGAL::Weighted_point_3<R> wp2_b( p2, RT(-10));
CGAL::Weighted_point_3<R> wp3_b( p3, RT(5));
CGAL::Weighted_point_3<R> wp4_b( p4, RT(174));
CGAL::Weighted_point_3<R> wp5_b( p5, RT(-3));
CGAL::Weighted_point_3<R> wp6_b( p6, RT(0));
CGAL::Weighted_point_3<R> wp7_b( p6, RT(4));
CGAL::Weighted_point_3<R> wp8_b( p1, RT(5));
CGAL::Weighted_point_3<R> wp9_b( p1, RT(-200));
CGAL::Point_3<R> p000(RT(0), RT(0), RT(0) ); // 0, 0, 0
CGAL::Point_3<R> p100(RT(4), RT(0), RT(0), RT(1) ); // 4,0,0
CGAL::Point_3<R> p010(RT(0), RT(5), RT(0), RT(1) ); // 0,5,0
CGAL::Point_3<R> p001(RT(0), RT(0), RT(-6), RT(1) ); // 0,0,6
CGAL::Weighted_point_3<R> wp000( p000, RT(0) );
CGAL::Weighted_point_3<R> wp100( p100, RT(16) );
CGAL::Weighted_point_3<R> wp010( p010, RT(25) );
CGAL::Weighted_point_3<R> wp001( p001, RT(36) );
CGAL::Weighted_point_3<R> wp000m( p000, RT(100) );
assert( CGAL::compare_power_distance(p1, wp1, wp1) == CGAL::compare_distance(p1, p1, p1));
assert( CGAL::compare_power_distance(p1, wp2, wp4) == CGAL::compare_distance(p1, p2, p4));
assert( CGAL::compare_power_distance(p3, wp6, wp5) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p5, wp5, wp3) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p1, wp3, wp6) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p2, wp2, wp2) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p2, wp5, wp1) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p4, wp2, wp4) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p2, wp2_b, wp4 ) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p4, wp3_b, wp1_b) == CGAL::SMALLER);
assert( CGAL::compare_power_distance(p2, wp3_b, wp3_b) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p1, wp4_b, wp3_b) == CGAL::EQUAL);
assert( CGAL::compare_power_distance(p3, wp5_b, wp1_b) == CGAL::LARGER);
assert( CGAL::compare_power_distance(p5, wp2_b, wp6_b) == CGAL::LARGER);
std::cout << ".";
assert( CGAL::power_product(wp1, wp1) == RT(0) );
assert( CGAL::power_product(wp1, wp2) == CGAL::squared_distance(p1, p2) );
assert( CGAL::power_product(wp3_b, wp5_b) == RT(36) );
std::cout << ".";
assert( CGAL::power_side_of_oriented_power_sphere(wp7_b, wp6_b) == CGAL::ON_NEGATIVE_SIDE );
assert( CGAL::power_side_of_oriented_power_sphere(wp2_b, wp2_b) == CGAL::ON_ORIENTED_BOUNDARY );
assert( CGAL::power_side_of_oriented_power_sphere(wp6_b, wp7_b) == CGAL::ON_POSITIVE_SIDE );
// according to the doc, this should gives the same result...
#if 0
assert( CGAL::power_side_of_oriented_power_sphere(wp3, wp5, wp6)
== CGAL::Segment_3<R>(wp3, wp5).has_on(wp6) );
assert( CGAL::power_side_of_oriented_power_sphere(wp5, wp6, wp5)
== CGAL::Segment_3<R>(wp5, wp6).has_on(wp5) );
assert( CGAL::power_side_of_oriented_power_sphere(wp2, wp6, wp1)
== CGAL::Segment_3<R>(wp2, wp6).has_on(wp1) );
#endif
assert( CGAL::power_side_of_oriented_power_sphere(wp100, wp000, wp001) == CGAL::ON_POSITIVE_SIDE );
assert( CGAL::power_side_of_oriented_power_sphere(wp100, wp000, wp100) == CGAL::ON_ORIENTED_BOUNDARY );
assert( CGAL::power_side_of_oriented_power_sphere(wp100, wp000, wp9_b) == CGAL::ON_NEGATIVE_SIDE );
// according to the doc, there should be a comparison with oriented_circle... ?
#if 0
assert( CGAL::power_side_of_oriented_power_sphere(wp3, wp4, wp5, wp6) == );
assert( CGAL::power_side_of_oriented_power_sphere(wp3, wp5, wp6, wp3) == );
assert( CGAL::power_side_of_oriented_power_sphere(wp3, wp5, wp4, wp6) == );
#endif
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp1_b) == CGAL::ON_NEGATIVE_SIDE );
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp100) == CGAL::ON_ORIENTED_BOUNDARY );
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp001) == CGAL::ON_POSITIVE_SIDE );
assert( CGAL::power_side_of_oriented_power_sphere(wp2, wp3, wp4, wp5, wp6)
== CGAL::side_of_oriented_sphere(p2, p3, p4, p5, p6));
assert( CGAL::power_side_of_oriented_power_sphere(wp2, wp3, wp4, wp5, wp5)
== CGAL::side_of_oriented_sphere(p2, p3, p4, p5, p5));
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp001, wp000m) == CGAL::ON_NEGATIVE_SIDE );
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp001, wp010) == CGAL::ON_ORIENTED_BOUNDARY );
assert( CGAL::power_side_of_oriented_power_sphere(wp000, wp100, wp010, wp001, wp1_b) == CGAL::ON_POSITIVE_SIDE );
std::cout << ".";
assert( CGAL::power_side_of_bounded_power_sphere(wp7_b, wp6_b) == CGAL::ON_UNBOUNDED_SIDE );
assert( CGAL::power_side_of_bounded_power_sphere(wp2_b, wp2_b) == CGAL::ON_BOUNDARY );
assert( CGAL::power_side_of_bounded_power_sphere(wp6_b, wp7_b) == CGAL::ON_BOUNDED_SIDE );
assert( CGAL::power_side_of_bounded_power_sphere(wp4_b, wp1_b) == CGAL::ON_UNBOUNDED_SIDE );
assert( CGAL::power_side_of_bounded_power_sphere(wp7_b, wp8_b) == CGAL::ON_BOUNDARY );
assert( CGAL::power_side_of_bounded_power_sphere(wp1_b, wp4_b) == CGAL::ON_BOUNDED_SIDE );
std::cout << CGAL::power_side_of_bounded_power_sphere(wp100, wp000, wp001) << std::endl;
// assert( CGAL::power_side_of_bounded_power_sphere(wp100, wp000, wp9_b) == CGAL::ON_UNBOUNDED_SIDE );
// assert( CGAL::power_side_of_bounded_power_sphere(wp100, wp000, wp100) == CGAL::ON_BOUNDARY );
// assert( CGAL::power_side_of_bounded_power_sphere(wp100, wp000, wp001) == CGAL::ON_BOUNDED_SIDE );
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp1_b) == CGAL::ON_UNBOUNDED_SIDE );
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp100) == CGAL::ON_BOUNDARY );
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp001) == CGAL::ON_BOUNDED_SIDE );
assert( CGAL::power_side_of_bounded_power_sphere(wp2, wp3, wp4, wp5, wp6)
== CGAL::side_of_bounded_sphere(p2, p3, p4, p5, p6));
assert( CGAL::power_side_of_bounded_power_sphere(wp2, wp3, wp4, wp5, wp5)
== CGAL::side_of_bounded_sphere(p2, p3, p4, p5, p5));
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp001, wp000m) == CGAL::ON_UNBOUNDED_SIDE );
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp001, wp010) == CGAL::ON_BOUNDARY );
// assert( CGAL::power_side_of_bounded_power_sphere(wp000, wp100, wp010, wp001, wp1_b) == CGAL::ON_BOUNDED_SIDE );
std::cout << ".";
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1) == RT(0) );
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1_b) == -wp1_b.weight() );
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp3, wp6) == RT(1) );
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1_b, wp3_b) == RT(164));
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp5)
== CGAL::squared_radius(p1, p3, p5));
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010) == RT(0));
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp4, wp5)
== CGAL::squared_radius(p1, p3, p4, p5));
assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010, wp001) == RT(0));
std::cout << ".";
assert( CGAL::power_distance_to_power_sphere(wp1, wp3_b, wp5, wp4_b, wp1) == RT(0) );
std::cout << ".";
assert( CGAL::compare_weighted_squared_radius(wp4_b, RT(10)) == CGAL::SMALLER );
assert( CGAL::compare_weighted_squared_radius(wp1, RT(0)) == CGAL::EQUAL );
assert( CGAL::compare_weighted_squared_radius(wp1_b, RT(0)) == CGAL::LARGER );
assert( CGAL::compare_weighted_squared_radius(wp1_b, wp2, RT(0)) == CGAL::LARGER );
assert( CGAL::compare_weighted_squared_radius(wp3, wp6, RT(1)) == CGAL::EQUAL );
assert( CGAL::compare_weighted_squared_radius(wp2, wp4_b, RT(255)) == CGAL::SMALLER );
assert( CGAL::compare_weighted_squared_radius(wp1, wp2, wp3, RT(50)) == CGAL::SMALLER);
assert( CGAL::compare_weighted_squared_radius(wp000, wp100, wp010, RT(0)) == CGAL::EQUAL);
assert( CGAL::compare_weighted_squared_radius(wp4_b, wp2, wp3, RT(50)) == CGAL::LARGER );
assert( CGAL::compare_weighted_squared_radius(wp000, wp100, wp010, wp2, RT(100)) == CGAL::SMALLER );
assert( CGAL::compare_weighted_squared_radius(wp000, wp100, wp010, wp001, RT(0)) == CGAL::EQUAL );
assert( CGAL::compare_weighted_squared_radius(wp000, wp100, wp010, wp3, RT(50)) == CGAL::LARGER );
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_FCT_WEIGHTED_POINT_3_H

View File

@ -61,6 +61,14 @@ _test_io(const R&)
_test_io_for(p22);
_test_io_for(p222);
std::cout << "Weighted_point_2" << std::endl;
typename R::Weighted_point_2 wp2(p2);
typename R::Weighted_point_2 wp22(p22, 2);
typename R::Weighted_point_2 wp222(p222, -2);
_test_io_for(p2);
_test_io_for(p22);
_test_io_for(p222);
std::cout << "Vector_2" << std::endl;
typename R::Vector_2 v2(2, 6, 2);
typename R::Vector_2 v22(2, -6, 2);
@ -125,6 +133,14 @@ _test_io(const R&)
_test_io_for(p333);
_test_io_for(p3333);
std::cout << "Weighted_point_3" << std::endl;
typename R::Weighted_point_3 wp3(p3);
typename R::Weighted_point_3 wp33(p33, 3);
typename R::Weighted_point_3 wp333(p333, -3);
_test_io_for(p3);
_test_io_for(p33);
_test_io_for(p333);
std::cout << "Vector_3" << std::endl;
typename R::Vector_3 v3(2, 6, 2, 2);
typename R::Vector_3 v33(2, -6, 2, 2);

View File

@ -25,6 +25,7 @@
#define CGAL__TEST_NEW_2_H
#include <CGAL/squared_distance_2.h>
#include <CGAL/use.h>
#include "_test_cls_line_new_2.h"
#include "_test_cls_segment_new_2.h"
@ -67,6 +68,7 @@ test_new_2(const R& rep)
typedef typename R::FT FT;
typedef typename R::Point_2 Point_2;
typedef typename R::Weighted_point_2 Weighted_point_2;
typedef typename R::Vector_2 Vector_2;
typedef typename R::Direction_2 Direction_2;
typedef typename R::Segment_2 Segment_2;
@ -91,6 +93,20 @@ test_new_2(const R& rep)
Point_2 p5 = construct_point(3,4,5);
Point_2 p6 = construct_point(3,4,6);
typename R::Construct_weighted_point_2 construct_weighted_point =
rep.construct_weighted_point_2_object();
Weighted_point_2 wp1;
Weighted_point_2 wp2 = construct_weighted_point(ORIGIN);
Weighted_point_2 wp3 = construct_weighted_point(1,1);
Weighted_point_2 wp3bis = construct_weighted_point(RT(1),RT(1));
Weighted_point_2 wp3ter = construct_weighted_point(FT(1),FT(1));
Weighted_point_2 wp4 = construct_weighted_point(p2);
Weighted_point_2 wp5 = construct_weighted_point(p3,2);
Weighted_point_2 wp6 = construct_weighted_point(p4,RT(2));
Weighted_point_2 wp7 = construct_weighted_point(p5,FT(2));
Weighted_point_2 wp8 = construct_weighted_point(wp7);
use(wp1); use(wp3bis); use(wp3ter);
typename R::Construct_vector_2 construct_vector =
rep.construct_vector_2_object();
Vector_2 v1;
@ -261,6 +277,10 @@ test_new_2(const R& rep)
tmp13 = construct_circumcenter(p2,p3);
tmp13 = construct_circumcenter(t2);
typename R::Construct_weighted_circumcenter_2 construct_weighted_circumcenter
= rep.construct_weighted_circumcenter_2_object();
tmp13 = construct_weighted_circumcenter(wp4,wp5,wp6);
typename R::Construct_centroid_2 construct_centroid
= rep.construct_centroid_2_object();
tmp13 = construct_centroid(p2,p3,p4);
@ -301,6 +321,9 @@ test_new_2(const R& rep)
= rep.construct_opposite_line_2_object();
Line_2 tmp17 = construct_opposite_line(l2);
typename R::Construct_radical_axis_2 construct_radical_axis
= rep.construct_radical_axis_2_object();
tmp17 = construct_radical_axis(wp6, wp8);
typename R::Construct_opposite_triangle_2 construct_opposite_triangle
= rep.construct_opposite_triangle_2_object();
@ -471,6 +494,10 @@ test_new_2(const R& rep)
tmp34ab = CGAL::compare_distance(t2, l1, s1, p1);
tmp34ab = CGAL::compare_distance(t2, l1, s1);
typename R::Compare_power_distance_2 compare_power_dist
= rep.compare_power_distance_2_object();
tmp34ab = compare_power_dist(p1, wp2, wp3);
typename R::Compare_angle_with_x_axis_2 compare_angle
= rep.compare_angle_with_x_axis_2_object();
Comparison_result tmp34ac = compare_angle(d3,d2);
@ -508,6 +535,11 @@ test_new_2(const R& rep)
= rep.side_of_oriented_circle_2_object();
Oriented_side tmp41 = side_of_oriented_circle(p2,p3,p4,p5);
typename R::Power_side_of_oriented_power_circle_2 power_side_of_oriented_power_circle
= rep.power_side_of_oriented_power_circle_2_object();
tmp41 = power_side_of_oriented_power_circle(wp4,wp5);
tmp41 = power_side_of_oriented_power_circle(wp4,wp5,wp6);
tmp41 = power_side_of_oriented_power_circle(wp4,wp5,wp6,wp7);
typename R::Side_of_bounded_circle_2 side_of_bounded_circle
= rep.side_of_bounded_circle_2_object();

View File

@ -93,6 +93,7 @@ test_new_3(const R& rep)
typedef typename R::FT FT;
typedef typename R::Point_3 Point_3;
typedef typename R::Weighted_point_3 Weighted_point_3;
typedef typename R::Vector_3 Vector_3;
typedef typename R::Direction_3 Direction_3;
typedef typename R::Segment_3 Segment_3;
@ -118,6 +119,21 @@ test_new_3(const R& rep)
Point_3 p5 = construct_point(1,2,3,4);
Point_3 p6 = construct_point(4,2,1,2);
typename R::Construct_weighted_point_3 construct_weighted_point
= rep.construct_weighted_point_3_object();
Weighted_point_3 wp1;
Weighted_point_3 wp2 = construct_weighted_point(ORIGIN);
Weighted_point_3 wp3 = construct_weighted_point(1,1,1);
Weighted_point_3 wp3bis = construct_weighted_point(RT(1),RT(1),RT(1));
Weighted_point_3 wp3ter = construct_weighted_point(FT(1),FT(1),FT(1));
use(wp3bis); use(wp3ter);
Weighted_point_3 wp4 = construct_weighted_point(p2);
Weighted_point_3 wp5 = construct_weighted_point(p4,2);
Weighted_point_3 wp6 = construct_weighted_point(p5,RT(2));
Weighted_point_3 wp7 = construct_weighted_point(p6,FT(2));
Weighted_point_3 wp8 = construct_weighted_point(wp7);
use(wp1);
typename R::Construct_vector_3 construct_vector
= rep.construct_vector_3_object();
Vector_3 v1;
@ -327,6 +343,12 @@ test_new_3(const R& rep)
tmp4 = construct_circumcenter(th2);
tmp4 = construct_circumcenter(t2);
typename R::Construct_weighted_circumcenter_3 construct_weighted_circumcenter
= rep.construct_weighted_circumcenter_3_object();
tmp4 = construct_weighted_circumcenter(wp4,wp5);
tmp4 = construct_weighted_circumcenter(wp4,wp5,wp6);
tmp4 = construct_weighted_circumcenter(wp4,wp5,wp6,wp7);
typename R::Construct_centroid_3 construct_centroid
= rep.construct_centroid_3_object();
tmp4 = construct_centroid(p2,p3,p4);
@ -422,6 +444,11 @@ test_new_3(const R& rep)
tmp12c = Compute_squared_distance(p1, h2);
(void) tmp12c;
typename R::Compute_power_product_3 compute_power_product
= rep.compute_power_product_3_object();
tmp12c = compute_power_product(wp2, wp3);
(void) tmp12c;
typename R::Compute_squared_length_3 compute_squared_length
= rep.compute_squared_length_3_object();
FT tmp11 = compute_squared_length(v3);
@ -436,6 +463,17 @@ test_new_3(const R& rep)
tmp11aa = Compute_squared_radius(p3, p4);
tmp11aa = Compute_squared_radius(p3, p4, p5);
tmp11aa = Compute_squared_radius(p3, p4, p5, p6);
typename R::Compute_power_distance_to_power_sphere_3 power_distance_to_power_sphere
= rep.compute_power_distance_to_power_sphere_3_object();
tmp11aa = power_distance_to_power_sphere(wp3, wp4, wp5, wp6, wp7);
typename R::Compute_squared_radius_smallest_orthogonal_sphere_3 compute_squared_radius_smallest_orthogonal_sphere
= rep.compute_squared_radius_smallest_orthogonal_sphere_3_object();
tmp11aa = compute_squared_radius_smallest_orthogonal_sphere(wp4);
tmp11aa = compute_squared_radius_smallest_orthogonal_sphere(wp4, wp5);
tmp11aa = compute_squared_radius_smallest_orthogonal_sphere(wp4, wp5, wp6);
tmp11aa = compute_squared_radius_smallest_orthogonal_sphere(wp4, wp5, wp6, wp7);
(void) tmp11aa;
typename R::Compute_squared_area_3 compute_squared_area
@ -589,6 +627,10 @@ test_new_3(const R& rep)
tmp34ab = CGAL::compare_distance(p1, p2, p3, p4);
tmp34ab = CGAL::compare_distance(p1, p2, p3);
typename R::Compare_power_distance_3 compare_power_dist
= rep.compare_power_distance_3_object();
tmp34ab = compare_power_dist(p1, wp2, wp3);
typename R::Compare_squared_radius_3 compare_sq_radius
= rep.compare_squared_radius_3_object();
@ -602,6 +644,13 @@ test_new_3(const R& rep)
(void)tmp;
}
typename R::Compare_weighted_squared_radius_3 compare_weighted_squared_radius
= rep.compare_weighted_squared_radius_3_object();
tmp34ab = compare_weighted_squared_radius(wp4, FT(1));
tmp34ab = compare_weighted_squared_radius(wp4, wp5, FT(1));
tmp34ab = compare_weighted_squared_radius(wp4, wp5, wp6, FT(1));
tmp34ab = compare_weighted_squared_radius(wp4, wp5, wp6, wp7, FT(1));
typename R::Collinear_3 collinear
= rep.collinear_3_object();
bool tmp29 = collinear(p2,p3,p4);
@ -740,14 +789,27 @@ test_new_3(const R& rep)
typename R::Side_of_oriented_sphere_3 side_of_oriented_sphere
= rep.side_of_oriented_sphere_3_object();
Oriented_side tmp44 = side_of_oriented_sphere(p2,p3,p4,p5,p6);
(void) tmp44;
typename R::Power_side_of_oriented_power_sphere_3 power_side_of_oriented_power_sphere
= rep.power_side_of_oriented_power_sphere_3_object();
tmp44 = power_side_of_oriented_power_sphere(wp3,wp4);
tmp44 = power_side_of_oriented_power_sphere(wp3,wp4,wp5);
tmp44 = power_side_of_oriented_power_sphere(wp3,wp4,wp5,wp6);
tmp44 = power_side_of_oriented_power_sphere(wp3,wp4,wp5,wp6,wp8);
(void) tmp44;
typename R::Side_of_bounded_sphere_3 side_of_bounded_sphere
= rep.side_of_bounded_sphere_3_object();
Bounded_side tmp45 = side_of_bounded_sphere(p2,p3,p4,p5,p6);
tmp45 = side_of_bounded_sphere(p2,p3,p4,p6);
tmp45 = side_of_bounded_sphere(p2,p3,p6);
typename R::Power_side_of_bounded_power_sphere_3 power_side_of_bounded_power_sphere
= rep.power_side_of_bounded_power_sphere_3_object();
tmp45 = power_side_of_bounded_power_sphere(wp3,wp4);
tmp45 = power_side_of_bounded_power_sphere(wp3,wp4,wp5);
tmp45 = power_side_of_bounded_power_sphere(wp3,wp4,wp5,wp6);
tmp45 = power_side_of_bounded_power_sphere(wp3,wp4,wp5,wp6,wp7);
(void) tmp45;
typename R::Angle_3 angle