-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRay.h
More file actions
30 lines (23 loc) · 775 Bytes
/
Ray.h
File metadata and controls
30 lines (23 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// Created by Bray, Matthew D ERDC-RDE-GSL-MS CIV on 11/23/22.
//
#ifndef RAYCASTER_RAY_H
#define RAYCASTER_RAY_H
#include <Eigen/Core>
using Vector4f = Eigen::Vector4f;
using Matrix4f = Eigen::Matrix4f;
class Ray {
public:
Ray() : origin(0.0f, 0.0f, 0.0f, 1.0f), direction(0.0f, 0.0f, 0.0f, 0.0f) {}
Ray(const Vector4f& origin, const Vector4f& direction) : origin(origin), direction(direction) {}
Ray(const Ray& ray) : origin(ray.origin), direction(ray.direction) {}
Vector4f origin;
Vector4f direction;
Vector4f position(float t) const {
return origin + (direction * t);
}
Ray transform_ray(const Matrix4f& transform) const {
return Ray(transform * origin, transform * direction);
}
};
#endif //RAYCASTER_RAY_H