0

1

I made my account just for this, as I have 0 clue where to start when tackling this problem. I have a grid of hexagons and I want to generate a path from point a to b right now I can generate a straight path which, but I wanted to know how you would go about generating curves like some trig functions do. There will be no obstacles in place of this grid, but I do wonder if that causes extra problems and how you would go about fixing that. It isn't major problem, and I could probably spaghetti code it out if I wanted to. But I want to know where to start on a problem like this and the most efficient way to solve it. Ill state this was originally coded on lua, but I don't care what type of answer I as long as it explains a solution.

The type of lines im looking for to be displayed on a simple hexagon grid

vimuth
  • 5,064
  • 33
  • 79
  • 116
BaldFelix
  • 1
  • 1
  • What do you mean with "like some trig functions do"? If you want to generate curved paths through an arbitrary number of points, look at 2D curve fitting (the easiest of which is usually called catmull-rom curves, even if they're something that's similar to but not actually catmull-rom curves). Also, while the rule is "don't use images of text", that doesn't mean "don't use images": in this case including an image of what you're talking about would be an excellent idea. – Mike 'Pomax' Kamermans Aug 18 '22 at 05:32
  • see [How can i produce multi point linear interpolation?](https://stackoverflow.com/a/30438865/2521214) polynomial cubic curves are the right way for this – Spektre Aug 18 '22 at 11:23

1 Answers1

0

You can sample a lot of points of you function and draw straight lines between them. It looks like its what geogebra does (try graphing x*sin(1/x), you'll see that it is not always enough but its simple and very efficient in most of the cases).

Cadeyrn
  • 545
  • 2
  • 12