Fast C# Tween 2 Points

Hi all,

I was wondering whether anyone could shed any light about what’s happening under the hood of the Pufferfish ‘Tween Two Points’ node? I was looking to emulate the functionality in C# mainly to reduce a dependency (getting students to install plugins is rarely easy) and also perhaps pick up a process speed boost if possible.

Thank you for any help,

C

You can create a line between them and use divide curve

That’s a good point, but it takes about 140% of the time. I have a lot of points.

Oh whoops, do you mean in C# instead? I’ll see whether that’s faster.

Or like this

With Python

This work like Pufferfish tween 2 points

tween 2 points.gh (7.6 KB)

1 Like

Perfect, thank you!

I am guessing pufferfish is interpolating the values and not using line.PointAt, since there are several components that would work with the same logic.

meant something like this:


Interesting just how much slower these are than the Pufferfish component

the scripting component is always slower than a compiled one.

2 Likes

also try hitting f5

Hi,

a script component is usually slower, but there are tons of tricks to get better performance. With some tricks applied, basically by bypassing the copying of data during in- and output, you can improve performance significantly… Also note, there are many more optimizations possible. This particular problem even qualifies for vectorization using SIMD instructions. However, the stronger you optimize, the harder code becomes to manage/read. If you are happy with the speed, you shouldn’t improve further just because for the sake of optimization. You might add unnecessary code complexity.

See:


points.gh (17.7 KB)

8 Likes

That was an evil way of lumping together many points into one object! :rage: :smiley:
image