The Points

Definition

A point represents a location in a given coordinate space specified in Long precision.

point.gif

The class Point3d.

Types

There are three different classes of Point according to the dimension:

Public Attributes

Points are characterized by the coordinates:

They are read write attributes. It means that they are accessible directly without any member function. For example:

Point2d p;
p.x=5; p.y=12;
std::cout << p.y << std::endl;

Construction

A point can be created without any argument or with specified coordinates or a specified point, or a specified dimension. For example:
Point2d p1;     // = Point2d p1(0,0)
p1=1;           // p1.x = p1.y = 1
Point2d p2(12,24);
Dimension d(50,100);
Point2d p3(d);  // =Point(50,100)
Point2d *p4 = new Point2d(3);   // p4->x = p4->y = 3;

Consultation

The basic arithmetic operators (+,-,*,/,==, !=, +=, -=, *=, /=) between point and constant or between points has been redefined to handle point. For example:
Point2d p1(5,10), p2;
if (p1==p2 || p1==1) {
   p1+=p2; p2+=2+p1;
   p1*=p2; p2*=2;
}

File Transfer

To save a point in a file, just use:
Point p;
p.SaveFile("foobar.pan");

To load a point from a file, just use:

Point p;
p.LoadFile("foobar.pan");

Generally, a point is not saved directly in a file but by the way of a collection. To save and load a point in a collection, use:

Collection cold;
Point2d *p1=new Point2d(10,20),*p2;
cold.SETPOBJECT("bar",Point2d,p1);
p2=(Point2d*)cold.GETPOBJECT("bar",Point2d);

To save and load an array of points in a collection, use:

Point2d **p3=new Point2d*[12], **p4;
for (int i=0; i<12; i++) p3[i]=new Point2d(i,i);
cold.SETPARRAY("foo",Point2d,p3,12);
p4=(Point2d**)cols.GETPARRAY("foo",Point2d);
std::cout << "Coordinates: " << p4[11]->x << "," << p4[11]->y << std::endl;

The Pantheon project
Image Team GREYC Laboratory
UMR CNRS 6072 - ENSICAEN - University of Caen, France
This page was last modified on 19 June 2015