mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-27 00:15:20 +02:00
sch2fig/dwg.c (rx, ry): avoid floating-point errors
Even small errors (i.e., one unit), can cause very visible changes in the graphical output. Perhaps fig2dev is over-reacting at times.
This commit is contained in:
parent
d63d183198
commit
8721964568
@ -14,7 +14,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -292,17 +291,37 @@ static int make_box(enum box_type box, int h, int *vx, int *vy)
|
|||||||
|
|
||||||
static int rx(int x, int y, int rot)
|
static int rx(int x, int y, int rot)
|
||||||
{
|
{
|
||||||
float a = rot / 180.0 * M_PI;
|
switch (rot) {
|
||||||
|
case 0:
|
||||||
|
return x;
|
||||||
|
case 90:
|
||||||
|
return y;
|
||||||
|
case 180:
|
||||||
|
return -x;
|
||||||
|
case 270:
|
||||||
|
return -y;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
|
||||||
return cos(a) * x + sin(a) * y;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ry(int x, int y, int rot)
|
static int ry(int x, int y, int rot)
|
||||||
{
|
{
|
||||||
float a = rot / 180.0 * M_PI;
|
switch (rot) {
|
||||||
|
case 0:
|
||||||
|
return y;
|
||||||
|
case 90:
|
||||||
|
return -x;
|
||||||
|
case 180:
|
||||||
|
return -y;
|
||||||
|
case 270:
|
||||||
|
return x;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
|
||||||
return -sin(a) * x + cos(a) * y;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user