Remove unit-less angles from VECTOR2I/D APIs.
This commit is contained in:
parent
14006495d5
commit
c8a50d9b50
|
@ -721,7 +721,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
|
|||
}
|
||||
else
|
||||
{
|
||||
auto lineAngle = startEndVector.Angle();
|
||||
EDA_ANGLE lineAngle( startEndVector );
|
||||
// Outlined tracks
|
||||
|
||||
SetLineWidth( 1.0 );
|
||||
|
@ -731,7 +731,7 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP
|
|||
Save();
|
||||
|
||||
m_currentManager->Translate( aStartPoint.x, aStartPoint.y, 0.0 );
|
||||
m_currentManager->Rotate( lineAngle, 0.0f, 0.0f, 1.0f );
|
||||
m_currentManager->Rotate( lineAngle.AsRadians(), 0.0f, 0.0f, 1.0f );
|
||||
|
||||
drawLineQuad( VECTOR2D( 0.0, aWidth / 2.0 ), VECTOR2D( lineLength, aWidth / 2.0 ) );
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ using KIGFX::COLOR4D;
|
|||
|
||||
static constexpr double ANGLE_EPSILON = 1e-9;
|
||||
|
||||
static bool angleIsSpecial( double aRadians )
|
||||
static bool angleIsSpecial( EDA_ANGLE aAngle )
|
||||
{
|
||||
return std::fabs( std::remainder( aRadians, M_PI_4 ) ) < ANGLE_EPSILON;
|
||||
return std::fabs( std::remainder( aAngle.AsRadians(), M_PI_4 ) ) < ANGLE_EPSILON;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ void DRAW_CONTEXT::DrawLineWithAngleHighlight( const VECTOR2I& aStart, const VEC
|
|||
const VECTOR2I vec = aEnd - aStart;
|
||||
COLOR4D strokeColor = m_render_settings.GetLayerColor( m_currLayer );
|
||||
|
||||
if( angleIsSpecial( vec.Angle() ) )
|
||||
if( angleIsSpecial( EDA_ANGLE( vec ) ) )
|
||||
strokeColor = getSpecialAngleColour();
|
||||
|
||||
m_gal.SetLineWidth( m_lineWidth );
|
||||
|
|
|
@ -2925,15 +2925,16 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
|
|||
for( auto& pin : pins )
|
||||
{
|
||||
auto setPinOrientation =
|
||||
[&]( double aAngleRad )
|
||||
[&]( const EDA_ANGLE& aAngle )
|
||||
{
|
||||
int oDeg = (int) NormalizeAngle180( RAD2DEG( aAngleRad ) );
|
||||
EDA_ANGLE angle( aAngle );
|
||||
angle.Normalize180();
|
||||
|
||||
if( oDeg >= -45 && oDeg <= 45 )
|
||||
if( angle >= -ANGLE_45 && angle <= ANGLE_45 )
|
||||
pin->SetOrientation( 'R' ); // 0 degrees
|
||||
else if( oDeg >= 45 && oDeg <= 135 )
|
||||
else if( angle >= ANGLE_45 && angle <= ANGLE_135 )
|
||||
pin->SetOrientation( 'U' ); // 90 degrees
|
||||
else if( oDeg >= 135 || oDeg <= -135 )
|
||||
else if( angle >= ANGLE_135 || angle <= -ANGLE_135 )
|
||||
pin->SetOrientation( 'L' ); // 180 degrees
|
||||
else
|
||||
pin->SetOrientation( 'D' ); // -90 degrees
|
||||
|
@ -2951,7 +2952,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
|
|||
VECTOR2I vec( otherPt - pin->GetPosition() );
|
||||
|
||||
pin->SetLength( vec.EuclideanNorm() );
|
||||
setPinOrientation( vec.Angle() );
|
||||
setPinOrientation( EDA_ANGLE( vec ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <core/optional.h>
|
||||
#include <math/vector2d.h>
|
||||
#include <geometry/eda_angle.h>
|
||||
|
||||
typedef OPT<VECTOR2I> OPT_VECTOR2I;
|
||||
|
||||
|
@ -158,12 +159,12 @@ public:
|
|||
int LineDistance( const VECTOR2I& aP, bool aDetermineSide = false ) const;
|
||||
|
||||
/**
|
||||
* Determine the smallest angle between two segments (result in degrees)
|
||||
* Determine the smallest angle between two segments
|
||||
*
|
||||
* @param aOther point to determine the orientation wrs to self
|
||||
* @return smallest angle between this and aOther (degrees)
|
||||
* @return smallest angle between this and aOther
|
||||
*/
|
||||
double AngleDegrees( const SEG& aOther ) const;
|
||||
EDA_ANGLE Angle( const SEG& aOther ) const;
|
||||
|
||||
/**
|
||||
* Compute a point on the segment (this) that is closest to point \a aP.
|
||||
|
|
|
@ -173,21 +173,6 @@ public:
|
|||
*/
|
||||
VECTOR2<T> Resize( T aNewLength ) const;
|
||||
|
||||
/**
|
||||
* Compute the angle of the vector.
|
||||
*
|
||||
* @return the vector angle in radians.
|
||||
*/
|
||||
double Angle() const;
|
||||
|
||||
/**
|
||||
* Rotate the vector by a given angle.
|
||||
*
|
||||
* @param aAngle rotation angle in radians
|
||||
* @return rotated vector
|
||||
*/
|
||||
VECTOR2<T> Rotate( double aAngle ) const;
|
||||
|
||||
/**
|
||||
* Return the vector formatted as a string.
|
||||
*
|
||||
|
@ -316,13 +301,6 @@ typename VECTOR2<T>::extended_type VECTOR2<T>::SquaredEuclideanNorm() const
|
|||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
double VECTOR2<T>::Angle() const
|
||||
{
|
||||
return atan2( (double) y, (double) x );
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
VECTOR2<T> VECTOR2<T>::Perpendicular() const
|
||||
{
|
||||
|
@ -385,43 +363,6 @@ VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate a VECTOR2 by aAngle.
|
||||
* @param aAngle = rotation angle in radians
|
||||
*/
|
||||
template <class T>
|
||||
VECTOR2<T> VECTOR2<T>::Rotate( double aAngle ) const
|
||||
{
|
||||
// Avoid common radian rotations that may allow for angular error
|
||||
if( aAngle == 0.0 || aAngle == 2 * M_PI )
|
||||
return VECTOR2<T> ( T( x ), T( y ) );
|
||||
|
||||
if( aAngle == M_PI_2 )
|
||||
return VECTOR2<T>( -T( y ), T( x ) );
|
||||
|
||||
if( aAngle == M_PI )
|
||||
return VECTOR2<T>( -T(x), -T( y ) );
|
||||
|
||||
if( aAngle == 3 * M_PI_2 )
|
||||
return VECTOR2<T>( T( y ), -T( x ) );
|
||||
|
||||
double sa = sin( aAngle );
|
||||
double ca = cos( aAngle );
|
||||
|
||||
if( std::is_integral<T>::value )
|
||||
{
|
||||
return VECTOR2<T> ( KiROUND( (double) x * ca - (double) y * sa ),
|
||||
KiROUND( (double) x * sa + (double) y * ca ) );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return VECTOR2<T> ( T( (double) x * ca - (double) y * sa ),
|
||||
T( (double) x * sa + (double) y * ca ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
VECTOR2<T> VECTOR2<T>::Resize( T aNewLength ) const
|
||||
{
|
||||
|
|
|
@ -253,16 +253,16 @@ std::vector<VECTOR2I> CIRCLE::Intersect( const CIRCLE& aCircle ) const
|
|||
int64_t y = KiROUND( sqrt( r1sqMinusXsq ) );
|
||||
|
||||
// Now correct back to original coordinates
|
||||
double rotAngle = vecCtoC.Angle();
|
||||
VECTOR2I solution1( x, y );
|
||||
solution1 = solution1.Rotate( rotAngle );
|
||||
EDA_ANGLE rotAngle( vecCtoC );
|
||||
VECTOR2I solution1( x, y );
|
||||
RotatePoint( solution1, -rotAngle );
|
||||
solution1 += Center;
|
||||
retval.push_back( solution1 );
|
||||
|
||||
if( y != 0 )
|
||||
{
|
||||
VECTOR2I solution2( x, -y );
|
||||
solution2 = solution2.Rotate( rotAngle );
|
||||
RotatePoint( solution2, -rotAngle );
|
||||
solution2 += Center;
|
||||
retval.push_back( solution2 );
|
||||
}
|
||||
|
|
|
@ -58,16 +58,14 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
|
|||
}
|
||||
|
||||
|
||||
double SEG::AngleDegrees( const SEG& aOther ) const
|
||||
EDA_ANGLE SEG::Angle( const SEG& aOther ) const
|
||||
{
|
||||
VECTOR2I thisVec = A - B;
|
||||
VECTOR2I otherVec = aOther.A - aOther.B;
|
||||
EDA_ANGLE thisAngle = EDA_ANGLE( A - B ).Normalize180();
|
||||
EDA_ANGLE otherAngle = EDA_ANGLE( aOther.A - aOther.B ).Normalize180();
|
||||
|
||||
double thisVecAngle = NormalizeAngle180( RAD2DECIDEG( thisVec.Angle() ) );
|
||||
double otherVecAngle = NormalizeAngle180( RAD2DECIDEG( otherVec.Angle() ) );
|
||||
double angleDegrees = std::abs( NormalizeAngle180( thisVecAngle - otherVecAngle ) ) / 10.0;
|
||||
EDA_ANGLE angle = std::abs( ( thisAngle - otherAngle ).Normalize180() );
|
||||
|
||||
return std::min( 180.0 - angleDegrees, angleDegrees );
|
||||
return std::min( ANGLE_180 - angle, angle );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -519,26 +519,26 @@ void DXF_IMPORT_PLUGIN::addArc( const DL_ArcData& aData )
|
|||
VECTOR2D center( mapX( centerCoords.x ), mapY( centerCoords.y ) );
|
||||
|
||||
// aData.anglex is in degrees.
|
||||
double startangle = aData.angle1;
|
||||
double endangle = aData.angle2;
|
||||
EDA_ANGLE startangle( aData.angle1, DEGREES_T );
|
||||
EDA_ANGLE endangle( aData.angle2, DEGREES_T );
|
||||
|
||||
// Init arc start point
|
||||
VECTOR2D startPoint( aData.radius, 0.0 );
|
||||
startPoint = startPoint.Rotate( startangle * M_PI / 180.0 );
|
||||
VECTOR2D arcStart(
|
||||
mapX( startPoint.x + centerCoords.x ), mapY( startPoint.y + centerCoords.y ) );
|
||||
RotatePoint( startPoint, -startangle );
|
||||
VECTOR2D arcStart( mapX( startPoint.x + centerCoords.x ),
|
||||
mapY( startPoint.y + centerCoords.y ) );
|
||||
|
||||
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
|
||||
double angle = -( endangle - startangle );
|
||||
EDA_ANGLE angle = -( endangle - startangle );
|
||||
|
||||
if( angle > 0.0 )
|
||||
angle -= 360.0;
|
||||
if( angle > ANGLE_0 )
|
||||
angle -= ANGLE_360;
|
||||
|
||||
DXF_IMPORT_LAYER* layer = getImportLayer( attributes.getLayer() );
|
||||
double lineWidth = lineWeightToWidth( attributes.getWidth(), layer );
|
||||
|
||||
GRAPHICS_IMPORTER_BUFFER* bufferToUse =
|
||||
( m_currentBlock != nullptr ) ? &m_currentBlock->m_buffer : &m_internalImporter;
|
||||
GRAPHICS_IMPORTER_BUFFER* bufferToUse = m_currentBlock ? &m_currentBlock->m_buffer
|
||||
: &m_internalImporter;
|
||||
bufferToUse->AddArc( center, arcStart, angle, lineWidth );
|
||||
|
||||
VECTOR2D radiusDelta( mapDim( aData.radius ), mapDim( aData.radius ) );
|
||||
|
@ -1279,7 +1279,7 @@ void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aS
|
|||
double cy = h * sin( offAng ) + ym;
|
||||
VECTOR2D center( SCALE_FACTOR( cx ), SCALE_FACTOR( -cy ) );
|
||||
VECTOR2D arc_start;
|
||||
double angle = RAD2DEG( ang );
|
||||
EDA_ANGLE angle( ang, RADIANS_T );
|
||||
|
||||
if( ang < 0.0 )
|
||||
{
|
||||
|
@ -1291,8 +1291,8 @@ void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aS
|
|||
angle = -angle;
|
||||
}
|
||||
|
||||
GRAPHICS_IMPORTER_BUFFER* bufferToUse =
|
||||
( m_currentBlock != nullptr ) ? &m_currentBlock->m_buffer : &m_internalImporter;
|
||||
GRAPHICS_IMPORTER_BUFFER* bufferToUse = m_currentBlock ? &m_currentBlock->m_buffer
|
||||
: &m_internalImporter;
|
||||
bufferToUse->AddArc( center, arc_start, angle, aWidth );
|
||||
|
||||
VECTOR2D radiusDelta( SCALE_FACTOR( radius ), SCALE_FACTOR( radius ) );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -219,10 +219,10 @@ public:
|
|||
* @param aCenter is the arc center point expressed in mm.
|
||||
* @param aStart is the arc arm end point expressed in mm.
|
||||
* Its length is the arc radius.
|
||||
* @param aAngle is the arc angle expressed in degrees.
|
||||
* @param aAngle is the arc angle.
|
||||
* @param aWidth is the segment thickness in mm. Use -1 for default line thickness
|
||||
*/
|
||||
virtual void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle,
|
||||
virtual void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
|
||||
double aWidth ) = 0;
|
||||
|
||||
virtual void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) = 0;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 CERN
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -50,7 +51,7 @@ void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadiu
|
|||
|
||||
|
||||
void GRAPHICS_IMPORTER_BUFFER::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart,
|
||||
double aAngle, double aWidth )
|
||||
const EDA_ANGLE& aAngle, double aWidth )
|
||||
{
|
||||
m_shapes.push_back( make_shape<IMPORTED_ARC>( aCenter, aStart, aAngle, aWidth ) );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 CERN
|
||||
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
|
||||
*
|
||||
|
@ -137,7 +137,8 @@ private:
|
|||
class IMPORTED_ARC : public IMPORTED_SHAPE
|
||||
{
|
||||
public:
|
||||
IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) :
|
||||
IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
|
||||
double aWidth ) :
|
||||
m_center( aCenter ),
|
||||
m_start( aStart ),
|
||||
m_angle( aAngle ),
|
||||
|
@ -171,10 +172,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
VECTOR2D m_center;
|
||||
VECTOR2D m_start;
|
||||
double m_angle;
|
||||
double m_width;
|
||||
VECTOR2D m_center;
|
||||
VECTOR2D m_start;
|
||||
EDA_ANGLE m_angle;
|
||||
double m_width;
|
||||
};
|
||||
|
||||
|
||||
|
@ -334,7 +335,7 @@ public:
|
|||
|
||||
void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) override;
|
||||
|
||||
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle,
|
||||
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
|
||||
double aWidth ) override;
|
||||
|
||||
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
|
||||
|
|
|
@ -95,7 +95,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadiu
|
|||
|
||||
|
||||
void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart,
|
||||
double aAngle, double aWidth )
|
||||
const EDA_ANGLE& aAngle, double aWidth )
|
||||
{
|
||||
std::unique_ptr<PCB_SHAPE> arc( createDrawing() );
|
||||
arc->SetShape( SHAPE_T::ARC );
|
||||
|
@ -105,11 +105,11 @@ void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D&
|
|||
* We need to perform the rotation/conversion here while still using floating point values
|
||||
* to avoid rounding errors when operating in integer space in pcbnew
|
||||
*/
|
||||
VECTOR2D end = aStart - aCenter;
|
||||
VECTOR2D mid = aStart - aCenter;
|
||||
VECTOR2D end = aStart;
|
||||
VECTOR2D mid = aStart;
|
||||
|
||||
end = aCenter + end.Rotate( DEG2RAD( aAngle ) );
|
||||
mid = aCenter + mid.Rotate( DEG2RAD( aAngle / 2.0 ) );
|
||||
RotatePoint( end, aCenter, -aAngle );
|
||||
RotatePoint( mid, aCenter, -aAngle / 2.0 );
|
||||
|
||||
arc->SetArcGeometry( MapCoordinate( aStart ), MapCoordinate( mid ), MapCoordinate( end ) );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 CERN
|
||||
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
void AddCircle( const VECTOR2D& aOrigin, double aRadius, double aWidth, bool aFilled ) override;
|
||||
|
||||
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle,
|
||||
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
|
||||
double aWidth ) override;
|
||||
|
||||
void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
#include <trigo.h>
|
||||
|
||||
|
||||
static const EDA_ANGLE s_arrowAngle( 27.5, DEGREES_T );
|
||||
|
||||
|
||||
PCB_DIMENSION_BASE::PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType ) :
|
||||
BOARD_ITEM( aParent, aType ),
|
||||
m_overrideTextEnabled( false ),
|
||||
|
@ -522,7 +525,7 @@ PCB_DIM_ALIGNED::PCB_DIM_ALIGNED( BOARD_ITEM* aParent, KICAD_T aType ) :
|
|||
m_height( 0 )
|
||||
{
|
||||
// To preserve look of old dimensions, initialize extension height based on default arrow length
|
||||
m_extensionHeight = static_cast<int>( m_arrowLength * std::sin( DEG2RAD( s_arrowAngle ) ) );
|
||||
m_extensionHeight = static_cast<int>( m_arrowLength * s_arrowAngle.Sin() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -634,22 +637,15 @@ void PCB_DIM_ALIGNED::updateGeometry()
|
|||
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar ) );
|
||||
|
||||
// Add arrows
|
||||
VECTOR2I arrowEnd( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
||||
RotatePoint( arrowEndPos, EDA_ANGLE( dimension ) + s_arrowAngle );
|
||||
RotatePoint( arrowEndNeg, EDA_ANGLE( dimension ) - s_arrowAngle );
|
||||
|
||||
double arrowRotPos = dimension.Angle() + DEG2RAD( s_arrowAngle );
|
||||
double arrowRotNeg = dimension.Angle() - DEG2RAD( s_arrowAngle );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart,
|
||||
m_crossBarStart + arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart,
|
||||
m_crossBarStart + arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd,
|
||||
m_crossBarEnd - arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd,
|
||||
m_crossBarEnd - arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndNeg ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndNeg ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -661,14 +657,18 @@ void PCB_DIM_ALIGNED::updateText()
|
|||
{
|
||||
int textOffsetDistance = m_text.GetEffectiveTextPenWidth() + m_text.GetTextHeight();
|
||||
|
||||
double rotation;
|
||||
if( crossbarCenter.x == 0 )
|
||||
rotation = sign( crossbarCenter.y ) * DEG2RAD( 90 );
|
||||
else
|
||||
rotation = -std::copysign( DEG2RAD( 90 ), crossbarCenter.x );
|
||||
EDA_ANGLE rotation;
|
||||
|
||||
VECTOR2I textOffset = crossbarCenter.Rotate( rotation ).Resize( textOffsetDistance );
|
||||
textOffset += crossbarCenter;
|
||||
if( crossbarCenter.x == 0 )
|
||||
rotation = ANGLE_90 * sign( -crossbarCenter.y );
|
||||
else if( crossbarCenter.x < 0 )
|
||||
rotation = -ANGLE_90;
|
||||
else
|
||||
rotation = ANGLE_90;
|
||||
|
||||
VECTOR2I textOffset = crossbarCenter;
|
||||
RotatePoint( crossbarCenter, rotation );
|
||||
textOffset += crossbarCenter.Resize( textOffsetDistance );
|
||||
|
||||
m_text.SetTextPos( m_crossBarStart + textOffset );
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ void PCB_DIM_ALIGNED::updateText()
|
|||
|
||||
if( m_keepTextAligned )
|
||||
{
|
||||
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( crossbarCenter.Angle(), RADIANS_T );
|
||||
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( crossbarCenter );
|
||||
textAngle.Normalize();
|
||||
|
||||
if( textAngle > ANGLE_90 && textAngle <= ANGLE_270 )
|
||||
|
@ -704,7 +704,7 @@ PCB_DIM_ORTHOGONAL::PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent, bool aInFP ) :
|
|||
PCB_DIM_ALIGNED( aParent, aInFP ? PCB_FP_DIM_ORTHOGONAL_T : PCB_DIM_ORTHOGONAL_T )
|
||||
{
|
||||
// To preserve look of old dimensions, initialize extension height based on default arrow length
|
||||
m_extensionHeight = static_cast<int>( m_arrowLength * std::sin( DEG2RAD( s_arrowAngle ) ) );
|
||||
m_extensionHeight = static_cast<int>( m_arrowLength * s_arrowAngle.Sin() );
|
||||
m_orientation = DIR::HORIZONTAL;
|
||||
}
|
||||
|
||||
|
@ -816,19 +816,16 @@ void PCB_DIM_ORTHOGONAL::updateGeometry()
|
|||
m_shapes.emplace_back( new SHAPE_SEGMENT( crossbar ) );
|
||||
|
||||
// Add arrows
|
||||
VECTOR2I crossBarAngle( m_crossBarEnd - m_crossBarStart );
|
||||
VECTOR2I arrowEnd( m_arrowLength, 0 );
|
||||
EDA_ANGLE crossBarAngle( m_crossBarEnd - m_crossBarStart );
|
||||
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
||||
RotatePoint( arrowEndPos, crossBarAngle + s_arrowAngle );
|
||||
RotatePoint( arrowEndNeg, crossBarAngle - s_arrowAngle );
|
||||
|
||||
double arrowRotPos = crossBarAngle.Angle() + DEG2RAD( s_arrowAngle );
|
||||
double arrowRotNeg = crossBarAngle.Angle() - DEG2RAD( s_arrowAngle );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarStart, m_crossBarStart + arrowEndNeg ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_crossBarEnd, m_crossBarEnd - arrowEndNeg ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -874,13 +871,9 @@ void PCB_DIM_ORTHOGONAL::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aA
|
|||
|
||||
// restrict angle to -179.9 to 180.0 degrees
|
||||
if( angle > ANGLE_180 )
|
||||
{
|
||||
angle -= ANGLE_360;
|
||||
}
|
||||
else if( angle <= -ANGLE_180 )
|
||||
{
|
||||
angle += ANGLE_360;
|
||||
}
|
||||
|
||||
// adjust orientation and height to new angle
|
||||
// we can only handle the cases of -90, 0, 90, 180 degrees exactly;
|
||||
|
@ -1010,13 +1003,13 @@ void PCB_DIM_LEADER::updateGeometry()
|
|||
m_shapes.emplace_back( new SHAPE_SEGMENT( start, *arrowSegEnd ) );
|
||||
|
||||
// Add arrows
|
||||
VECTOR2I arrowEnd( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
||||
RotatePoint( arrowEndPos, EDA_ANGLE( firstLine ) + s_arrowAngle );
|
||||
RotatePoint( arrowEndNeg, EDA_ANGLE( firstLine ) - s_arrowAngle );
|
||||
|
||||
double arrowRotPos = firstLine.Angle() + DEG2RAD( s_arrowAngle );
|
||||
double arrowRotNeg = firstLine.Angle() - DEG2RAD( s_arrowAngle );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( start, start + arrowEndNeg ) );
|
||||
|
||||
|
||||
if( !GetText().IsEmpty() )
|
||||
|
@ -1120,7 +1113,7 @@ void PCB_DIM_RADIAL::updateText()
|
|||
if( m_keepTextAligned )
|
||||
{
|
||||
VECTOR2I textLine( Text().GetPosition() - GetKnee() );
|
||||
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( textLine.Angle(), RADIANS_T );
|
||||
EDA_ANGLE textAngle = FULL_CIRCLE - EDA_ANGLE( textLine );
|
||||
|
||||
textAngle.Normalize();
|
||||
|
||||
|
@ -1146,7 +1139,7 @@ void PCB_DIM_RADIAL::updateGeometry()
|
|||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
|
||||
|
||||
centerArm = centerArm.Rotate( DEG2RAD( 90 ) );
|
||||
RotatePoint( centerArm, -ANGLE_90 );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
|
||||
|
||||
|
@ -1190,13 +1183,13 @@ void PCB_DIM_RADIAL::updateGeometry()
|
|||
m_shapes.emplace_back( new SHAPE_SEGMENT( arrowSeg ) );
|
||||
|
||||
// Add arrows
|
||||
VECTOR2I arrowEnd( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndPos( m_arrowLength, 0 );
|
||||
VECTOR2I arrowEndNeg( m_arrowLength, 0 );
|
||||
RotatePoint( arrowEndPos, EDA_ANGLE( radial ) + s_arrowAngle );
|
||||
RotatePoint( arrowEndNeg, EDA_ANGLE( radial ) - s_arrowAngle );
|
||||
|
||||
double arrowRotPos = radial.Angle() + DEG2RAD( s_arrowAngle );
|
||||
double arrowRotNeg = radial.Angle() - DEG2RAD( s_arrowAngle );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEnd.Rotate( arrowRotPos ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEnd.Rotate( arrowRotNeg ) ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEndPos ) );
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, m_end + arrowEndNeg ) );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( textSeg ) );
|
||||
}
|
||||
|
@ -1263,7 +1256,7 @@ void PCB_DIM_CENTER::updateGeometry()
|
|||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) );
|
||||
|
||||
arm = arm.Rotate( DEG2RAD( 90 ) );
|
||||
RotatePoint( arm, -ANGLE_90 );
|
||||
|
||||
m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) );
|
||||
}
|
||||
|
|
|
@ -309,8 +309,6 @@ protected:
|
|||
|
||||
///< Internal cache of drawn shapes
|
||||
std::vector<std::shared_ptr<SHAPE>> m_shapes;
|
||||
|
||||
static constexpr float s_arrowAngle = 27.5;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -375,12 +375,12 @@ void TEARDROP_MANAGER::computeCurvedForRectShape( TEARDROP_PARAMETERS* aCurrPar
|
|||
side_length = side2.EuclideanNorm();
|
||||
delta_effective = std::min( delta, side_length/8 );
|
||||
|
||||
double angle2 = side2.Angle();
|
||||
sign = std::abs( angle2 ) <= 90.0*M_PI/180 ? 1 : -1;
|
||||
EDA_ANGLE angle2( side2 );
|
||||
sign = std::abs( angle2 ) <= ANGLE_90 ? 1 : -1;
|
||||
|
||||
bias = VECTOR2I( 0, sign * delta_effective );
|
||||
|
||||
bias.Rotate( angle2 );
|
||||
RotatePoint( bias, -angle2 );
|
||||
|
||||
ctrl1.x += bias.x;
|
||||
ctrl1.y += bias.y;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
|
@ -377,8 +377,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
|
|||
SEG trackSeg( retval->GetStart(), retval->GetEnd() );
|
||||
|
||||
// Allow deviations in colinearity as defined in ADVANCED_CFG
|
||||
if( trackSeg.AngleDegrees( aCollinearSeg )
|
||||
> ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation )
|
||||
if( trackSeg.Angle( aCollinearSeg )
|
||||
> EDA_ANGLE( ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation, DEGREES_T ) )
|
||||
{
|
||||
retval = nullptr;
|
||||
}
|
||||
|
|
|
@ -431,7 +431,9 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
|
|||
|
||||
int offset = segment->GetWidth() / 2;
|
||||
SEG seg = segment->GetSeg();
|
||||
VECTOR2I normal = ( seg.B - seg.A ).Resize( offset ).Rotate( -M_PI_2 );
|
||||
VECTOR2I normal = ( seg.B - seg.A );
|
||||
normal.Resize( offset );
|
||||
RotatePoint( normal, ANGLE_90 );
|
||||
|
||||
/*
|
||||
* TODO: This creates more snap points than necessary for rounded rect pads
|
||||
|
@ -446,7 +448,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
|
|||
addAnchor( seg.Center() + normal, OUTLINE | SNAPPABLE, aPad );
|
||||
addAnchor( seg.Center() - normal, OUTLINE | SNAPPABLE, aPad );
|
||||
|
||||
normal = normal.Rotate( M_PI_2 );
|
||||
RotatePoint( normal, -ANGLE_90 );
|
||||
|
||||
addAnchor( seg.A - normal, OUTLINE | SNAPPABLE, aPad );
|
||||
addAnchor( seg.B + normal, OUTLINE | SNAPPABLE, aPad );
|
||||
|
@ -726,7 +728,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
|
|||
|
||||
for( int i = 0; i < 2; i++ )
|
||||
{
|
||||
radial = radial.Rotate( DEG2RAD( 90 ) );
|
||||
RotatePoint( radial, -ANGLE_90 );
|
||||
addAnchor( start + radial, CORNER | SNAPPABLE, aItem );
|
||||
}
|
||||
|
||||
|
|
|
@ -169,17 +169,15 @@ bool ArePointsNearCircle(
|
|||
*/
|
||||
|
||||
template<typename T>
|
||||
bool ArePerpendicular( const VECTOR2<T>& a, const VECTOR2<T>& b, double aTolerance )
|
||||
bool ArePerpendicular( const VECTOR2<T>& a, const VECTOR2<T>& b, const EDA_ANGLE& aTolerance )
|
||||
{
|
||||
auto angle = std::abs( a.Angle() - b.Angle() );
|
||||
EDA_ANGLE angle = std::abs( EDA_ANGLE( a ) - EDA_ANGLE( b ) );
|
||||
|
||||
// Normalise: angles of 3*pi/2 are also perpendicular
|
||||
if (angle > M_PI)
|
||||
{
|
||||
angle -= M_PI;
|
||||
}
|
||||
if (angle > ANGLE_180)
|
||||
angle -= ANGLE_180;
|
||||
|
||||
return KI_TEST::IsWithin( angle, M_PI / 2.0, aTolerance );
|
||||
return KI_TEST::IsWithin( angle.AsRadians(), ANGLE_90.AsRadians(), aTolerance.AsRadians() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ void TestFilletSegmentConstraints( const SEG& aSeg, VECTOR2I aRadCentre,
|
|||
KI_TEST::IsWithinAndBelow<int>, ( diffC.EuclideanNorm() )( aRadius )( aError + 1 ) );
|
||||
|
||||
// Check 3: Mid-point -> radius centre perpendicular
|
||||
const auto perpendularityMaxError = ( M_PI / 2 ) / 10;
|
||||
const EDA_ANGLE perpendularityMaxError = ANGLE_90 / 10;
|
||||
BOOST_CHECK_PREDICATE( GEOM_TEST::ArePerpendicular<int>,
|
||||
( diffC )( aSeg.A - aSeg.B )( perpendularityMaxError ) );
|
||||
}
|
||||
|
|
|
@ -229,8 +229,8 @@ using MATCH_PRED = std::function<bool( const EXP_OBJ&, const FOUND_OBJ& )>;
|
|||
* matches a given "expected" object.
|
||||
*/
|
||||
template <typename EXP_CONT, typename FOUND_CONT, typename MATCH_PRED>
|
||||
void CheckUnorderedMatches(
|
||||
const EXP_CONT& aExpected, const FOUND_CONT& aFound, MATCH_PRED aMatchPredicate )
|
||||
void CheckUnorderedMatches( const EXP_CONT& aExpected, const FOUND_CONT& aFound,
|
||||
MATCH_PRED aMatchPredicate )
|
||||
{
|
||||
using EXP_OBJ = typename EXP_CONT::value_type;
|
||||
|
||||
|
@ -260,10 +260,11 @@ void CheckUnorderedMatches(
|
|||
// check every "found" object was expected
|
||||
for( const EXP_OBJ* found : matched )
|
||||
{
|
||||
const bool was_expected =
|
||||
std::find_if( aExpected.begin(), aExpected.end(),
|
||||
[found]( const EXP_OBJ& aObj ) { return &aObj == found; } )
|
||||
!= aExpected.end();
|
||||
const bool was_expected = std::find_if( aExpected.begin(), aExpected.end(),
|
||||
[found]( const EXP_OBJ& aObj )
|
||||
{
|
||||
return &aObj == found;
|
||||
} ) != aExpected.end();
|
||||
|
||||
BOOST_CHECK_MESSAGE( was_expected, "Found item was not expected. Found: \n" << *found );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue