Is there a type of spline which can produce (approximately) the following result given the specified points indicated. I want to be able to specify how curved the corners are from the "centre points" so that I get "very square" corners to "very round" corners. Sorry about my shakey hand ! Points along a line should produce (roughly) a linear curve.

I found quite a few questions and answers online about this but they all seem to be B-spline related, and don't (I think) quite capture my constraints. If anybody knows what I'm looking for, direction to an online reference/article would be great.

My points always appear on an integer lattice (grid), and are always equally spaced.

I'm looking for something low complexity, but which I can pass a value, say t in [0,1] and returns the (x,y) position of the curve at that time. I realise I could probably build a function like this piece-wise, but wondered if there is a ready made spline solution (piece-wise equation) which could achieve the same result.

Maybe B-splines or NURBS are the answer, but maybe they are heavy on computation too...

enter image description here

Given Sirisian's answer below, I suddenly realised how Bezier curves work. Wow they really are a clever idea! enter image description here

Everything seems centred around a single t value, e.g.

l1(t) = a+t(b-a)
l2(t) = b+t(c-b))
m(t)  = l1(t)+t(l2(t)-l1(t))

We can expand m to simplify if necessary.

I think B-Splines give a nice result, e.g. see below. It also has the advantage of not being restricted to a uniform grid. Not sure about speed of computation yet though...

enter image description here enter image description here


Seems like a simple quadratic Bézier curve would be sufficient.


Implementation-wise you'd just draw a line for horizontally or vertically connected nodes and then a curve for the other cases.

An alternative that would be more complex would be use to use an arc like in the SVG spec:


There are implementation details in the spec for how it functions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.