summaryrefslogtreecommitdiff
path: root/src/linalg.h
blob: cb82452cda6ed3a1523a0275f1101bab8402ce15 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef LINALG_H_
#define LINALG_H_

#include <Eigen/Core>
#include <Eigen/Geometry>
#include <Eigen/Dense>
#include<Eigen/StdVector>

EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2d)
using Eigen::Vector2d;
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3d)
using Eigen::Vector3d;

typedef Eigen::AlignedBox<double, 3> BoundingBox;
using Eigen::Matrix3f;
using Eigen::Matrix3d;
using Eigen::Matrix4d;
#if EIGEN_WORLD_VERSION >= 3
#define Transform3d Eigen::Affine3d
#else
using Eigen::Transform3d;
#endif

bool matrix_contains_infinity( const Transform3d &m );
bool matrix_contains_nan( const Transform3d &m );

BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
Vector3d getBoundingCenter(BoundingBox bbox);
double getBoundingRadius(BoundingBox bbox);


class Color4f : public Eigen::Vector4f
{
public:
	Color4f() { }
	Color4f(int r, int g, int b, int a = 255) { setRgb(r,g,b,a); }
	Color4f(float r, float g, float b, float a = 1.0f) : Eigen::Vector4f(r, g, b, a) { }

	void setRgb(int r, int g, int b, int a = 255) {
		*this << r/255.0f, g/255.0f, b/255.0f, a/255.0f;
	}

	bool isValid() const { return this->minCoeff() >= 0.0f; }
};

#endif
contact: Jan Huwald // Impressum