summaryrefslogtreecommitdiff
path: root/geometry.h
blob: 049fba45c93f5e144d6622f26f77c42fa72f36f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once

typedef struct {
  int x;
  int y;
} LPoint;

typedef struct {
  LPoint p0;
  LPoint p1;
} LLine;

// dist is a fixed point with precission of 8 bits
// offs is where on the line segment xy0-xy1 the point's normale hits,
// range 0..65536 (but can extend, if normale hits line outside line segment)
int dist_pl(LPoint const * p, LLine const * l, int * offs);
int dist_pp(LPoint const * p0, LPoint const * p1);
int get_x_for_y(LPoint const * p0, LPoint const * p1, int y);