aboutsummaryrefslogtreecommitdiff
path: root/src/un_splines.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/un_splines.c')
-rw-r--r--src/un_splines.c85
1 files changed, 69 insertions, 16 deletions
diff --git a/src/un_splines.c b/src/un_splines.c
index 7b27ee0..c6d2844 100644
--- a/src/un_splines.c
+++ b/src/un_splines.c
@@ -1,40 +1,93 @@
-real un_m_bezierr(real a, real q0, real q1, real b, real t) {
- real i0, i1, i2, p1, p2;
+void un_m_bezierr(real *v, real a, real q0, real q1, real b, real t) {
+ real i0, i1, i2, p0, p1;
i0 = un_m_lerpr(a, q0, t);
i1 = un_m_lerpr(q0, q1, t);
i2 = un_m_lerpr(q1, b, t);
- p1 = un_m_lerpr(i0, i1, t);
- p2 = un_m_lerpr(i1, i2, t);
+ p0 = un_m_lerpr(i0, i1, t);
+ p1 = un_m_lerpr(i1, i2, t);
- return un_m_lerpr(p1, p2, t);
+ *v = un_m_lerpr(p0, p1, t);
}
-f32 un_m_bezierf(f32 a, f32 q0, f32 q1, f32 b, f32 t) {
- f32 i0, i1, i2, p1, p2;
+void un_m_bezierf(f32 *v, f32 a, f32 q0, f32 q1, f32 b, f32 t) {
+ f32 i0, i1, i2, p0, p1;
i0 = un_m_lerpf(a, q0, t);
i1 = un_m_lerpf(q0, q1, t);
i2 = un_m_lerpf(q1, b, t);
- p1 = un_m_lerpf(i0, i1, t);
- p2 = un_m_lerpf(i1, i2, t);
+ p0 = un_m_lerpf(i0, i1, t);
+ p1 = un_m_lerpf(i1, i2, t);
- return un_m_lerpf(p1, p2, t);
+ *v = un_m_lerpf(p0, p1, t);
}
-f64 un_m_bezierd(f64 a, f64 q0, f64 q1, f64 b, f64 t) {
- f64 i0, i1, i2, p1, p2;
+void un_m_bezierd(f64 *v, f64 a, f64 q0, f64 q1, f64 b, f64 t) {
+ f64 i0, i1, i2, p0, p1;
i0 = un_m_lerpd(a, q0, t);
i1 = un_m_lerpd(q0, q1, t);
i2 = un_m_lerpd(q1, b, t);
- p1 = un_m_lerpd(i0, i1, t);
- p2 = un_m_lerpd(i1, i2, t);
+ p0 = un_m_lerpd(i0, i1, t);
+ p1 = un_m_lerpd(i1, i2, t);
- return un_m_lerpd(p1, p2, t);
+ *v = un_m_lerpd(p0, p1, t);
}
-// add v2-4 variants
+void un_m_bezier2r(real *v, real *a, real *q0, real *q1, real *b, real t) {
+ un_m_bezierr(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierr(v + 1, a[1], q0[1], q1[1], b[1], t);
+}
+
+void un_m_bezier3r(real *v, real *a, real *q0, real *q1, real *b, real t) {
+ un_m_bezierr(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierr(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierr(v + 2, a[2], q0[2], q1[2], b[2], t);
+}
+
+void un_m_bezier4r(real *v, real *a, real *q0, real *q1, real *b, real t) {
+ un_m_bezierr(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierr(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierr(v + 2, a[2], q0[2], q1[2], b[2], t);
+ un_m_bezierr(v + 3, a[3], q0[3], q1[3], b[3], t);
+}
+
+void un_m_bezier2f(f32 *v, f32 *a, f32 *q0, f32 *q1, f32 *b, f32 t) {
+ un_m_bezierf(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierf(v + 1, a[1], q0[1], q1[1], b[1], t);
+}
+
+void un_m_bezier3f(f32 *v, f32 *a, f32 *q0, f32 *q1, f32 *b, f32 t) {
+ un_m_bezierf(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierf(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierf(v + 2, a[2], q0[2], q1[2], b[2], t);
+}
+
+void un_m_bezier4f(f32 *v, f32 *a, f32 *q0, f32 *q1, f32 *b, f32 t) {
+ un_m_bezierf(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierf(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierf(v + 2, a[2], q0[2], q1[2], b[2], t);
+ un_m_bezierf(v + 3, a[3], q0[3], q1[3], b[3], t);
+}
+
+
+void un_m_bezier2d(f64 *v, f64 *a, f64 *q0, f64 *q1, f64 *b, f64 t) {
+ un_m_bezierd(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierd(v + 1, a[1], q0[1], q1[1], b[1], t);
+}
+
+void un_m_bezier3d(f64 *v, f64 *a, f64 *q0, f64 *q1, f64 *b, f64 t) {
+ un_m_bezierd(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierd(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierd(v + 2, a[2], q0[2], q1[2], b[2], t);
+}
+
+void un_m_bezier4d(f64 *v, f64 *a, f64 *q0, f64 *q1, f64 *b, f64 t) {
+ un_m_bezierd(v + 0, a[0], q0[0], q1[0], b[0], t);
+ un_m_bezierd(v + 1, a[1], q0[1], q1[1], b[1], t);
+ un_m_bezierd(v + 2, a[2], q0[2], q1[2], b[2], t);
+ un_m_bezierd(v + 3, a[3], q0[3], q1[3], b[3], t);
+}