121 lines
2.6 KiB
C++
121 lines
2.6 KiB
C++
#include "point.h"
|
|
|
|
point :: point(void):m_x(0),m_y(0),m_couleur(ROUGE)
|
|
{}
|
|
|
|
point :: point(SHORT x, SHORT y, ULONG couleur) :m_x(x),m_y(y),m_couleur(couleur)
|
|
{}
|
|
|
|
point :: point(point& copiePoint) :m_x(copiePoint.getCoordX()),m_y(copiePoint.getCoordY()),m_couleur(copiePoint.getColor())
|
|
{}
|
|
|
|
SHORT point :: getCoordX(void)
|
|
{
|
|
return m_x;
|
|
}
|
|
|
|
SHORT point :: getCoordY(void)
|
|
{
|
|
return m_y;
|
|
}
|
|
|
|
ULONG point :: getColor(void)
|
|
{
|
|
return m_couleur;
|
|
}
|
|
|
|
void point :: geoTranslation(SHORT x)
|
|
{
|
|
x=m_x+x;
|
|
if(x >= 0)
|
|
{
|
|
m_x=x;
|
|
}
|
|
else
|
|
{
|
|
cout << "geoTranslation : valeur retournee negative" << endl;
|
|
};
|
|
}
|
|
|
|
void point :: geoTranslation(SHORT x, SHORT y)
|
|
{
|
|
x=m_x+x;
|
|
y=m_y+y;
|
|
if((x >= 0) && (y >= 0))
|
|
{
|
|
m_x=x;
|
|
m_y=y;
|
|
}
|
|
else
|
|
{
|
|
cout << "geoTranslation : valeur retournee negative" << endl;
|
|
};
|
|
}
|
|
|
|
void point :: geoHomothetie(point& centre, float k)
|
|
{
|
|
SHORT x=k*(m_x-centre.getCoordX());
|
|
SHORT y=k*(m_y-centre.getCoordY());
|
|
if((x >= 0) && (y >= 0))
|
|
{
|
|
m_x=x;
|
|
m_y=y;
|
|
}
|
|
else
|
|
{
|
|
cout << "geoHomothetie : valeur retournee negative" << endl;
|
|
};
|
|
}
|
|
|
|
void point :: geoRotation(point& centre, double degree)
|
|
{
|
|
double rad = degree*(PI/180);
|
|
SHORT x = ((m_x-centre.getCoordX()) * cos(rad)) + ((centre.getCoordY()-m_y) * sin(rad)) + centre.getCoordX();
|
|
SHORT y = ((m_y-centre.getCoordY()) * cos(rad)) + ((m_x-centre.getCoordX()) * sin(rad)) + centre.getCoordY();
|
|
if((x >= 0) && (y >= 0))
|
|
{
|
|
m_x=x;
|
|
m_y=y;
|
|
}
|
|
else
|
|
{
|
|
cout << "geoRotation : valeur retournee negative" << endl;
|
|
};
|
|
}
|
|
|
|
void point :: geoRotation(point& centre, double degree, bool isTrig)
|
|
{
|
|
if(isTrig==true)
|
|
{
|
|
degree = -degree;
|
|
}
|
|
double rad = degree*(PI/180);
|
|
SHORT x = ((m_x-centre.getCoordX()) * cos(rad)) + ((centre.getCoordY()-m_y) * sin(rad)) + centre.getCoordX();
|
|
SHORT y = ((m_y-centre.getCoordY()) * cos(rad)) + ((m_x-centre.getCoordX()) * sin(rad)) + centre.getCoordY();
|
|
if((x >= 0) && (y >= 0))
|
|
{
|
|
m_x=x;
|
|
m_y=y;
|
|
}
|
|
else
|
|
{
|
|
cout << "geoRotation : valeur retournee negative" << endl;
|
|
};
|
|
}
|
|
|
|
void point :: afficher(Bmp& imageTemp)
|
|
{
|
|
imageTemp.setpixel(m_x,m_y,m_couleur);
|
|
}
|
|
|
|
void point :: redefine(short x, short y, ULONG color)
|
|
{
|
|
m_x=x;
|
|
m_y=y;
|
|
m_couleur=color;
|
|
}
|
|
|
|
bool point::operator!=(const point& b) const
|
|
{
|
|
return ((b.m_x != m_x) || (b.m_y != m_y) || (b.m_couleur != m_couleur));
|
|
}
|