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