Clean up some more deci-degrees.

This commit is contained in:
Jeff Young 2022-01-18 12:43:08 +00:00
parent 1c8ba6dafc
commit 4e493e2cbc
4 changed files with 23 additions and 46 deletions

View File

@ -196,7 +196,6 @@ inline double DEG2RAD( double deg ) { return deg * M_PI / 180.0; }
inline double RAD2DEG( double rad ) { return rad * 180.0 / M_PI; }
// These are the same *but* work with the internal 'decidegrees' unit
inline double DECIDEG2RAD( double deg ) { return deg * M_PI / 1800.0; }
inline double RAD2DECIDEG( double rad ) { return rad * 1800.0 / M_PI; }
/* These are templated over T (and not simply double) because Eeschema

View File

@ -34,25 +34,6 @@
#include <pad.h>
/**
* Circle generation utility: computes r * sin(a)
* Where a is in decidegrees, not in radians.
*/
double sindecideg( double r, double a )
{
return r * sin( DECIDEG2RAD( a ) );
}
/**
* Circle generation utility: computes r * cos(a)
* Where a is in decidegrees, not in radians.
*/
double cosdecideg( double r, double a )
{
return r * cos( DECIDEG2RAD( a ) );
}
AR_MATRIX::AR_MATRIX()
{
m_BoardSide[0] = nullptr;
@ -421,10 +402,9 @@ void AR_MATRIX::traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int lay
AR_MATRIX::CELL_OP op_logic )
{
int radius, nb_segm;
int x0, y0, // Starting point of the current segment trace.
x1, y1; // End point.
int x0, y0; // Starting point of the current segment trace.
int x1, y1; // End point.
int ii;
int angle;
radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
@ -444,9 +424,9 @@ void AR_MATRIX::traceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int lay
for( ii = 1; ii < nb_segm; ii++ )
{
angle = ( 3600 * ii ) / nb_segm;
x1 = KiROUND( cosdecideg( radius, angle ) );
y1 = KiROUND( sindecideg( radius, angle ) );
EDA_ANGLE angle = ( ANGLE_360 * ii ) / nb_segm;
x1 = KiROUND( radius * angle.Cos() );
y1 = KiROUND( radius * angle.Sin() );
drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
x0 = x1;
y0 = y1;
@ -577,27 +557,26 @@ void AR_MATRIX::traceFilledCircle(
* center = ux0,uy0, starting at ux1, uy1. Coordinates are in
* PCB units.
*/
void AR_MATRIX::traceArc( int ux0, int uy0, int ux1, int uy1, double ArcAngle, int lg, int layer,
int color, AR_MATRIX::CELL_OP op_logic )
void AR_MATRIX::traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg,
int layer, int color, AR_MATRIX::CELL_OP op_logic )
{
int radius, nb_segm;
int x0, y0, // Starting point of the current segment trace
x1, y1; // End point
int ii;
double angle, StAngle;
int radius, nb_segm;
int x0, y0; // Starting point of the current segment trace
int x1, y1; // End point
int ii;
EDA_ANGLE angle, startAngle;
radius = KiROUND( Distance( ux0, uy0, ux1, uy1 ) );
x0 = ux1 - ux0;
y0 = uy1 - uy0;
StAngle = EDA_ANGLE( VECTOR2I( ux1, uy1 ) - VECTOR2I( ux0, uy0 ) ).AsTenthsOfADegree();
startAngle = EDA_ANGLE( VECTOR2I( ux1, uy1 ) - VECTOR2I( ux0, uy0 ) );
if( lg < 1 )
lg = 1;
nb_segm = ( 2 * radius ) / lg;
nb_segm = ( nb_segm * std::abs( ArcAngle ) ) / 3600;
nb_segm = nb_segm * std::abs( arcAngle.AsDegrees() ) / 360.0;
if( nb_segm < 5 )
nb_segm = 5;
@ -607,13 +586,13 @@ void AR_MATRIX::traceArc( int ux0, int uy0, int ux1, int uy1, double ArcAngle, i
for( ii = 1; ii <= nb_segm; ii++ )
{
angle = ( ArcAngle * ii ) / nb_segm;
angle += StAngle;
angle = arcAngle * ii / nb_segm;
angle += startAngle;
NORMALIZE_ANGLE_POS( angle );
angle.Normalize();
x1 = KiROUND( cosdecideg( radius, angle ) );
y1 = KiROUND( cosdecideg( radius, angle ) );
x1 = KiROUND( radius * angle.Cos() );
y1 = KiROUND( radius * angle.Cos() );
drawSegmentQcq( x0 + ux0, y0 + uy0, x1 + ux0, y1 + uy0, lg, layer, color, op_logic );
x0 = x1;
y0 = y1;
@ -798,8 +777,7 @@ void AR_MATRIX::TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin,
int ux1 = aShape->GetStart().x - GetBrdCoordOrigin().x;
int uy1 = aShape->GetStart().y - GetBrdCoordOrigin().y;
traceArc( ux0, uy0, ux1, uy1, aShape->GetArcAngle().AsTenthsOfADegree(), half_width,
layer, aColor, op_logic );
traceArc( ux0, uy0, ux1, uy1, aShape->GetArcAngle(), half_width, layer, aColor, op_logic );
}
}

View File

@ -131,8 +131,8 @@ private:
void traceFilledCircle( int cx, int cy, int radius, LSET aLayerMask, int color,
AR_MATRIX::CELL_OP op_logic );
void traceArc( int ux0, int uy0, int ux1, int uy1, double ArcAngle, int lg, int layer,
int color, AR_MATRIX::CELL_OP op_logic );
void traceArc( int ux0, int uy0, int ux1, int uy1, const EDA_ANGLE& arcAngle, int lg,
int layer, int color, AR_MATRIX::CELL_OP op_logic );
public:
MATRIX_CELL* m_BoardSide[AR_MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides

View File

@ -909,7 +909,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
// Keep the size ratio for the font, but make it smaller
if( padsize.x < padsize.y )
{
m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
m_gal->Rotate( -ANGLE_90.AsRadians() );
size = padsize.x;
std::swap( padsize.x, padsize.y );
}