Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Questions on architecture of CGAL with respect to adding a feature

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Questions on architecture of CGAL with respect to adding a feature


Chronological Thread 
  • From: Marc Glisse <>
  • To:
  • Subject: Re: [cgal-discuss] Questions on architecture of CGAL with respect to adding a feature
  • Date: Fri, 26 Feb 2016 15:11:55 +0100 (CET)

On Fri, 26 Feb 2016, Frédérik Paradis wrote:

Thank you for your answer Sebastien.

There are several factors to take into account:
- would there be a significant speed up when using dimension specific
implementation?
- can the implementation be made easily dimension generic?


The answer to the first question is no and the second is yes. So I guess I
should just make a dimension generic implementation. However, since the
CGAL::Ipelet_base class return instances of Point_2, I have to convert
these instances into Point_d.

You could look at Search_traits_3 (there may be better examples in CGAL, I just picked the first one I found). It handles the difference through typedefs.

Is there a way to do do that? Right now, I do
something like that:

Point_d point_2_to_point_d(Point_2 p) {
return Point_d(CGAL::to_double(p.x()), CGAL::to_double(p.y()));
}

Point_2 point_d_to_point_2(Point_d p) {
return Point_2(CGAL::to_double(p[0]), CGAL::to_double(p[1]));
}

This class is not documented so it cannot appear in examples but it can
certainly be used in the implementation of algorithms of CGAL. Actually
it is even better to reuse something existing than creating an almost
identical duplicate. At the same time if you need some improvements
or new functions in this class they should be welcome.


Perfect.

I would need a more precise definition to answer correctly. However,
there is the traits Root_of_traits that depending on the number type
used will provide an exact representation of algebraic numbers of degree
2 when using an exact number type.

http://doc.cgal.org/latest/Number_types/classCGAL_1_1Root__of__traits.html

http://doc.cgal.org/latest/Number_types/classCGAL_1_1Sqrt__extension.html


So, let r_v and r_v be the radius of two circles v and w. We get r =
max(r_v, r_w). Let d be the distance between the circles v and w. Let s be
a constant greater than 0. We want to verify if d >= s*r.

One common trick is to compare the square of distances instead of the distances directly, to avoid square roots. Something like d^2 >= s^2*r^2.

Here is how I've done the calculation:

bool are_well_separated(const Node* v, const Node* w) const {
Sphere_d cir_v = v->enclosing_circle();
Sphere_d cir_w = w->enclosing_circle();
FT max_rad = CGAL::sqrt(std::max(cir_v.squared_radius(),
cir_w.squared_radius()));
FT distance_vw = CGAL::sqrt(CGAL::squared_distance(cir_v.center(),
cir_w.center()));
return (distance_vw - 2.*max_rad) > s*max_rad;
}

I do not really understand how to use the two classes that mentionned.

Thank you for your answer.

Frédérik

--
Marc Glisse



Archive powered by MHonArc 2.6.18.

Top of Page