### Interpolation functions in Fuses?

Posted:

**Mon Jan 07, 2019 7:04 am**Does anyone know if its possible to interpolate a new set of positions as a function in a .fuse, there is a command to convert to a bspline on masks but nothing as far as I can see in the docs or any of the examples in the shape fuses. I have looked into interpolation algorithms(linear seems the easiest) but in .lua that is still difficult.

I have 3 points I need to interpolate in some way which ever way is easiest, hopefully just something simple . If its not simple, then this maybe a possibility

De Casteljau's algorithm

https://www.khanacademy.org/partner-con ... animation7

Or

Catmull-rom interpolation

https://github.com/pkulchenko/ZeroBrane ... ullrom.lua

I looked into math.cos() and math.sin which is how most of the circular shapes are created, but would give a perfect arc which isn't what I want.

I would need the current Middle Vector point I have to act as a Bspline control for a new interpolated(curved) set of points that use the original 3 points as reference.

Here is a loop I would use to plot the new points and lines(currently just a circle) but I hopefully will be able to interpolate the points and resample using "sides" number

Best solution would be Shape() = MakeItSmooth(How.Smooth?)

Code: Select all

```
-- Lines to points
local line1 = Shape()
line1:MoveTo(start1.X, convertY(start1.Y, img))
line1:LineTo(V3[1],convertY(V3[2],img)) -- Line to Mid
line1:LineTo(P2[1],convertY(P2[2],img)) -- Line to end
```

De Casteljau's algorithm

https://www.khanacademy.org/partner-con ... animation7

Or

Catmull-rom interpolation

https://github.com/pkulchenko/ZeroBrane ... ullrom.lua

I looked into math.cos() and math.sin which is how most of the circular shapes are created, but would give a perfect arc which isn't what I want.

I would need the current Middle Vector point I have to act as a Bspline control for a new interpolated(curved) set of points that use the original 3 points as reference.

Here is a loop I would use to plot the new points and lines(currently just a circle) but I hopefully will be able to interpolate the points and resample using "sides" number

Code: Select all

```
line2:MoveTo(start1.X, convertY(start1.Y, img))
for i = 1, sides - 1 do
line2:LineTo(P1[1]+cos(i/sides * math.pi * 2 + angle) * r,convertY(P1[2]+sin(i/sides * math.pi * 2 + angle) * r,img))
end
```

Best solution would be Shape() = MakeItSmooth(How.Smooth?)