|
Geometry : |
Subject: [ggl] Segment Transformation
From: Barend Gehrels (barend)
Date: 2011-09-16 01:54:31
Hi Bernhard,
>
> I'm trying to transform segments, but it doesn't work. Is this a bug, or am
> I doing something wrong?
> Slightly changed transformation example:
>
> #include<boost/geometry.hpp>
> int main()
> {
> namespace trans = boost::geometry::strategy::transform;
> using boost::geometry::dsv;
>
> typedef boost::geometry::model::point<double, 2,
> boost::geometry::cs::cartesian> point_type;
> typedef boost::geometry::model::segment<point_type> segment_type;
>
> point_type p1(1.0, 1.0);
> point_type p2(2.0, 2.0);
> segment_type s1(p1, p2);
> segment_type s2;
>
> // Translate over (1.5, 1.5)
> trans::translate_transformer<segment_type, segment_type>
> translate(1.5, 1.5);
> //trans::rotate_transformer<segment_type, segment_type,
> boost::geometry::degree> rot(90);
> boost::geometry::transform(s1, s2, translate);
>
> return 0;
> }
>
The transformers should be declared like this:
trans::translate_transformer<point_type, point_type> translate(1.5, 1.5);
It then works perfectly.
So the rationale is that this strategy (most, nearly all) are declared
using a point-type as a template parameter. The free functions then work
on any parameter type.
Regards, Barend
Geometry list run by mateusz at loskot.net