summaryrefslogtreecommitdiff
path: root/lib/ray.h
blob: 9bf47af4a9ad6a7cd064b1a45b80ec0b08e2ba9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#pragma once

#include <glm/glm.hpp>
#include <span>

class Ray {
public:
	Ray(glm::vec3 start, glm::vec3 direction) : start {start}, direction {direction} { }

	static Ray fromPoints(glm::vec3, glm::vec3);

	glm::vec3 start;
	glm::vec3 direction;

	float distanceToLine(const glm::vec3 & a, const glm::vec3 & b) const;
	bool passesCloseToEdges(const std::span<const glm::vec3> positions, float distance) const;
};