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

#include "config/types.h"
#include <glm/glm.hpp>
#include <span>

class Ray {
public:
#ifndef __cpp_aggregate_paren_init
	Ray(Position3D start, Direction3D direction) : start {start}, direction {direction} { }
#endif

	static Ray fromPoints(Position3D, Position3D);

	Position3D start;
	Direction3D direction;

	[[nodiscard]] float distanceToLine(const Position3D & a, const Position3D & b) const;
	[[nodiscard]] bool passesCloseToEdges(const std::span<const Position3D> positions, float distance) const;
};