From b8ec9574712a664b3c8393aad0ed8ecbb0b4cb82 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 29 Jul 2016 22:13:07 -0300 Subject: [PATCH] sch2fig/ (rx, ry): consolidate into misc.c (integer version) --- sch2fig/dwg.c | 40 +--------------------------------------- sch2fig/misc.c | 36 ++++++++++++++++++++++++++++++++++++ sch2fig/misc.h | 3 +++ sch2fig/text.c | 17 ----------------- 4 files changed, 40 insertions(+), 56 deletions(-) diff --git a/sch2fig/dwg.c b/sch2fig/dwg.c index bb944b7..07c9b5f 100644 --- a/sch2fig/dwg.c +++ b/sch2fig/dwg.c @@ -17,6 +17,7 @@ #include #include "util.h" +#include "misc.h" #include "style.h" #include "text.h" #include "fig.h" @@ -286,45 +287,6 @@ static int make_box(enum box_type box, int h, int *vx, int *vy) } -/* @@@ rx, ry are from text.c; should go to misc.h or misc.c */ - - -static int rx(int x, int y, int rot) -{ - switch (rot) { - case 0: - return x; - case 90: - return y; - case 180: - return -x; - case 270: - return -y; - default: - assert(0); - - } -} - - -static int ry(int x, int y, int rot) -{ - switch (rot) { - case 0: - return y; - case 90: - return -x; - case 180: - return -y; - case 270: - return x; - default: - assert(0); - - } -} - - void dwg_hlabel(int x, int y, const char *s, int dir, int dim, enum fig_shape shape) { diff --git a/sch2fig/misc.c b/sch2fig/misc.c index 820464a..55bc741 100644 --- a/sch2fig/misc.c +++ b/sch2fig/misc.c @@ -76,3 +76,39 @@ int angle_add(int a, int b) return a % 360; } + + +int rx(int x, int y, int rot) +{ + switch (rot) { + case 0: + return x; + case 90: + return y; + case 180: + return -x; + case 270: + return -y; + default: + assert(0); + + } +} + + +int ry(int x, int y, int rot) +{ + switch (rot) { + case 0: + return y; + case 90: + return -x; + case 180: + return -y; + case 270: + return x; + default: + assert(0); + + } +} diff --git a/sch2fig/misc.h b/sch2fig/misc.h index 342d88c..8d6692a 100644 --- a/sch2fig/misc.h +++ b/sch2fig/misc.h @@ -45,4 +45,7 @@ unsigned matrix_to_angle(int m[6]); bool matrix_is_mirrored(int m[6]); int angle_add(int a, int b); +int rx(int x, int y, int rot); +int ry(int x, int y, int rot); + #endif /* !MISC_H */ diff --git a/sch2fig/text.c b/sch2fig/text.c index 597849d..54c88f1 100644 --- a/sch2fig/text.c +++ b/sch2fig/text.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "util.h" #include "misc.h" @@ -77,22 +76,6 @@ void text_flip_x(struct text *txt) } -static int rx(int x, int y, int rot) -{ - float a = rot / 180.0 * M_PI; - - return cos(a) * x + sin(a) * y; -} - - -static int ry(int x, int y, int rot) -{ - float a = rot / 180.0 * M_PI; - - return -sin(a) * x + cos(a) * y; -} - - static int align(int dim, enum text_align align) { switch (align) {