diff --git a/src/clara.cpp b/src/clara.cpp index fe52cc066fc16ebdeb241621d4349f27cca6adf2..809a4312839be84ccecd442845b2d86e0e703a0c 100644 --- a/src/clara.cpp +++ b/src/clara.cpp @@ -89,23 +89,23 @@ double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; } -Vector Ray::get_dir() { +Vector LightRay::get_dir() { return dir; } -Point Ray::get_point() { +Point LightRay::get_point() { return p; } -void Ray::set_dir(Vector v) { +void LightRay::set_dir(Vector v) { dir = v; } -void Ray::set_point(Point pt) { +void LightRay::set_point(Point pt) { p = pt; } -std::optional<Point> Ray::collision_point(Line l) { +std::optional<Point> LightRay::collision_point(Line l) { Vector dir = get_dir(); Point p = get_point(); @@ -137,7 +137,7 @@ std::optional<Point> Ray::collision_point(Line l) { return std::nullopt; } -void Ray::collide(Object o) { +void LightRay::collide(Object o) { for (auto it = o.lines_begin(); it != o.lines_end(); it++) { std::optional<Point> collision = collision_point(*it); if (collision != std::nullopt) { // leiti punkt diff --git a/src/clara.h b/src/clara.h index 5c569efcd8d6218888a0ec32a27f76879cb3976e..ba4bbfef54f941e735daa0d30e781f67522eb927 100644 --- a/src/clara.h +++ b/src/clara.h @@ -7,7 +7,7 @@ struct Vector; struct Point; struct Line; -class Ray; +class LightRay; class Object; // todo struct Point { @@ -18,6 +18,8 @@ struct Point { Point(double ix, double iy) : x{ix}, y{iy} {}; Point(const Point &p) : x{p.x}, y{p.y} {}; + Point& operator=(const Point&) = default; + Point operator+(Vector); }; @@ -49,7 +51,7 @@ struct Vector { }; double dot(Vector, Vector); -class Ray { +class LightRay { private: Point p; Vector dir; @@ -57,7 +59,7 @@ class Ray { double refraction_index; public: - Ray(Point ip, Vector idir, double iwavelength) : p{ip}, dir{idir}, wavelength{iwavelength} {}; + LightRay(Point ip, Vector idir, double iwavelength) : p{ip}, dir{idir}, wavelength{iwavelength} {}; Vector get_dir(); Point get_point(); void set_dir(Vector); diff --git a/src/main.cpp b/src/main.cpp index 2c220607efdc23bf6321663e5b6f63fccfe88d87..ede9a8d85ff7bca68dedc7ad1bfd20b2c683b878 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include <iostream> +#include <cassert> #include "clara.h" -#include <cassert> int main() { Point p1{};