Root/ptrude/path.h

1/*
2 * path.h - 2D path operations
3 *
4 * Written 2011 by Werner Almesberger
5 * Copyright 2011 by Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef PATH_H
14#define PATH_H
15
16#include <stdio.h>
17
18
19struct vertex {
20    double x, y;
21    double r; /* minimum bend radius; 0 = use previous value */
22    double d; /* max. distance of corner from ideal arc; 0 = prev */
23    const char *tag;
24    struct vertex *next;
25
26    /*
27     * "len" is set by path_set_len to the distance to the next vertex, or
28     * 0 if this is the last vertex in the path. round_path adjusts "len"
29     * such that it corresponds to the length of the same part of the
30     * original path.
31     */
32    double len;
33};
34
35struct path {
36    struct vertex *vertices;
37    struct vertex **last;
38};
39
40
41void free_path(struct path *path);
42
43double path_set_length(struct path *path);
44struct path *round_path(const struct path *path, double r, double d);
45struct path *stretch_path(const struct path *path, double dist, double r);
46
47struct path *load_path(FILE *file);
48void save_path(FILE *file, const struct path *path);
49
50#endif /* !PATH_H */
51

Archive Download this file

Branches:
master



interactive