Simple Ray class
This commit is contained in:
@@ -3,8 +3,12 @@ set(target project_core)
|
||||
add_library(${target}
|
||||
core.cpp
|
||||
core.hpp
|
||||
Ray.cpp
|
||||
Ray.hpp
|
||||
)
|
||||
|
||||
target_compile_features(${target} PRIVATE cxx_std_23)
|
||||
|
||||
# target_link_libraries(${target} PRIVATE)
|
||||
target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(${target} PUBLIC Eigen3::Eigen)
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "Ray.hpp"
|
||||
|
||||
core::Ray::Ray(const Eigen::Vector3d &origin, const Eigen::Vector3d &direction)
|
||||
: origin_(origin), direction_(direction) {}
|
||||
|
||||
const Eigen::Vector3d &core::Ray::origin() const { return origin_; }
|
||||
|
||||
const Eigen::Vector3d &core::Ray::direction() const { return direction_; }
|
||||
|
||||
Eigen::Vector3d core::Ray::pointAt(const double t) const {
|
||||
return origin_ + (t * direction_);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef RAY_HPP
|
||||
#define RAY_HPP
|
||||
|
||||
#include <Eigen/Dense>
|
||||
|
||||
namespace core {
|
||||
|
||||
class Ray {
|
||||
public:
|
||||
Ray(const Eigen::Vector3d &origin, const Eigen::Vector3d &direction);
|
||||
~Ray() = default;
|
||||
|
||||
const Eigen::Vector3d &origin() const;
|
||||
|
||||
const Eigen::Vector3d &direction() const;
|
||||
|
||||
Eigen::Vector3d pointAt(const double t) const;
|
||||
|
||||
private:
|
||||
Eigen::Vector3d origin_;
|
||||
Eigen::Vector3d direction_;
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user