1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/*
Copyright (C) 2017-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/
/*
WARNING: This file was generated by the dkct program (see
http://dktools.sourceforge.net/ for details).
Changes you make here will be lost if dkct is run again!
You should modify the original source and run dkct on it.
Original source: dk4grat.ctr
*/
/** @file dk4grat.h Header file for the dk4grat module.
*/
#ifndef DK4GRAT_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4GRAT_H_INCLUDED 1
#line 8 "dk4grat.ctr"
#ifdef __cplusplus
extern "C" {
#endif
/** Calculate kappa value for angle to use instead of 1/3 for Bezier curves.
@param alpha Arc angle.
@return Kappa value.
*/
double
dk4gratool_kappa_for_angle(double alpha);
/** Initialize points to draw a circle.
@param ptr Address of result array of points.
@param sz Number of elements in array (12 or 24).
@param r Radius.
@param erp Error report, may be NULL.
@return 1 on success, 0 on error.
Error codes:
- DK4_E_INVALID_ARGUMENTS<br>
if ptr is NULL, r is negative or the number of points
is neither 12 nor 24.
*/
int
dk4gratool_points_for_circle(
dk4_gra_point_t *ptr,
size_t sz,
double r,
dk4_er_t *erp
);
/** Initialize points to draw an ellipse.
@param ptr Address of result array of points.
@param sz Number of elements in array (12 or 24).
@param xc Center point x.
@param yc Center point y.
@param rx X radius.
@param ry Y radius.
@param alpha Rotation counterclockwise in radians.
@param erp Error report, may be NULL.
@return 1 on success, 0 on error.
Error codes:
- DK4_E_INVALID_ARGUMENTS<br>
if ptr is NULL, r is negative or the number of points
is neither 12 nor 24.
*/
int
dk4gratool_points_for_ellipse(
dk4_gra_point_t *ptr,
size_t sz,
double xc,
double yc,
double rx,
double ry,
double alpha,
dk4_er_t *erp
);
/** Rotate a point relatively to origin.
@param pt Point whose coordinates must be changed (in/out),
must not be NULL (not checked in function).
@param rot Rotation counterclockwise in radians.
*/
void
dk4gratool_rotate_point(
dk4_gra_point_t *pt,
double rot
);
/** Calculate distance between two points.
@param a Point A.
@param b Point B.
@param erp Error report, may be NULL.
@return Distance between the points.
*/
double
dk4gratool_dist_point_point(
dk4_gra_point_t const *a,
dk4_gra_point_t const *b,
dk4_er_t *erp
);
/** Calculate distance between a track specified by points
A and B and an external point P.
@param a Track endpoint A.
@param b Track endpoint B.
@param p External point P.
@param erp Error report, may be NULL.
@return Distance from point P to track specified by endpoint A, B.
*/
double
dk4gratool_dist_point_track(
dk4_gra_point_t const *a,
dk4_gra_point_t const *b,
dk4_gra_point_t const *p,
dk4_er_t *erp
);
/** Calculate distance between a simple ellipse (in origin, not rotated)
and a point.
This is a poor approximation working best if rx and ry do not
differ too much.
@param rx Ellipse x radius.
@param ry Ellipse y radius.
@param p Point.
@return Non-negative value on success, negative value on error.
*/
double
dk4gratool_dist_point_ellipse_simple(
double rx,
double ry,
dk4_gra_point_t const *p
);
/** Calculate distance between a rotated ellipse and a point.
This is a poor approximation working best if rx and ry do not
differ too much.
@param c Ellipse center point.
@param rx Ellipse x radius.
@param ry Ellipse y radius.
@param rot Ellipse rotation.
@param p Point to calculate distance to.
@param erp Error report, may be NULL.
@return Distance value.
*/
double
dk4gratool_dist_point_ellipse(
dk4_gra_point_t const *c,
double rx,
double ry,
double rot,
dk4_gra_point_t const *p,
dk4_er_t *erp
);
#ifdef __cplusplus
}
#endif
/* vim: set ai sw=4 ts=4 : */
#endif
|