summaryrefslogtreecommitdiff
path: root/geometry.c
diff options
context:
space:
mode:
authorerdgeist <erdgeist@bauklotz.fritz.box>2017-04-09 22:08:28 +0200
committererdgeist <erdgeist@bauklotz.fritz.box>2017-04-09 22:08:28 +0200
commit804f3bce8ad4dfd48186f0030252067f69b62e07 (patch)
treef70b7e33a3c3f34f615893b2e3d04feb51cbdc97 /geometry.c
parent0ab1e4878f9e2b592032dc7c67ae8018293058f6 (diff)
Add function to find a point for a certain offset
Diffstat (limited to 'geometry.c')
-rw-r--r--geometry.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/geometry.c b/geometry.c
index f2961c7..7c29f85 100644
--- a/geometry.c
+++ b/geometry.c
@@ -29,3 +29,12 @@ int
29dist_pp(LPoint const * p0, LPoint const * p1) { 29dist_pp(LPoint const * p0, LPoint const * p1) {
30 return impl_dist_pp(p0->x,p0->y,p1->x,p1->y); 30 return impl_dist_pp(p0->x,p0->y,p1->x,p1->y);
31} 31}
32
33int
34get_x_for_y(LPoint const * p0, LPoint const * p1, int y) {
35 if (p1->x!=p0->x && p1->y!=p0->y) {
36 double m = (double)(p1->y-p0->y) / (double)(p1->x-p0->x);
37 return (int)((((double)y) - (double)(p0->y) + m * (double)p0->x)/m);
38 }
39 return p1->x;
40}