1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
#include<iostream>
#include<cmath>
#include "Klasa.h"
using namespace std;
Tacka::Tacka()
{
m_x = 0.;
m_y = 0.;
m_z = 0.;
}
Tacka::Tacka(const Tacka&p)
{
m_x = p.m_x;
m_y = p.m_y;
m_z = p.m_z;
}
void Tacka::Unos(double x, double y, double z)
{
m_x = x;
m_y = y;
m_z = z;
}
void Tacka::Mnozenje(int x)
{
m_x *= x;
m_y *= x;
m_z *= x;
}
void Tacka::Stampaj() const
{
cout << "Vrednosti dimenzija su \n";
cout << "x= " << m_x << ",y=" << m_y << ",z=" << m_z << endl;
}
Tacka Tacka::Sabiranje(const Tacka &p)
{
double x, y, z;
x = this->m_x + p.m_x;
y = this->m_y + p.m_y;
z = this->m_z + p.m_z;
Tacka novatacka;
novatacka.Unos(x, y, z);
return novatacka;
}
Tacka Tacka::Oduzimanje(const Tacka &p)
{
Tacka novatacka;
double x, y, z;
x = this->m_x - p.m_x;
y = this->m_y - p.m_y;
z = this->m_z - p.m_z;
novatacka.Unos(x, y, z);
return novatacka;
}
Tacka::~Tacka() {
}
Tacka operator*(const Tacka & t1, const Tacka & t2)
{
double x, y, z;
Tacka t;
x = t1.m_x * t2.m_x;
y = t1.m_y * t2.m_y;
z = t1.m_z * t2.m_z;
t.Unos(x, y, z);
return t;
}
bool operator<(const Tacka &t1, const Tacka &t2)
{
double x,y;
x = sqrt((t1.m_x)*(t1.m_x) + (t1.m_y)*(t1.m_y) + (t1.m_z)*(t1.m_z));
y = sqrt((t2.m_x)*(t2.m_x) + (t2.m_y)*(t2.m_y) + (t2.m_z)*(t2.m_z));
return x < y;
}
Tacka operator+(const Tacka &t1,const Tacka &t2)
{
double x, y, z;
Tacka t;
x = t1.m_x + t2.m_x;
y = t1.m_y + t2.m_y;
z = t1.m_z + t2.m_z;
t.Unos(x, y, z);
return t;
}
Tacka operator/(const Tacka &t1, int value)
{
double x, y, z;
Tacka t;
x = t1.m_x / value;
y = t1.m_y / value;
z = t1.m_z / value;
t.Unos(x, y, z);
return t;
}
Tacka operator-(const Tacka &t1, const Tacka &t2)
{
double x, y, z;
Tacka t;
x = t1.m_x - t2.m_x;
y = t1.m_y - t2.m_y;
z = t1.m_z - t2.m_z;
return t;
}
bool operator>(const Tacka &t1, const Tacka &t2)
{
double x, y;
x = sqrt((t1.m_x)*(t1.m_x) + (t1.m_y)*(t1.m_y) + (t1.m_z)*(t1.m_z));
y = sqrt((t2.m_x)*(t2.m_x) + (t2.m_y)*(t2.m_y) + (t2.m_z)*(t2.m_z));
return x > y;
}
bool operator==(const Tacka &t1, const Tacka &t2)
{
return (t1.m_x == t2.m_x && t1.m_y == t2.m_y && t1.m_z == t2.m_z);
}
istream & operator>>(istream & in, Tacka & t)
{
in >> t.m_x;
in >> t.m_y;
in >> t.m_z;
return in;
}
ostream & operator<<(ostream & out, const Tacka & t)
{
out << "Tacka(" << t.m_x << ',' << t.m_y << ',' << t.m_z << ')' << endl;
return out;
}
Tacka operator+(const Tacka &t1, int n)
{
Tacka t;
t.m_x = t1.m_x + n;
t.m_y = t1.m_y + n;
t.m_z = t1.m_z + n;
return t;
}
Tacka operator*(const Tacka &t1, int m)
{
Tacka t;
t.m_x = t1.m_x * m;
t.m_y = t1.m_y * m;
t.m_z = t1.m_z * m;
return t;
}
|