1 |
francois |
283 |
//------------------------------------------------------------ |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
// MAGiC |
4 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
5 |
|
|
// D�partement de G�nie M�canique - UQTR |
6 |
|
|
//------------------------------------------------------------ |
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�partement |
8 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec � |
9 |
|
|
// Trois Rivi�res |
10 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord |
11 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
12 |
|
|
//------------------------------------------------------------ |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
// |
15 |
|
|
// ot_boite_2D.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 � 11H23 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h" |
26 |
francois |
481 |
#include "ot_boite_2d.h" |
27 |
francois |
283 |
#include <algorithm> |
28 |
|
|
#include <math.h> |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
BOITE_2D::BOITE_2D(double xmin,double ymin,double xmax,double ymax):x(xmin),y(ymin),dx(xmax-xmin),dy(ymax-ymin) |
34 |
|
|
{ |
35 |
|
|
} |
36 |
|
|
BOITE_2D::BOITE_2D(BOITE_2D& mdd):x(mdd.x),y(mdd.y),dx(mdd.dx),dy(mdd.dy) |
37 |
|
|
{ |
38 |
|
|
} |
39 |
|
|
BOITE_2D::BOITE_2D(const BOITE_2D& mdd):x(mdd.x),y(mdd.y),dx(mdd.dx),dy(mdd.dy) |
40 |
|
|
{ |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
BOITE_2D::~BOITE_2D() |
44 |
|
|
{ |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
double BOITE_2D::get_xmin(void) |
48 |
|
|
{ |
49 |
|
|
return x; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
double BOITE_2D::get_xmax(void) |
53 |
|
|
{ |
54 |
|
|
return (x+dx); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
double BOITE_2D::get_ymin(void) |
58 |
|
|
{ |
59 |
|
|
return y; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
double BOITE_2D::get_ymax(void) |
63 |
|
|
{ |
64 |
|
|
return (y+dy); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
BOITE_2D& BOITE_2D::operator=(BOITE_2D& boite) |
68 |
|
|
{ |
69 |
|
|
x=boite.x; |
70 |
|
|
y=boite.y; |
71 |
|
|
dx=boite.dx; |
72 |
|
|
dy=boite.dy; |
73 |
|
|
return *this; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
BOITE_2D& BOITE_2D::operator+(BOITE_2D& boite) |
77 |
|
|
{ |
78 |
|
|
double xmin=std::min(x,boite.x); |
79 |
|
|
double ymin=std::min(y,boite.y); |
80 |
|
|
double xmax=std::min(x+dx,boite.x+boite.dx); |
81 |
|
|
double ymax=std::min(y+dy,boite.y+boite.dy); |
82 |
|
|
x=xmin; |
83 |
|
|
y=ymin; |
84 |
|
|
dx=xmax-xmin;; |
85 |
|
|
dy=ymax-ymin; |
86 |
|
|
return *this; |
87 |
|
|
} |
88 |
|
|
double BOITE_2D::get_rayon(void) |
89 |
|
|
{ |
90 |
|
|
return (0.5*sqrt(dx*dx+dy*dy)); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
void BOITE_2D::get_centre(double *coo) |
94 |
|
|
{ |
95 |
|
|
coo[0]=x+dx*0.5; |
96 |
|
|
coo[1]=y+dy*0.5; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
int BOITE_2D::operator*(BOITE_2D& boite) |
102 |
|
|
{ |
103 |
|
|
if ( x+dx>=boite.x) |
104 |
|
|
if ( y+dy>=boite.y) |
105 |
|
|
if ( x<(boite.x+boite.dx)) |
106 |
|
|
if ( y<(boite.y+boite.dy)) |
107 |
|
|
return 1; |
108 |
|
|
return 0; |
109 |
|
|
} |