Fixed bad computation in eeschema/transform (my fault)

Note: ArcTangente gives a double but *takes* ints, so it's not good to
use for nontrivial things
This commit is contained in:
Lorenzo Marcantonio 2013-05-02 22:53:12 +02:00
parent 19845828ef
commit 91674347b5
1 changed files with 4 additions and 4 deletions

View File

@ -1,8 +1,8 @@
#include <macros.h>
#include <trigo.h>
#include <transform.h>
#include <common.h>
#include <trigo.h>
TRANSFORM& TRANSFORM::operator=( const TRANSFORM& aTransform )
@ -79,21 +79,21 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
t = x * x1 + y * y1;
y = x * x2 + y * y2;
x = t;
*aAngle1 = KiROUND( ArcTangente( y, x ) );
*aAngle1 = KiROUND( RAD2DECIDEG( atan2( y, x ) ) );
x = cos( DECIDEG2RAD( *aAngle2 ) );
y = sin( DECIDEG2RAD( *aAngle2 ) );
t = x * x1 + y * y1;
y = x * x2 + y * y2;
x = t;
*aAngle2 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 );
*aAngle2 = KiROUND( RAD2DECIDEG( atan2( y, x ) ) );
NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE_POS( *aAngle2 );
if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600;
if( *aAngle2 - *aAngle1 > 1800 ) /* Need to swap the two angles. */
if( *aAngle2 - *aAngle1 > 1800 ) // Need to swap the two angles
{
Angle = (*aAngle1);
*aAngle1 = (*aAngle2);