Line.h 623 Bytes
Newer Older
Srb František's avatar
Srb František committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include <vector>
#include <string>
#include <fstream>
#include <tuple>
using tuple_color = std::tuple<float, float, float>;

class Line
{
public:
	float x1,y1,r1,g1,b1,x2,y2,r2,g2,b2;
	Line(float x1, float y1, float x2, float y2);
	Line(float x1,float y1,float x2, float y2,tuple_color color1, tuple_color color2);
	static Line normalize(int x1, int y1, int x2, int y2,int width,int height,tuple_color color1, tuple_color color2);
	float length() {
		float dx = x1 - x2;
		float dy = y1 - y2;
		return sqrt(dx * dx + dy * dy);
	}
	~Line();
	static Line ray_cast(Line ray, const std::vector<Line>& walls);
};