mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-16 18:54:04 +02:00
5d7ab083a3
- README: added that loops can also execute zero times - accept labels only at the beginning of a line - rectangles and lines no longer use the bounding box for drawing (caused offset problems since we now correct for the line width) - dist_rect and inside_rect no longer require their input pre-sorted - pad instances now have their own structure and no longer abuse the bounding box to know the pad coordinates - Makefile: use $(GEN) for fig2dev, to reduce chattiness - when dragging a point, the symbol is now adjusted accordingly - added moving of rects, pads, circles, and arcs - added creation of pads - moved rotate_r from gui_inst.c to coord.c - new function "theta" that combines most of the angle calculations - save_pix_buf: y < 0 clipping changed width, not height git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5386 99fdad57-331a-0410-800a-d7fa5415bdb3
85 lines
1.9 KiB
C
85 lines
1.9 KiB
C
/*
|
|
* coord.h - Coordinate representation and basic operations
|
|
*
|
|
* Written 2009 by Werner Almesberger
|
|
* Copyright 2009 by Werner Almesberger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
|
|
#ifndef COORD_H
|
|
#define COORD_H
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
#define MICRON_UNITS 10
|
|
#define MIL_UNITS (25.4*MICRON_UNITS)
|
|
#define MM_UNITS (1000.0*MICRON_UNITS)
|
|
#define KICAD_UNIT (10.0*MIL_UNITS)
|
|
|
|
#define MIL_IN_MM 0.0254
|
|
|
|
|
|
typedef int32_t unit_type;
|
|
|
|
|
|
#define UNIT_ERROR ((unit_type) 1 << (sizeof(unit_type)*8-1))
|
|
|
|
|
|
struct coord {
|
|
unit_type x, y;
|
|
};
|
|
|
|
|
|
static inline unit_type mil_to_units(double mil)
|
|
{
|
|
return mil*MIL_UNITS;
|
|
}
|
|
|
|
|
|
static inline unit_type mm_to_units(double mm)
|
|
{
|
|
return mm*MM_UNITS;
|
|
}
|
|
|
|
|
|
static inline double units_to_mm(unit_type u)
|
|
{
|
|
return (double) u/MM_UNITS;
|
|
}
|
|
|
|
|
|
static inline double units_to_kicad(unit_type u)
|
|
{
|
|
return (double) u/KICAD_UNIT;
|
|
}
|
|
|
|
|
|
double mm_to_mil(double mm, int exponent);
|
|
double mil_to_mm(double mil, int exponent);
|
|
|
|
struct coord normalize(struct coord v, unit_type len);
|
|
struct coord rotate(struct coord v, double angle);
|
|
struct coord add_vec(struct coord a, struct coord b);
|
|
struct coord sub_vec(struct coord a, struct coord b);
|
|
struct coord neg_vec(struct coord v);
|
|
|
|
struct coord rotate_r(struct coord c, unit_type r, double angle);
|
|
double theta(struct coord c, struct coord p);
|
|
|
|
void swap_coord(unit_type *a, unit_type *b);
|
|
void sort_coord(struct coord *min, struct coord *max);
|
|
|
|
unit_type dist_point(struct coord a, struct coord b);
|
|
unit_type dist_line(struct coord p, struct coord a, struct coord b);
|
|
unit_type dist_rect(struct coord p, struct coord a, struct coord b);
|
|
int inside_rect(struct coord p, struct coord a, struct coord b);
|
|
unit_type dist_circle(struct coord p, struct coord c, unit_type r);
|
|
|
|
#endif /* !COORD_H */
|