23 changed files with 134 additions and 101 deletions
@ -1,51 +1,7 @@ |
|||
#pragma once |
|||
|
|||
|
|||
#include <Eigen/Dense> |
|||
|
|||
#include <type_traits> |
|||
|
|||
|
|||
using Byte = unsigned char; |
|||
using Index = uint32_t; |
|||
|
|||
using Real = float; |
|||
|
|||
using Vector2 = Eigen::Matrix<Real, 2, 1>; |
|||
using Vector3 = Eigen::Matrix<Real, 3, 1>; |
|||
using Vector4 = Eigen::Matrix<Real, 4, 1>; |
|||
|
|||
using Matrix2 = Eigen::Matrix<Real, 2, 2>; |
|||
using Matrix3 = Eigen::Matrix<Real, 3, 3>; |
|||
using Matrix4 = Eigen::Matrix<Real, 4, 4>; |
|||
|
|||
using Transform = Eigen::Transform<Real, 3, Eigen::Affine>; |
|||
using AngleAxis = Eigen::AngleAxis<Real>; |
|||
using Quaternion = Eigen::Quaternion<Real>; |
|||
|
|||
using Triangle = Eigen::Array<Index, 3, 1>; |
|||
|
|||
|
|||
template<typename Scalar, typename Derived0, typename Derived1> |
|||
auto lerp( |
|||
Scalar factor, |
|||
const Eigen::MatrixBase<Derived0>& m0, |
|||
const Eigen::MatrixBase<Derived1>& m1 |
|||
) -> std::enable_if_t< |
|||
Derived0::RowsAtCompileTime == Derived1::RowsAtCompileTime && |
|||
Derived0::ColsAtCompileTime == Derived1::ColsAtCompileTime, |
|||
Eigen::Matrix< |
|||
std::common_type_t< |
|||
Scalar, |
|||
typename Derived0::Scalar, |
|||
typename Derived1::Scalar |
|||
>, |
|||
Derived0::RowsAtCompileTime, |
|||
Derived0::ColsAtCompileTime |
|||
> |
|||
> { |
|||
return (Scalar(1) - factor) * m0 + factor * m1; |
|||
} |
|||
#include <core/types.h> |
|||
|
|||
|
|||
template<typename T> |
|||
@ -1,4 +1,4 @@ |
|||
#include <Logger.h> |
|||
#include <core/Logger.h> |
|||
|
|||
#include <iostream> |
|||
|
|||
@ -1,28 +1,5 @@ |
|||
#include <utils.h> |
|||
#include <core/math.h> |
|||
|
|||
#include <cstring> |
|||
#include <fstream> |
|||
|
|||
|
|||
Uuid make_uuid(uint8_t const* bytes) { |
|||
Uuid uuid; |
|||
std::memcpy(uuid.data(), bytes, UUID_SIZE); |
|||
return uuid; |
|||
} |
|||
|
|||
std::vector<char> read_binary_file(const char* path) { |
|||
std::ifstream istream(path, std::ios_base::ate | std::ios_base::binary); |
|||
if(!istream.is_open()) |
|||
throw std::runtime_error(cat("failed to open '", path, "'")); |
|||
|
|||
std::vector<char> buffer(size_t(istream.tellg())); |
|||
|
|||
istream.seekg(0); |
|||
istream.read(buffer.data(), buffer.size()); |
|||
istream.close(); |
|||
|
|||
return buffer; |
|||
} |
|||
|
|||
Eigen::Matrix4f projection_matrix(float x_min, float x_max, float y_min, float y_max, float z_min, float z_max) { |
|||
auto const cx = x_max + x_min; |
|||
@ -0,0 +1,54 @@ |
|||
#pragma once |
|||
|
|||
|
|||
#include <core/types.h> |
|||
|
|||
#include <Eigen/Dense> |
|||
|
|||
#include <type_traits> |
|||
|
|||
|
|||
using Real = float; |
|||
|
|||
using Vector2 = Eigen::Matrix<Real, 2, 1>; |
|||
using Vector3 = Eigen::Matrix<Real, 3, 1>; |
|||
using Vector4 = Eigen::Matrix<Real, 4, 1>; |
|||
|
|||
using Matrix2 = Eigen::Matrix<Real, 2, 2>; |
|||
using Matrix3 = Eigen::Matrix<Real, 3, 3>; |
|||
using Matrix4 = Eigen::Matrix<Real, 4, 4>; |
|||
|
|||
using Transform = Eigen::Transform<Real, 3, Eigen::Affine>; |
|||
using AngleAxis = Eigen::AngleAxis<Real>; |
|||
using Quaternion = Eigen::Quaternion<Real>; |
|||
|
|||
using Triangle = Eigen::Array<Index, 3, 1>; |
|||
|
|||
|
|||
template<typename Scalar, typename Derived0, typename Derived1> |
|||
auto lerp( |
|||
Scalar factor, |
|||
const Eigen::MatrixBase<Derived0>& m0, |
|||
const Eigen::MatrixBase<Derived1>& m1 |
|||
) -> std::enable_if_t< |
|||
Derived0::RowsAtCompileTime == Derived1::RowsAtCompileTime && |
|||
Derived0::ColsAtCompileTime == Derived1::ColsAtCompileTime, |
|||
Eigen::Matrix< |
|||
std::common_type_t< |
|||
Scalar, |
|||
typename Derived0::Scalar, |
|||
typename Derived1::Scalar |
|||
>, |
|||
Derived0::RowsAtCompileTime, |
|||
Derived0::ColsAtCompileTime |
|||
> |
|||
> { |
|||
return (Scalar(1) - factor) * m0 + factor * m1; |
|||
} |
|||
|
|||
Eigen::Matrix4f projection_matrix(float x_min, float x_max, float y_min, float y_max, float z_min, float z_max); |
|||
Eigen::Matrix4f look_at_matrix( |
|||
const Eigen::Vector3f& cam_pos, |
|||
const Eigen::Vector3f& look_at, |
|||
const Eigen::Vector3f& up |
|||
); |
|||
@ -0,0 +1,10 @@ |
|||
#pragma once |
|||
|
|||
|
|||
#include <Eigen/Dense> |
|||
|
|||
#include <type_traits> |
|||
|
|||
|
|||
using Byte = unsigned char; |
|||
using Index = uint32_t; |
|||
@ -0,0 +1,26 @@ |
|||
#include <core/utils.h> |
|||
|
|||
#include <cstring> |
|||
#include <fstream> |
|||
|
|||
|
|||
Uuid make_uuid(uint8_t const* bytes) { |
|||
Uuid uuid; |
|||
std::memcpy(uuid.data(), bytes, UUID_SIZE); |
|||
return uuid; |
|||
} |
|||
|
|||
std::vector<char> read_binary_file(const char* path) { |
|||
std::ifstream istream(path, std::ios_base::ate | std::ios_base::binary); |
|||
if(!istream.is_open()) |
|||
throw std::runtime_error(cat("failed to open '", path, "'")); |
|||
|
|||
std::vector<char> buffer(size_t(istream.tellg())); |
|||
|
|||
istream.seekg(0); |
|||
istream.read(buffer.data(), buffer.size()); |
|||
istream.close(); |
|||
|
|||
return buffer; |
|||
} |
|||
|
|||
Loading…
Reference in new issue