/*
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
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
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