Commit 78e41187 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

Moved utilities for angles in trigo.h

New conversion routines and sin/cos implementation for angles in decidegrees
parent 226b3d64
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -387,7 +387,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
    else if( size.x == 0 )
    else if( size.x == 0 )
        orient = 900;
        orient = 900;
    else
    else
        orient = -(int) ( RAD2DEG( atan2( (double)size.y, (double)size.x ) ) * 10.0 );
        orient = -ArcTangente( size.y, size.x );


    size.x = KiROUND( hypot( size.x, size.y ) ) + width;
    size.x = KiROUND( hypot( size.x, size.y ) ) + width;
    size.y = width;
    size.y = width;
@@ -407,9 +407,7 @@ void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, int orient,
    if( size.x > size.y )
    if( size.x > size.y )
    {
    {
        EXCHG( size.x, size.y );
        EXCHG( size.x, size.y );
        orient += 900;
        orient = AddAngles( orient, 900 );
        if( orient >= 3600 )
            orient -= 3600;
    }
    }


    deltaxy = size.y - size.x;       /* distance between centers of the oval */
    deltaxy = size.y - size.x;       /* distance between centers of the oval */
+1 −3
Original line number Original line Diff line number Diff line
@@ -423,9 +423,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int ori
    if( size.x > size.y )
    if( size.x > size.y )
    {
    {
        EXCHG( size.x, size.y );
        EXCHG( size.x, size.y );
        orient += 900;
        orient = AddAngles( orient, 900 );
        if( orient >= 3600 )
            orient -= 3600;
    }
    }
    sketchOval( pos, size, orient, -1 );
    sketchOval( pos, size, orient, -1 );
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -287,12 +287,12 @@ void GERBER_PLOTTER::Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle,
{
{
    wxASSERT( outputFile );
    wxASSERT( outputFile );
    wxPoint start, end;
    wxPoint start, end;
    start.x = aCenter.x + KiROUND( aRadius*cos( DEG2RAD( aStAngle/10.0 ) ) );
    start.x = aCenter.x + KiROUND( cosdecideg( aRadius, aStAngle ) );
    start.y = aCenter.y - KiROUND( aRadius*sin( DEG2RAD( aStAngle/10.0 ) ) );
    start.y = aCenter.y - KiROUND( sindecideg( aRadius, aStAngle ) );
    SetCurrentLineWidth( aWidth );
    SetCurrentLineWidth( aWidth );
    MoveTo( start );
    MoveTo( start );
    end.x = aCenter.x + KiROUND( aRadius*cos( DEG2RAD( aEndAngle/10.0 ) ) );
    end.x = aCenter.x + KiROUND( cosdecideg( aRadius, aEndAngle ) );
    end.y = aCenter.y - KiROUND( aRadius*sin( DEG2RAD( aEndAngle/10.0 ) ) );
    end.y = aCenter.y - KiROUND( sindecideg( aRadius, aEndAngle ) );
    DPOINT devEnd = userToDeviceCoordinates( end );
    DPOINT devEnd = userToDeviceCoordinates( end );
    DPOINT devCenter = userToDeviceCoordinates( aCenter )
    DPOINT devCenter = userToDeviceCoordinates( aCenter )
        - userToDeviceCoordinates( start );
        - userToDeviceCoordinates( start );
+4 −6
Original line number Original line Diff line number Diff line
@@ -401,8 +401,8 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int ra


    // Calculate start point,
    // Calculate start point,
    wxPoint cmap;
    wxPoint cmap;
    cmap.x  = int( centre.x + ( radius * cos( DEG2RAD( StAngle / 10.0 ) ) ) );
    cmap.x  = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
    cmap.y  = int( centre.y - ( radius * sin( DEG2RAD( StAngle / 10.0 ) ) ) );
    cmap.y  = centre.y - KiROUND( sindecideg( radius, StAngle ) );
    DPOINT  cmap_dev = userToDeviceCoordinates( cmap );
    DPOINT  cmap_dev = userToDeviceCoordinates( cmap );


    fprintf( outputFile,
    fprintf( outputFile,
@@ -431,10 +431,8 @@ void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int or
     */
     */
    if( size.x > size.y )
    if( size.x > size.y )
    {
    {
        EXCHG( size.x, size.y ); orient += 900;
        EXCHG( size.x, size.y ); 

        orient = AddAngles( orient, 900 );
        if( orient >= 3600 )
            orient -= 3600;
    }
    }


    deltaxy = size.y - size.x;     // distance between centers of the oval
    deltaxy = size.y - size.x;     // distance between centers of the oval
+6 −9
Original line number Original line Diff line number Diff line
@@ -219,23 +219,20 @@ void PDF_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad
    SetCurrentLineWidth( width );
    SetCurrentLineWidth( width );


    // Usual trig arc plotting routine...
    // Usual trig arc plotting routine...
    double alpha = DEG2RAD( StAngle / 10.0 );
    start.x = centre.x + KiROUND( cosdecideg( radius, -StAngle ) );
    start.x = centre.x + (int) ( radius * cos( -alpha ) );
    start.y = centre.y + KiROUND( sindecideg( radius, -StAngle ) );
    start.y = centre.y + (int) ( radius * sin( -alpha ) );
    DPOINT pos_dev = userToDeviceCoordinates( start );
    DPOINT pos_dev = userToDeviceCoordinates( start );
    fprintf( workFile, "%g %g m ", pos_dev.x, pos_dev.y );
    fprintf( workFile, "%g %g m ", pos_dev.x, pos_dev.y );
    for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
    for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
    {
    {
        alpha = DEG2RAD( ii / 10.0 );
        end.x = centre.x + KiROUND( cosdecideg( radius, -ii ) );
        end.x = centre.x + (int) ( radius * cos( -alpha ) );
        end.y = centre.y + KiROUND( sindecideg( radius, -ii ) );
        end.y = centre.y + (int) ( radius * sin( -alpha ) );
        pos_dev = userToDeviceCoordinates( end );
        pos_dev = userToDeviceCoordinates( end );
        fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
        fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
    }
    }


    alpha = DEG2RAD( EndAngle / 10.0 );
    end.x = centre.x + KiROUND( cosdecideg( radius, -EndAngle ) );
    end.x = centre.x + (int) ( radius * cos( -alpha ) );
    end.y = centre.y + KiROUND( sindecideg( radius, -EndAngle ) );
    end.y = centre.y + (int) ( radius * sin( -alpha ) );
    pos_dev = userToDeviceCoordinates( end );
    pos_dev = userToDeviceCoordinates( end );
    fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
    fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );


Loading