aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/math/Transformations.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/math/Transformations.h')
-rw-r--r--meowpp/math/Transformations.h56
1 files changed, 24 insertions, 32 deletions
diff --git a/meowpp/math/Transformations.h b/meowpp/math/Transformations.h
index b712558..b9583f9 100644
--- a/meowpp/math/Transformations.h
+++ b/meowpp/math/Transformations.h
@@ -50,17 +50,14 @@ template<class Scalar>
class BallProjection: public Transformation<Scalar> {
private:
struct Myself {
- Scalar radius_;
size_t dimension_;
+ Scalar radius_;
- Myself() {
+ Myself(size_t d): dimension_(1), radius_(1) {
}
- ~Myself() {
+ Myself(size_t d, Scalar const& r): dimension_(d), radius_(r) {
}
- Myself& copyFrom(Myself const& b) {
- radius_ = b.radius_;
- dimension_ = b.dimension_;
- return *this;
+ Myself(Myself const& m): dimension_(m.dimension_), radius_(m.radius_) {
}
};
@@ -70,18 +67,16 @@ public:
* Constructor, copy settings from given BallProjection
* @param [in] b another ball projection class
*/
- BallProjection(BallProjection const& b):
- Transformation<Scalar>(b), self(false) {
- copyFrom(b);
+ BallProjection(BallProjection const& b): Transformation<Scalar>(b),
+ self(b.self, Self<Myself>::COPY_FROM) {
}
/*!
* Constructor and setup, radius = 1
* @param [in] d Dimension of the input/output vector
*/
- BallProjection(size_t d): self(true),
- Transformation<Scalar>(d, 1, d, 1, 1) {
- self()->dimension_ = d;
+ BallProjection(size_t d): Transformation<Scalar>(d, 1, d, 1, 1),
+ self(Myself(d)) {
radius(1);
}
@@ -90,9 +85,8 @@ public:
* @param [in] d Dimension of the input/output vector
* @param [in] r Radius of the hyper-sphere
*/
- BallProjection(size_t d, Scalar const& r):
- Transformation<Scalar>(d, 1, d, 1, 1), self(true) {
- self()->dimension_ = d;
+ BallProjection(size_t d, Scalar const& r): Transformation<Scalar>(d,1,d,1,1),
+ self(Myself(d, r)) {
radius(r);
}
@@ -334,41 +328,40 @@ private:
Myself() {
}
- ~Myself() {
+
+ Myself(size_t d, Scalar f): focal_(f), dimension_(d) {
}
- Myself& copyFrom(Myself const& b) {
- focal_ = b.focal_;
- dimension_ = b.dimension_;
- return *this;
+
+ Myself(Myself const& b): focal_(b.focal_), dimension_(b.dimension_) {
+ }
+
+ ~Myself() {
}
};
- Self<Myself> const& self;
+ Self<Myself> const self;
public:
/*!
* Constructor, focal = 1
*/
PhotoProjection(size_t dimension):
- Transformation<Scalar>(dimension, 1, dimension, 1, 1), self(true) {
- self()->dimension_ = dimension;
- focal(1);
+ Transformation<Scalar>(dimension, 1, dimension, 1, 1),
+ self(Myself(dimension, 1)) {
}
/*!
* Constructor
*/
PhotoProjection(size_t dimension, Scalar const& f):
- Transformation<Scalar>(dimension, 1, dimension, 1, 1), self(true) {
- self()->dimension_ = dimension;
- focal(f);
+ Transformation<Scalar>(dimension, 1, dimension, 1, 1),
+ self(Myself(dimension, f)) {
}
/*!
* Constructor, copy settings from another PhotoProjection.
*/
- PhotoProjection(PhotoProjection const& p):
- Transformation<Scalar>(p), self(false) {
- self().copyFrom(p.self);
+ PhotoProjection(PhotoProjection const& p): Transformation<Scalar>(p),
+ self(p.self, Self<Myself>::COPY_FROM) {
}
/*!
@@ -510,7 +503,6 @@ public:
* .
* Then the jacobian matrix is like below: \n
* \f[
- * f \times
* \left[
* \begin{array}{c}
* \frac{-x_1}{x_N} \\