31 #if defined(RigidTransformation3D_RECURSES)
32 #error Recursive header files inclusion detected in RigidTransformation3D.h
33 #else // defined(RigidTransformation3D_RECURSES)
35 #define RigidTransformation3D_RECURSES
37 #if !defined RigidTransformation3D_h
39 #define RigidTransformation3D_h
48 #include "DGtal/base/Common.h"
49 #include <DGtal/kernel/domains/CDomain.h>
69 template <
typename TSpace>
78 typedef typename TSpace::Point
Point;
92 const double & angle,
const RealVector & aTranslate )
97 if ( std::isnan(
axis.norm() ) )
98 throw std::runtime_error (
"Axis of rotation can not be set as a vector of length 0!" );
99 t_sin = std::sin ( angle );
100 t_cos = std::cos ( angle );
114 + ( ( axis[0] * axis[1] * ( 1. -
t_cos ) - axis[2] *
t_sin ) * ( aInput[1] -
origin[1] ) )
115 + ( ( axis[1] * t_sin + axis[0] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[2] -
origin[2] ) ) ) +
trans[0] ) +
origin[0] + 0.5 );
117 p[1] = std::floor ( ( ( ( ( axis[2] * t_sin + axis[0] * axis[1] * ( 1. -
t_cos ) ) * ( aInput[0] -
origin[0] ) )
118 + ( (
t_cos + ( axis[1] * axis[1] ) * ( 1. -
t_cos ) ) * ( aInput[1] -
origin[1] ) )
119 + ( ( -axis[0] * t_sin + axis[1] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[2] -
origin[2] ) ) ) +
trans[1] ) +
origin[1] + 0.5 );
121 p[2] = std::floor ( ( ( ( ( -axis[1] * t_sin + axis[0] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[0] -
origin[0] ) )
122 + ( ( axis[0] * t_sin + axis[1] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[1] -
origin[1] ) )
150 template <
typename TSpace>
159 typedef typename TSpace::Point
Point;
173 const double & angle,
const RealVector & aTranslate )
176 if ( std::isnan(
axis.norm() ) )
177 throw std::runtime_error (
"Axis of rotation can not be set as a vector of length 0!" );
179 t_sin = std::sin ( angle );
180 t_cos = std::cos ( angle );
194 + ( ( axis[2] *
t_sin + axis[0] * axis[1] * ( 1. -
t_cos ) ) * ( aInput[1] -
trans[1] -
origin[1] ) )
197 p[1] = std::floor ( ( ( ( ( axis[0] * axis[1] * ( 1. -
t_cos ) - axis[2] *
t_sin ) * ( aInput[0] -
trans[0] -
origin[0] ) )
199 + ( ( axis[0] * t_sin + axis[1] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[2] -
trans[2] -
origin[2] ) ) ) ) +
origin[1] + 0.5 );
201 p[2] = std::floor ( ( ( ( ( axis[1] * t_sin + axis[0] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[0] -
trans[0] -
origin[0] ) )
202 + ( ( -axis[0] * t_sin + axis[1] * axis[2] * ( 1. -
t_cos ) ) * ( aInput[1] -
trans[1] -
origin[1] ) )
227 template <
typename TDomain,
typename TRig
idTransformFunctor >
229 std::unary_function < std::pair < typename TDomain::Point, typename TDomain::Point >, TDomain>
237 typedef std::pair < typename TDomain::Space::Point, typename TDomain::Space::Point >
Bounds;
255 typedef typename TDomain::Point Point;
258 points[0] =
transform ( aInput.lowerBound() );
259 points[1] =
transform ( aInput.upperBound() );
260 points[2] =
transform ( Point ( aInput.upperBound()[0], aInput.lowerBound()[1], aInput.lowerBound()[2] ) );
261 points[3] =
transform ( Point ( aInput.lowerBound()[0], aInput.upperBound()[1], aInput.upperBound()[2] ) );
262 points[4] =
transform ( Point ( aInput.upperBound()[0], aInput.lowerBound()[1], aInput.upperBound()[2] ) );
263 points[5] =
transform ( Point ( aInput.lowerBound()[0], aInput.upperBound()[1], aInput.lowerBound()[2] ) );
264 points[6] =
transform ( Point ( aInput.lowerBound()[0], aInput.lowerBound()[1], aInput.upperBound()[2] ) );
265 points[7] =
transform ( Point ( aInput.upperBound()[0], aInput.upperBound()[1], aInput.lowerBound()[2] ) );
267 typename Point::Component cmax = std::numeric_limits<typename Point::Component>::max();
268 typename Point::Component cmin = std::numeric_limits<typename Point::Component>::min();
269 Point t_min ( cmax, cmax, cmax ), t_max ( cmin, cmin, cmin );
270 for (
int i = 0; i < 8; i++ )
272 if ( points[i][0] < t_min[0] )
273 t_min[0] = points[i][0];
274 if ( points[i][1] < t_min[1] )
275 t_min[1] = points[i][1];
276 if ( points[i][2] < t_min[2] )
277 t_min[2] = points[i][2];
279 if ( points[i][0] > t_max[0] )
280 t_max[0] = points[i][0];
281 if ( points[i][1] > t_max[1] )
282 t_max[1] = points[i][1];
283 if ( points[i][2] > t_max[2] )
284 t_max[2] = points[i][2];
287 bounds.first = t_min;
288 bounds.second = t_max;
300 #endif // !defined RigidTransformation3D_h
302 #undef RigidTransformation3D_RECURSES
303 #endif // else defined(RigidTransformation3D_RECURSES)
DomainRigidTransformation3D(const TRigidTransformFunctor &aRigidFunctor)
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
std::pair< typename TDomain::Space::Point, typename TDomain::Space::Point > Bounds
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Bounds operator()(const TDomain &aInput) const
DGtal is the top-level namespace which contains all DGtal functions and types.
BOOST_STATIC_ASSERT((TDomain::dimension==3))
Checking concepts.
Aim: implements bounds of transformed domain.
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
const TRigidTransformFunctor & transform