Files
omath/include/omath/collision/line_tracer.hpp
Orange d74c66990a Refactors: Moves linear algebra to new directory
Moves linear algebra headers to a new subdirectory to improve project structure.

Updates includes to reflect the directory change.
Adds vcpkg to the tracked repositories.
2025-08-31 23:36:05 +03:00

38 lines
1003 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// Created by Orange on 11/13/2024.
//
#pragma once
#include "omath/linear_algebra/vector3.hpp"
#include "omath/triangle.hpp"
namespace omath::collision
{
class Ray
{
public:
Vector3<float> start;
Vector3<float> end;
bool infinite_length = false;
[[nodiscard]]
Vector3<float> direction_vector() const noexcept;
[[nodiscard]]
Vector3<float> direction_vector_normalized() const noexcept;
};
class LineTracer
{
public:
LineTracer() = delete;
[[nodiscard]]
static bool can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
// Realization of MöllerTrumbore intersection algorithm
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
[[nodiscard]]
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
};
} // namespace omath::collision