Skip to content

Commit

Permalink
RCP build
Browse files Browse the repository at this point in the history
  • Loading branch information
skramm committed Dec 12, 2023
1 parent 958646e commit 450537c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions homog2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6061,6 +6061,7 @@ Two tasks:
}; // class PolylineBase

/// Build a Regular Convex Polygon of radius \c rad with \c n points, centered at (0,0)
/// \todo handle sin() and cos() to support ttmath
template<typename PLT,typename FPT>
template<typename FPT2>
void
Expand All @@ -6070,12 +6071,13 @@ PolylineBase<PLT,FPT>::impl_constr_RCP( FPT2 rad, size_t n, const detail::PlHelp
HOMOG2D_THROW_ERROR_1( "unable, nb of points must be > 2" );
if( rad <= 0 )
HOMOG2D_THROW_ERROR_1( "unable, radius must be >= 0" );

std::vector<Point2d_<HOMOG2D_INUMTYPE>> v_pts(n);
auto it = std::begin( v_pts );
auto angle0 = (HOMOG2D_INUMTYPE)2. * M_PI / n;
for( size_t i=0; i<n; i++ )
{
HOMOG2D_INUMTYPE angle = (HOMOG2D_INUMTYPE)2. * M_PI * i / n;
std::cout << i << ": angle=" << angle * 180 / M_PI << '\n';
auto angle = angle0 * i;
auto x = std::cos( angle );
auto y = std::sin( angle );
*it = Point2d_<HOMOG2D_INUMTYPE>( x * rad, y * rad );
Expand Down
9 changes: 4 additions & 5 deletions misc/demo_opencv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,18 +1660,17 @@ void demo_orthSeg( int demidx )
struct Param_RCP : Data
{
explicit Param_RCP( int demidx, std::string title ): Data( demidx, title )
{

}
{}
size_t nbPts = 5;
};

void action_RCP( void* param )
{
auto& data = *reinterpret_cast<Param_RCP*>(param);
data.clearImage();
CPolyline pol(100, data.nbPts );
pol.translate(150,150);
CPolyline pol(180, data.nbPts );
std::cout << " -Building Regular Convex Polygon with " << data.nbPts << " points\n";
pol.translate(250,200);
pol.draw( data.img );
data.showImage();
}
Expand Down

0 comments on commit 450537c

Please sign in to comment.