shape_line_chain ans shape_poly_det: add Rotate() geometric transform, useful for DRAWSEGMENT transforms
This commit is contained in:
parent
7586afd530
commit
992820f722
|
@ -35,6 +35,17 @@ bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
|
|||
}
|
||||
|
||||
|
||||
void SHAPE_LINE_CHAIN::Rotate( double aAngle, const VECTOR2I& aCenter )
|
||||
{
|
||||
for( std::vector<VECTOR2I>::iterator i = m_points.begin(); i != m_points.end(); ++i )
|
||||
{
|
||||
(*i) -= aCenter;
|
||||
(*i) = (*i).Rotate( aAngle );
|
||||
(*i) += aCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance ) const
|
||||
{
|
||||
BOX2I box_a( aSeg.A, aSeg.B - aSeg.A );
|
||||
|
|
|
@ -1536,6 +1536,18 @@ void SHAPE_POLY_SET::Move( const VECTOR2I& aVector )
|
|||
}
|
||||
|
||||
|
||||
void SHAPE_POLY_SET::Rotate( double aAngle, const VECTOR2I& aCenter )
|
||||
{
|
||||
for( POLYGON& poly : m_polys )
|
||||
{
|
||||
for( SHAPE_LINE_CHAIN& path : poly )
|
||||
{
|
||||
path.Rotate( aAngle, aCenter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SHAPE_POLY_SET::TotalVertices() const
|
||||
{
|
||||
int c = 0;
|
||||
|
|
|
@ -595,6 +595,14 @@ public:
|
|||
(*i) += aVector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Rotate
|
||||
* rotates all vertices by a given angle
|
||||
* @param aCenter is the rotation center
|
||||
* @param aAngle rotation angle in radians
|
||||
*/
|
||||
void Rotate( double aAngle, const VECTOR2I& aCenter );
|
||||
|
||||
bool IsSolid() const override
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -864,6 +864,14 @@ class SHAPE_POLY_SET : public SHAPE
|
|||
/// @copydoc SHAPE::Move()
|
||||
void Move( const VECTOR2I& aVector ) override;
|
||||
|
||||
/**
|
||||
* Function Rotate
|
||||
* rotates all vertices by a given angle
|
||||
* @param aCenter is the rotation center
|
||||
* @param aAngle rotation angle in radians
|
||||
*/
|
||||
void Rotate( double aAngle, const VECTOR2I& aCenter );
|
||||
|
||||
/// @copydoc SHAPE::IsSolid()
|
||||
bool IsSolid() const override
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue