Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] troubles rotating a 2D polygon

Subject: CGAL users discussion list

List archive

[cgal-discuss] troubles rotating a 2D polygon


Chronological Thread 
  • From: Cristiano Nattero <>
  • To:
  • Subject: [cgal-discuss] troubles rotating a 2D polygon
  • Date: Fri, 12 Jun 2009 17:27:50 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=Zi7VmpmQza5LNBCdiM5KrkLyqp+QyAaLUf3NEM43nkF4PlIpBgBwsoqNeiQjuTieQk wxxRCVCInCC/BKq02VhlHIMiaFStf93tJM17I/IWb40WXZ0t4djo1GeJoihxZ8644XEI ELZDcXSmRz2IjwYID5yj1zxEtuyPUPSjVlVPM=

Hello everybody,

I'm experimenting with rotations of a 2D polygon and something
strange happens: it looks like I could rotate it CW but not CCW!

I can't spot the problem :(

Here's the code:

//------------------------------------------------------------------------------------

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Vector_2<K> Vector;
typedef CGAL::Aff_transformation_2<K> Transformation;
typedef CGAL::Polygon_2<K> Polygon;

//[...]


Polygon transformPolygon( const Polygon& P, const Vector& v, const
long double& angle )
{
Transformation t( CGAL::TRANSLATION, v );
Transformation r( cos( angle ), -sin( angle ), 0, sin( angle ), cos(
angle ), 0, 1 );
Polygon tempP;

tempP = transform( t, P );
tempP = transform( r, tempP );

return tempP;
}

//[...]

Vector v( 1, 0 );

long double angle;

//------------------------------------------------------------------------------------

v is initialized as shown above.

When I call the function with

angle = - M_PI / 2;

it works fine. It doesn't when

angle = M_PI / 2;

Where's the error?

Thank you very much for your help :-)

--
Ciao,
Cristiano Nattero


  • [cgal-discuss] troubles rotating a 2D polygon, Cristiano Nattero, 06/12/2009

Archive powered by MHonArc 2.6.16.

Top of Page