Roger Travis
Roger Travis

Reputation: 8538

How to smooth a line ( point array ) in c#?

Suppose you have an array of Points that draw a line like this

enter image description here

yet it is a bit jagged and you want o make it smoother. what would you suggest?

Thanks

Upvotes: 0

Views: 1284

Answers (2)

Igor Ševo
Igor Ševo

Reputation: 5525

You could average the points you have: Iterate through all the points in groups of three and bring the middle point in each of the groups closer to the center point between the two points. It would need some experimenting on how much to bring the points closer, but you could average the array several times.

Upvotes: 3

Igor Ševo
Igor Ševo

Reputation: 5525

Instead of drawing points, draw a curve with those points using Graphics.DrawCurve(...).

Upvotes: 1

Related Questions