Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] point lying over a line problem

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] point lying over a line problem


Chronological Thread 
  • From: Alejandro Aragon <>
  • To:
  • Subject: Re: [cgal-discuss] point lying over a line problem
  • Date: Wed, 23 Jul 2008 11:48:52 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=FQ1wieVGCHNyPTmzE42e7x/hDSX+syonOQESxYZkGed6PmOW5SyGmlBPwKvPcDUZpf MSjQyQwJpExJuumF3X0rzcWAxkBux3/2lPPapuzGSm7h06PTeVZ4L0VFhcZoH/1oMaCO /LerbeTYhY3Qu7XXvj8xJKxtTmZGIkvvp+IoU=

Indeed that made the difference, using simple cartesian gave:

$./a.out
Time: 1.5705sec
Measurement granularity: 1000000 of a second
Time: 1.56849sec
Measurement granularity: 1000000 of a second

so I guess it's the same. Now, why would you use reference counting for such a small type??? Let's say you use double precision Point_2 types, you would need 64 bits to represent the x and y coordinates and then half of that to keep track of the storage???? Isn't that something silly to do? I would expect using reference counting in objects that require a large amount of storage (the std::string class for example, even though I believe that even that class is not using reference counting). If you allocate 100 different points, 33% of your memory goes away in using pointers!!!

I guess that Cartesian uses objects that really need reference counting, but I don't think that the Point_2 should be one of them. Then users of the library who didn't bother to go over the entire documentation (like me) think that Cartesian is their best candidate, when it is not.

Alejandro M. Aragón

On Jul 23, 2008, at 11:20 AM, Andreas Fabri wrote:

Hi Alejandro,

Cartesian has reference counted objects. You might try Simple_cartesian instead.

Best regards,

andreas



Alejandro Aragon wrote:
By the way, talking about points in CGAL. I decided to create my own point class, templated by the dimension of the point to see the difference in creation time with that of the CGAL types. I introduced an implicit conversion so that I can use my point type where a CGAL algorithm needs it. Then my test was just creating points. It was surprising the time that it took the creation of 10e9 Point_2 objects compared to my simple templated point class:
int main(int argc, char *argv[]) {
typedef CGAL::Point_2 PointType;
Timer t1;
cout<<"CGAL point"<<endl;
t1.Reset();
for (long i=0; i<1.0e9; ++i) {
PointType p(3,5);
}
t1.Tac();
cout<<"my point"<<endl;
t1.Reset();
for (long i=0; i<1.0e9; ++i) {
geometry::Point<2> p(3,5);
}
t1.Tac();
exit(0);
}
$./a.out
CGAL point
Time: 74.2738sec
Measurement granularity: 1000000 of a second
my point
Time: 1.57362sec
Measurement granularity: 1000000 of a second
so can someone tell me why is this? I would never expect an almost factor of 50 in execution times! and this was just for creating a point.
Alejandro M. Aragón
On Jul 23, 2008, at 10:48 AM, Andreas Fabri wrote:
Sylvain Pion wrote:
Alejandro Aragon a écrit :
Hi, no one has replied to my post yet, so I decided to send it again in case someone will.
Wrong decision : you should have decided to read the FAQ, for example.

http://www.cgal.org/FAQ.html#inexact_NT

I'm trying to check how the oriented_side() function works for a line. I
created a very simple example, where a point should lie on a line, but it
doesn't. The program is as follows:

#include <CGAL/Cartesian.h>
#include <iostream>

using std::cout;
using std::endl;

int main() {

typedef CGAL::Cartesian<double> KernelType;
typedef KernelType::Point_2 PointType;
typedef KernelType::Line_2 LineType;


PointType p(0.034,0.006);
cout<<"point -> "<<p<<endl;

LineType l(-0.004, 0.004, 0.000112);
cout<<"line -> "<<l<<endl;

CGAL::Oriented_side test = l.oriented_side(p);

if ( test == CGAL::ON_POSITIVE_SIDE ) {
cout<<"point on positive side"<<endl;
} else if ( test == CGAL::ON_NEGATIVE_SIDE ) {
cout<<"point on negative side"<<endl;
} else {
cout<<"point over line"<<endl;
}

return 0;
}

The output of this little program is:

point -> 0.034 0.006
line -> -0.004 0.004 0.000112
point on negative side

Can someone tell me what is happening here? The point should not be on the
negative side. Thank you all.

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page