summaryrefslogtreecommitdiffhomepage
path: root/cv/affine.cpp
blob: 1b37305cd4660351f249eb3ecc9b9cb9f75053c2 (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
/* Copyright (c) 2012 Patrick Ruoff
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#include "affine.hpp"

namespace affine_impl {

Affine::Affine() : R(mat33::eye()), t(0,0,0) {}

Affine::Affine(const mat33& R, const vec3& t) : R(R),t(t) {}

Affine operator*(const Affine& X, const Affine& Y)
{
    return Affine(X.R*Y.R, X.R*Y.t + X.t);
}

Affine operator*(const mat33& X, const Affine& Y)
{
    return Affine(X*Y.R, X*Y.t);
}

Affine operator*(const Affine& X, const mat33& Y)
{
    return Affine(X.R*Y, X.t);
}

vec3 operator*(const Affine& X, const vec3& v)
{
    return X.R*v + X.t;
}

} // ns affine_impl