66 lines
1.2 KiB
C
66 lines
1.2 KiB
C
|
//
|
||
|
// Created by nb on 07.07.24.
|
||
|
//
|
||
|
|
||
|
#ifndef VECTOR_VECTOR3_H
|
||
|
#define VECTOR_VECTOR3_H
|
||
|
|
||
|
#include "iostream"
|
||
|
#include <cmath>
|
||
|
|
||
|
namespace Vector{
|
||
|
class Vector3{
|
||
|
public:
|
||
|
Vector3(double x,double y, double z):x(x),y(y),z(z){};
|
||
|
Vector3(): Vector3(0,0,0){};
|
||
|
|
||
|
virtual ~Vector3() = default;
|
||
|
|
||
|
Vector3 operator+(const Vector3& v) const;
|
||
|
|
||
|
Vector3 operator-(const Vector3& v) const{
|
||
|
Vector3 tmp=v*-1;
|
||
|
return *this+tmp;
|
||
|
};
|
||
|
|
||
|
Vector3 operator*(double s) const;
|
||
|
|
||
|
Vector3 operator/(double s) const{
|
||
|
return *this*(1/s);
|
||
|
};
|
||
|
|
||
|
Vector3& operator*=(double s);
|
||
|
|
||
|
Vector3& operator/=(double s){
|
||
|
return *this*=(1/s);
|
||
|
};
|
||
|
|
||
|
Vector3& operator+=(const Vector3& v);
|
||
|
|
||
|
Vector3& operator-=(const Vector3& v);
|
||
|
|
||
|
Vector3& operator=(const Vector3& v);
|
||
|
|
||
|
|
||
|
|
||
|
Vector3& norm();
|
||
|
|
||
|
double dot(const Vector3& v) const;
|
||
|
|
||
|
double len() const;
|
||
|
|
||
|
Vector3 cross(const Vector3& v) const;
|
||
|
|
||
|
friend std::ostream& operator<<(std::ostream& os, const Vector3& v){
|
||
|
os<<"{"<<v.x<<", "<<v.y<<", "<<v.z<<"}";
|
||
|
return os;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
double x,y,z;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif //VECTOR_VECTOR3_H
|