Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GRAPHICS.H>
//Є« бб в®зЄЁ
class Point {
public:
float x; //ॠ«млҐ Є®®а¤Ё вл
float y;
float z;
float mx; //Є®®а¤Ё вл ¤«п ўлў®¤ нЄа
float my;
float offset[3]; //㦮 ¤«п Ї®«гзҐЁп Їа®ҐЄжЁЁ
Point(); //ваЁ Є®бвагЄв®а
Point(int x1,int y1, int z1);
Point ( Point& Point );
void SetOffset(int xoff, int yoff, int zoff);
void Perspective();
//ЏҐаҐ®ЇаҐ¤Ґ«ҐЁҐ § Є®ў ®ЇҐа жЁ© ¤«п Їа®бв®вл а Ў®вл б Є« бᮬ
Point& operator = ( Point& tochka );
Point& operator -= ( Point& tochka );
Point& operator += ( Point& tochka );
Point& operator /= ( float Value );
Point& operator *= ( float Value );
};
Point::Point() {}
Point::Point(int x1,int y1, int z1)
{
x=x1;
y=y1;
z=z1;
}
Point :: Point ( Point& tochka )
{
x = tochka.x;
y = tochka.y;
z = tochka.z;
mx = tochka.mx;
my = tochka.my;
}
//д-жЁп ЇаҐ®Ўа §®ў Ёп ॠ«мле Є®®а¤Ё в ў Є®®а¤Ё вл ¬®Ё®а (®а¬ «Ё§ жЁп)
void Point :: Perspective() {
mx=0.35*z+x+offset[0];
my=0.35*z+y+offset[1];
}
// “бв ®ўЄ Є®®а¤Ё вл жҐва ЄгЎ //
void Point :: SetOffset(int xoff, int yoff, int zoff)
{
offset[0]=xoff;
offset[1]=yoff;
offset[2]=zoff;
};
// ЏҐаҐ®ЇаҐ¤Ґ«ҐЁҐ ®ЇҐа в®а =
//‚®§¬®¦®бвм ЇаЁа ўЁў вм в®зЄЁ ¤агЈ ¤агЈг
Point& Point :: operator = ( Point& tochka )
{
x = tochka.x;
y = tochka.y;
z = tochka.z;
mx = tochka.mx;
my = tochka.my;
return ( *this );
}
// Function to subtract a point from this point. //
Point& Point :: operator -= ( Point& tochka )
{
x -= tochka.x;
y -= tochka.y;
z -= tochka.z;
Perspective();
return ( *this );
}
// Function to add a point to this point. //
Point& Point :: operator += ( Point& tochka )
{
x += tochka.x;
y += tochka.y;
z += tochka.z;
Perspective();
return ( *this );
}
// Function to add a point to this point. //
Point& Point :: operator /= ( float Value )
{
x /= Value;
y /= Value;
z /= Value;
Perspective();
return ( *this );
}
// Scale the vector by the given amount along all axis. //
Point& Point :: operator *= ( float Amount ){
x *= Amount;
y *= Amount;
z *= Amount;
Perspective();
return ( *this );
}