Salut a tous
Voila mon petit pb
Je dois créer un programme qui effectue une triangulation de delauanay a partir d un fichier de Point avec 2 "double" comme attributs
J ai cée 2 objet, Point et Triangle
Et j ai des erreurs a la compilation
Point.h
#ifndef _POINT__H
#define _POINT__H
#include
//#include
using namespace std;
class Point
{
protected:
double x,y;
public:
Point(double 0.0, double 0.0);
double dist(const Point&);
double abs() const;
double ord() const;
bool isEqual(const Point&) const;
void deplacer(double, double);
void rotation(const Point&, double);
void zoom(const Point&, double);
void afficher() const;
};
#endif
Point.cpp
#include
#include "Point.h"
#include <math.h>
using namespace std;
Point::Point(double xx,double yy)
{
x = xx;
y = yy;
}
double Point::dist(const Point &p1)
{
return sqrt((x-p1.x)*(x-p1.x)+(y-p1.y)*(y-p1.y));
}
double Point::abs() const
{
return x;
}
double Point::ord() const
{
return y;
}
bool Point::isEqual(const Point &p1) const
{
return (x==p1.x && y==p1.y);
}
void Point::deplacer(double dx,double dy)
{
x += dx;
y += dy;
}
void Point::rotation(const Point &w,double theta)
{
double d = dist(w);
double alpha = acos((x-w.x)/sqrt((x-w.x)*(x-w.x)+(y-w.y)*(y-w.y)));
double beta = asin((y-w.y)/sqrt((x-w.x)*(x-w.x)+(y-w.y)*(y-w.y)));
theta = theta*M_PI/180.;
if (d!=0)
{
x = w.x + d*cos(theta + alpha);
y = w.y + d*sin(theta + beta);
}
}
void Point::zoom(const Point& a,double k)
{
x = (x-a.x)*k + a.x;
y = (y-a.y)*k + a.y;
}
void Point::afficher() const
{
cout << "{"<< x << " ; "<< y<< "}";
}
Triangle.h
#ifndef _TRIANGLE__H
#define _TRIANGLE__H
#include
#include "Point.h"
using namespace std;
class Triangle
{
protected:
Point* a;
Point* b;
Point* c;
Triangle* t1;
Triangle* t2;
Triangle* t3;
public:
Triangle(Point*, Point*, Point*, Triangle*, Triangle*, Triangle*);
Triangle(Point*, Point*, Point*);
Triangle();
Point centreCC() const;
Point sommet(int i) const;
double rayon() const;
void deplacer(double, double);
void rotation(const Point&, double);
void zoom(const Point&, double);
void afficherT() const;
};
#endif
Triangle.cpp
#include
#include "Triangle.h"
using namespace std;
Triangle::Triangle(Point *aa, Point *bb, Point *cc, Triangle *tt1, Triangle *tt2, Triangle *tt3)
{
a =aa;
b = bb;
c =cc;
t1 =tt1;
t2 =tt2;
t3 =tt3;
}
Triangle::Triangle(Point *a, Point *b, Point *c)
{
t1 = NULL;
t2 = NULL;
t3 = NULL;
}
Triangle::Triangle()
{
a = NULL;
b = NULL;
c = NULL;
t1 = NULL;
t2 = NULL;
t3 = NULL;
}
Point Triangle::centreCC() const
{
double x1,x2,x3,y1,y2,y3;
double p,q,r,s,t,u;
x1=a.x;
x2=b.x;
x3=c.x;
y1=a.y;
y2=b.y;
y3=c.y;
if (!a.isEqual(b) && !a.isEqual(c) && !b.isEqual(c))
{
p=x2-x3;
q=y2-y3;
r=((y2+y3)*(y2-y3)+(x2+x3)*(x2-x3))/2.;
s=x2-x1;
t=y2-y1;
u=((y2+y1)*(y2-y1)+(x2+x1)*(x2-x1))/2.;
Point cc(((r*t-u*q)/(p*t-q*s)),((s*r-p*u)/(q*s-p*t)));
return cc;
}
if (a.isEqual(b) && !a.isEqual(c))
{
Point cc((a.x+c.x)/2.,(a.y+c.y)/2);
return cc;
}
if (a.isEqual(c) && !a.isEqual(b))
{
Point cc((a.x+b.x)/2,(a.y+b.y)/2);
return cc;
}
if (c.isEqual(b) && !c.isEqual(a))
{
Point cc((b.x+c.x)/2,(b.y+c.y)/2);
return cc;
}
if (a.isEqual(c) && a.isEqual(b))
{
Point cc(0,0);
return cc;
}
}
Point Triangle::sommet(int i) const
{
if (i==1) return a;
if (i==2) return b;
if (i==3) return c;
}
double Triangle::rayon() const
// rayon du cercle circonscrit au triangle
{
return a.dist(centreCC());
}
void Triangle::deplacer(double dx,double dy)
{
a.deplacer(dx,dy);
b.deplacer(dx,dy);
c.deplacer(dx,dy);
}
void Triangle::rotation(const Point &w,double theta)
{
a.rotation(w,theta);
b.rotation(w,theta);
c.rotation(w,theta);
}
void Triangle::zoom(const Point &w, double k)
{
a.zoom(w, k);
b.zoom(w, k);
c.zoom(w, k);
}
void Triangle::afficherT() const
{
a.afficher();
cout << " | ";
b.afficher();
cout << " | ";
c.afficher();
}
makefile
# Path for the Tcontainer project
#
INC_DIR = ../header
#
# Path for the Algebra project
#SRC_DIR BIN_DIR ../bin/
INC_DIR = ../header
CCC = g++
#
# Global Flags
#
ALG_FLAGS = -O2 -g -Wno-deprecated
#
# header files needed
#
INCLUDES = -I$(INC_DIR)
#
# Targets
#
all: test
SRCS = Point.cpp Triangle.cpp
TEST_SRCS = Test.cpp
#
# Règles de compilation des modules
#
OBJS= $(SRCS:%.cc=$(BIN_DIR)%.o)
TEST_OBJS= $(TEST_SRCS:%.cc=$(BIN_DIR)%.o)
$(BIN_DIR)%.o: %.cc
$(CCC) $(INCLUDES) $(ALG_FLAGS) $< -c -o $@
#
# executable de test
#
test : $(OBJS) $(TEST_OBJS)
$(CCC) $(INCLUDES) $(CCCFLAGS) $(ALG_FLAGS) -o $(BIN_DIR)$@ $(OBJS) $(TEST_OBJS) -lm
quand je lance la compilation voila ce qu il me sort
Triangle.cpp:51: error: request for member `x' in `this->Triangle::a', which is
of non-class type `Point* const'
Triangle.cpp:57: error: request for member `isEqual' in `this->Triangle::a',
which is of non-aggregate type `Point* const
Triangle.cpp:93: error: conversion from `Point* const' to non-scalar type `
Point' requested
Triangle.cpp:117: error: request for member `deplacer' in `this->Triangle::a',
which is of non-aggregate type `Point*
je n ai que ce type d erreur mais plusieurs
Si qqun a une solution ca m aiderait bcp
Merci
Afficher la suite