annotate src/dmcurves.c @ 2294:7f6ba3b32f54

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Jul 2019 10:28:43 +0300
parents 7df95aefb9c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * DMLib
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * -- Curve and spline functions
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * (C) Copyright 2015 Tecnic Software productions (TNSP)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 */
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 #include "dmcurves.h"
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
978
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
10 void dmLerpInit(DMLerpContext *ctx, DMFloat start, DMFloat end, DMFloat nsteps)
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
11 {
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
12 ctx->start = start;
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
13 ctx->end = end;
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
14 ctx->nsteps = nsteps;
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
15 }
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
16
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
17
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
18 DMFloat dmCatmullRom(const DMFloat t, const DMFloat p0, const DMFloat p1, const DMFloat p2, const DMFloat p3)
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
19 {
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
20 const DMFloat q = t * t;
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
21 return (
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
22 (2 * p1) +
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
23 (-p0 + p2) * t +
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
24 (2 * p0 - 5 * p1 + 4 * p2 - p3) * q +
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
25 ( -p0 + 3 * p1 - 3 * p2 + p3) * q * t
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
26 ) * 0.5f;
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
27 }
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
28
fecf3967abee Move lerp functions from dmlerp.c to dmcurves.c, too.
Matti Hamalainen <ccr@tnsp.org>
parents: 976
diff changeset
29
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 static inline const DMVector *dmSplineGetPoint(const DMVector *points, const int npoints, const int n)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 {
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 return (n < 0) ? &points[0] : ((n < npoints) ? &points[n] : &points[npoints - 1]);
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 }
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
36 int dmBSplineGenerate(const DMVector *points, const int npoints, const int slod,
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
37 int (*callback)(void *data, const int ndst, const int nc, float x, float y, float z),
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
38 void *data, const int ndst)
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 {
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 int cv, j;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
42 for (cv = -3, j = 0; j != npoints + 1; j++, cv++)
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 {
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 // for each section of curve, draw 'lod' number of divisions
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 int i;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 for (i = 0; i != slod; i++)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 {
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
48 int ret;
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 const float t = (float) i / slod;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 const float it = 1.0f - t;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
984
0ba1ec9b8608 Comment cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 978
diff changeset
52 // Calculate blending functions for cubic bspline
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 const float t2 = t * t;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 const float t3 = t2 * t;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 const float b0 = it * it * it / 6.0f;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 const float b1 = ( 3*t3 - 6*t2 + 4) / 6.0f;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 const float b2 = (-3*t3 + 3*t2 + 3*t + 1) / 6.0f;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 const float b3 = t3 / 6.0f;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
984
0ba1ec9b8608 Comment cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 978
diff changeset
60 // Calculate coordinates of the curve point
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
61 if ((ret = callback(data, ndst, j,
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
62 b0 * dmSplineGetPoint(points, npoints, cv + 0)->x +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
63 b1 * dmSplineGetPoint(points, npoints, cv + 1)->x +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
64 b2 * dmSplineGetPoint(points, npoints, cv + 2)->x +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
65 b3 * dmSplineGetPoint(points, npoints, cv + 3)->x
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
66 ,
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
67 b0 * dmSplineGetPoint(points, npoints, cv + 0)->y +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
68 b1 * dmSplineGetPoint(points, npoints, cv + 1)->y +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
69 b2 * dmSplineGetPoint(points, npoints, cv + 2)->y +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
70 b3 * dmSplineGetPoint(points, npoints, cv + 3)->y
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
71 ,
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
72 b0 * dmSplineGetPoint(points, npoints, cv + 0)->z +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
73 b1 * dmSplineGetPoint(points, npoints, cv + 1)->z +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
74 b2 * dmSplineGetPoint(points, npoints, cv + 2)->z +
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
75 b3 * dmSplineGetPoint(points, npoints, cv + 3)->z
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
76 )) != DMERR_OK)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
77 return ret;
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 }
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 }
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
81 return DMERR_OK;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
82 }
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
83
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
84
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
85 /*
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
86 static int dmSplineAddGL(void *data, const int ndst, const int nc, float x, float y, float z)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
87 {
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
88 (void) data;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
89 glVertex3f(x, y, z);
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
90 return DMERR_OK;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
91 }
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
92
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
93
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
94 int dmGLBSpline(const DMVector *points, const int npoints, const int slod)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
95 {
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
96 // begin drawing our curve
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
97 glBegin(GL_LINE_STRIP);
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
98
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
99 return dmBSplineGenerate(points, npoints, slod, dmSplineAddGL, NULL, 0);
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
100
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
101 // we need to specify the last point on the curve
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
102 glVertex3fv(points[npoints - 1]);
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
103 glEnd();
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
104 }
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
105 */
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
106
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
107
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
108 static int dmSplineAddVector(void *data, const int ndst, const int nc, float x, float y, float z)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
109 {
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
110 if (nc < ndst)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
111 {
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
112 DMVector **dst = (DMVector **) data;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
113
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
114 (*dst)->x = x;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
115 (*dst)->y = y;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
116 (*dst)->z = z;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
117
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
118 (*dst)++;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
119 return DMERR_OK;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
120 }
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
121 else
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
122 return DMERR_BOUNDS;
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
123 }
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
124
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
125
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
126 int dmBSplineGenerateArray(DMVector *dst, const int ndst, const DMVector *points, const int npoints, const int slod)
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
127 {
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
128 return dmBSplineGenerate(points, npoints, slod, dmSplineAddVector, &dst, ndst);
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 }
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 int dmBSplineGenerateAlloc(DMVector **dst, int *ndst, const DMVector *points, const int npoints, const int slod)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 {
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 if (ndst == NULL || dst == NULL)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 return DMERR_NULLPTR;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 if ((*ndst = dmBSplineGetNPoints(npoints, slod)) <= 0)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 return DMERR_INVALID_DATA;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 if ((*dst = dmCalloc(*ndst, sizeof(DMVector))) == NULL)
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 return DMERR_MALLOC;
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
1081
7df95aefb9c6 Make bspline functions more flexible.
Matti Hamalainen <ccr@tnsp.org>
parents: 984
diff changeset
143 return dmBSplineGenerate(points, npoints, slod, dmSplineAddVector, *dst, *ndst);
976
1b439304ff3c Add new module dmcurves, that will contain functions for spline generation
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 }