BRL-CAD
dspline.h
Go to the documentation of this file.
1/* D S P L I N E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2014-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @file dspline.h
21 *
22 */
23
24#ifndef RT_DSPLINE_H
25#define RT_DSPLINE_H
26
27#include "common.h"
28
29#include "vmath.h"
30
31#include "rt/defines.h"
32
33__BEGIN_DECLS
34
35/**
36 * Initialize a spline matrix for a particular spline type.
37 */
38RT_EXPORT extern void rt_dspline_matrix(mat_t m, const char *type,
39 const double tension,
40 const double bias);
41
42/**
43 * m spline matrix (see rt_dspline4_matrix)
44 * a, b, c, d knot values
45 * alpha: 0..1 interpolation point
46 *
47 * Evaluate a 1-dimensional spline at a point "alpha" on knot values
48 * a, b, c, d.
49 */
50RT_EXPORT extern double rt_dspline4(mat_t m,
51 double a,
52 double b,
53 double c,
54 double d,
55 double alpha);
56
57/**
58 * pt vector to receive the interpolation result
59 * m spline matrix (see rt_dspline4_matrix)
60 * a, b, c, d knot values
61 * alpha: 0..1 interpolation point
62 *
63 * Evaluate a spline at a point "alpha" between knot pts b & c. The
64 * knots and result are all vectors with "depth" values (length).
65 *
66 */
67RT_EXPORT extern void rt_dspline4v(double *pt,
68 const mat_t m,
69 const double *a,
70 const double *b,
71 const double *c,
72 const double *d,
73 const int depth,
74 const double alpha);
75
76/**
77 * Interpolate n knot vectors over the range 0..1
78 *
79 * "knots" is an array of "n" knot vectors. Each vector consists of
80 * "depth" values. They define an "n" dimensional surface which is
81 * evaluated at the single point "alpha". The evaluated point is
82 * returned in "r"
83 *
84 * Example use:
85 *
86 * double result[MAX_DEPTH], knots[MAX_DEPTH*MAX_KNOTS];
87 * mat_t m;
88 * int knot_count, depth;
89 *
90 * knots = bu_malloc(sizeof(double) * knot_length * knot_count);
91 * result = bu_malloc(sizeof(double) * knot_length);
92 *
93 * rt_dspline4_matrix(m, "Catmull", (double *)NULL, 0.0);
94 *
95 * for (i=0; i < knot_count; i++)
96 * get a knot(knots, i, knot_length);
97 *
98 * rt_dspline_n(result, m, knots, knot_count, knot_length, alpha);
99 *
100 */
101RT_EXPORT extern void rt_dspline_n(double *r,
102 const mat_t m,
103 const double *knots,
104 const int n,
105 const int depth,
106 const double alpha);
107
108
109__END_DECLS
110
111#endif /* RT_DSPLINE_H */
112
113/*
114 * Local Variables:
115 * tab-width: 8
116 * mode: C
117 * indent-tabs-mode: t
118 * c-file-style: "stroustrup"
119 * End:
120 * ex: shiftwidth=4 tabstop=8
121 */
Header file for the BRL-CAD common definitions.
void rt_dspline_n(double *r, const mat_t m, const double *knots, const int n, const int depth, const double alpha)
double rt_dspline4(mat_t m, double a, double b, double c, double d, double alpha)
void rt_dspline_matrix(mat_t m, const char *type, const double tension, const double bias)
void rt_dspline4v(double *pt, const mat_t m, const double *a, const double *b, const double *c, const double *d, const int depth, const double alpha)
void float float int * n
Definition: tig.h:74
void int * c
Definition: tig.h:139
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:366
fundamental vector, matrix, quaternion math macros