diff --git a/.idea/.name b/.idea/.name index ad926c8..5aa6adf 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -block \ No newline at end of file +VolsVecs \ No newline at end of file diff --git a/apps/main.cpp b/apps/main.cpp index 530de5c..38fa874 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -3,8 +3,8 @@ int main(int argc, char **argv) { std::cout << "Hello, world!" << std::endl; - Vector::Vector3 vec(1,2,3); - Vector::Vector3 vec2(2,1,3); + LinAlg::Vector3 vec(1, 2, 3); + LinAlg::Vector3 vec2(2, 1, 3); Volumes::Block block(vec,1,1,1); std::cout< -namespace Vector{ +namespace LinAlg{ class Vector3{ public: Vector3(double x,double y, double z):x(x),y(y),z(z){}; diff --git a/src/block.cpp b/src/block.cpp index d5d3c17..91143ca 100644 --- a/src/block.cpp +++ b/src/block.cpp @@ -5,9 +5,9 @@ namespace Volumes{ double Block::getVolume() { - Vector::Vector3 x=corners[1]-corners[0]; - Vector::Vector3 y=corners[3]-corners[0]; - Vector::Vector3 z=corners[7]-corners[0]; + LinAlg::Vector3 x= corners[1] - corners[0]; + LinAlg::Vector3 y= corners[3] - corners[0]; + LinAlg::Vector3 z= corners[7] - corners[0]; return x.len()*y.len()*z.len(); } } \ No newline at end of file diff --git a/src/matrix3.cpp b/src/matrix3.cpp new file mode 100644 index 0000000..682209a --- /dev/null +++ b/src/matrix3.cpp @@ -0,0 +1,10 @@ +// +// Created by nb on 07.07.24. +// +#include "LinAlg/matrix3.h" + +namespace LinAlg{ + short Matrix3::getIndex(int x, int y) { + return x+y*3; + } +} \ No newline at end of file diff --git a/src/vector3.cpp b/src/vector3.cpp index 7b7b7b1..12efec9 100644 --- a/src/vector3.cpp +++ b/src/vector3.cpp @@ -1,22 +1,22 @@ #include "Vector/vector3.h" -namespace Vector{ - Vector3 Vector3::operator+(const Vector::Vector3 &v) const { +namespace LinAlg{ + Vector3 Vector3::operator+(const LinAlg::Vector3 &v) const { return {x+v.x,y+v.y,z+v.z}; } - Vector3& Vector3::operator=(const Vector::Vector3 &v) = default; + Vector3& Vector3::operator=(const LinAlg::Vector3 &v) = default; - Vector3& Vector3::operator+=(const Vector::Vector3 &v) { + Vector3& Vector3::operator+=(const LinAlg::Vector3 &v) { *this=*this+v; return *this; } - double Vector3::dot(const Vector::Vector3 &v) const { + double Vector3::dot(const LinAlg::Vector3 &v) const { return x*v.x+y*v.y+z*v.z; } - Vector3 Vector3::cross(const Vector::Vector3& v) const { + Vector3 Vector3::cross(const LinAlg::Vector3& v) const { return {y*v.z-v.y*z,z*v.x-v.z*x,x*v.y-v.x*y}; } @@ -33,7 +33,7 @@ namespace Vector{ return *this; } - Vector3 &Vector3::operator-=(const Vector::Vector3 &v) { + Vector3 &Vector3::operator-=(const LinAlg::Vector3 &v) { *this=*this-v; return *this; }