#include <iostream>
using std::cout;
using std::endl;
struct Point
{
Point();
Point(const double x, const double y, const double z);
double x;
double y;
double z;
};
Point::Point() :
x(0.0), y(0.0), z(0.0)
{}
Point::Point(const double x, const double y, const double z) :
x(x), y(y), z(z)
{}
Point operator+(const Point& first, const Point& second)
{
return Point(first.x + second.x,
first.y + second.y,
first.z + second.z);
}
Point operator*(const double factor, const Point& p)
{
return Point(factor * p.x,
factor * p.y,
factor * p.z);
}
Point operator*(const Point& p, const double factor)
{
return Point(factor * p.x,
factor * p.y,
factor * p.z);
}
double operator*(const Point& a, const Point& b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
Point cross(const Point& a, const Point& b)
{
return Point(a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x);
}
void print(const Point& p)
{
cout << "x: " << p.x << endl;
cout << "y: " << p.y << endl;
cout << "z: " << p.z << endl;
}
int main()
{
Point p(1.0, 2.0, 3.0);
Point q = 0.2 * p;
print(p);
print(q);
cout << "Skalarprodukt: " << p * q << endl;
print(cross(p, Point(2.0, 3.0, 1.0)));
return 0;
}