1 #ifndef math_Transformations_H__
2 #define math_Transformations_H__
49 template<
class Scalar>
56 Myself(
size_t d): dimension_(1), radius_(1) {
59 Myself(
size_t d, Scalar
const& r): dimension_(d), radius_(r) {
62 Myself(Myself
const& m): dimension_(m.dimension_), radius_(m.radius_) {
73 self(b.self,
Self<Myself>::COPY_FROM) {
135 return self->radius_;
153 return self->dimension_;
174 for (
size_t c = 0, C = ret.
cols(); c < C; c++) {
176 for (
size_t i = 0; i <
self->dimension_; i++) {
177 sum = sum +
squ(ret(i, c));
179 Scalar len(sqrt(
double(sum)));
180 for (
size_t i = 0; i <
self->dimension_; i++) {
181 ret(i, c, ret(i, c) *
radius() / len);
217 for(
size_t i = 0, I =
dimension(); i < I; ++i)
218 sum = sum +
squ(x(i, 0));
219 Scalar len(sqrt(
double(sum)));
221 for(
size_t i = 0, I =
dimension(); i < I; ++i)
222 for(
size_t j = 0; j < I; ++j)
227 ret(i, j,
radius() * (-x(i, 0) * x(j, 0) /
cub(len)));
263 for(
size_t i = 0, I =
dimension(); i < I; i++) {
264 sum = sum +
squ(x(i, 0));
266 return ret / Scalar(sqrt(
double(sum)));
324 template<
class Scalar>
334 Myself(
size_t d, Scalar f): focal_(f), dimension_(d) {
337 Myself(Myself
const& b): focal_(b.focal_), dimension_(b.dimension_) {
351 self(Myself(dimension, 1)) {
359 self(Myself(dimension, f)) {
366 self(p.self,
Self<Myself>::COPY_FROM) {
428 return self->dimension_;
450 for (
size_t c = 0, C = ret.
cols(); c < C; c++) {
451 for (
size_t i = 0, I =
dimension(); i < I; ++i) {
452 ret(i, c, -ret(i, c) *
focal() / ret(I - 1, c));
489 for(ssize_t i = 0, I = (ssize_t)
dimension() - 1; i < I; i++){
490 ret(i, i, -
focal() / x(I, 0) );
527 for(
size_t i = 0, I =
dimension(); i < I; ++i) {
528 ret(i, 0, -x(i, 0) / x(I - 1, 0));
550 #endif // Transformations_H__
PhotoProjection & operator=(PhotoProjection const &b)
Same as copyFrom(b)
Matrix< Scalar > jacobian(Matrix< Scalar > const &x) const
Return the jacobian matrix (derivate by the input vector) of this projection.
Scalar parameter(size_t i) const
Same as focal()
PhotoProjection & copyFrom(PhotoProjection const &b)
Matrix< Scalar > jacobian(Matrix< Scalar > const &x, size_t i) const
Return the jacobian matrix (derivate by radius) of this projection.
BallProjection(BallProjection const &b)
BallProjection & copyFrom(BallProjection const &b)
Copy settings from another one.
size_t cols() const
Return number of cols.
PhotoProjection & referenceFrom(PhotoProjection const &b)
BallProjection(size_t d, Scalar const &r)
PhotoProjection(PhotoProjection const &p)
Scalar parameter(size_t i) const
same as radius()
size_t dimension() const
Get the dimension of this projection.
BallProjection & referenceFrom(BallProjection const &b)
Reference settings from another one.
A ball projection is to project the given vector to a hyper-sphere.
Scalar focal() const
Get the focal length.
Matrix< Scalar > operator()(Matrix< Scalar > const &v) const
Same as transformate(v)
Matrix< Scalar > transformate(Matrix< Scalar > const &x) const
Project the input vector(s) onto the plane.
PhotoProjection(size_t dimension)
Scalar radius(Scalar const &r)
Setup the radius.
Scalar parameter(size_t i, Scalar const &s)
Same as focal(s)
Scalar focal(Scalar const &f)
Set the focal length.
Matrix< Scalar > jacobian(Matrix< Scalar > const &x) const
Return the jacobian matrix (derivate by the input vector) of this projection.
Matrix< Scalar > operator()(Matrix< Scalar > const &v) const
Same as transformate(v)
size_t dimension() const
Get the dimension of this projection.
Matrix< Scalar > transformate(Matrix< Scalar > const &x) const
Project the input vector(s) onto the hyper-sphere and return it.
A photo projection is a kind of transformation that project point/vector to a flat photo...
PhotoProjection(size_t dimension, Scalar const &f)
Matrix< Scalar > jacobian(Matrix< Scalar > const &x, size_t i) const
Return the jacobian matrix (derivate by the focus length) of this projection.
BallProjection & operator=(BallProjection const &b)
Same as copyFrom(b)
Scalar radius() const
Return the value of the radius.
Scalar parameter(size_t i, Scalar const &s)
same as radius(s)