Hi! I have a function, let’s say f(ϕ) = sin(ϕ), ϕ = 0...10. Now I want to break that function down in a list of lines that approximates the real function well (maybe with a maximum or minimum line length, angle between lines, or number of lines). Is there a package that can help with that? Bonus points if it also works in polar coordinates.
Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread. (Original message )(More Info)
A little more information based on the discussion on Slack:
I have a function that only works on lines (let’s say (0.0, 0.0) -> (0.1, 0.3)), that’s why I want to turn my sin (for example) into a piecewise linear function/list of lines.
I know that some combination of inputs (e.g. number of lines and maximum length of lines) might give trouble, we can ignore that for now.
I imagined that adaptive algorithms of integration/differentiation equations might do something close to what I’m looking for, but 1) I’m not sure about that being true, 2) I don’t know any package that does just that.
PS: Is there any way for me to change the title of the post? At the moment it’s quite … nondescript.
Thank you but this isn’t what I’m looking for.
If we stay with the example of sin, around 0 this would be a good approximation but around π/2 it might be to coarse. So I’m looking for an package/algorithm that picks the steps so that I can set “maximum or minimum line length, angle between lines, or number of lines” (or at least more than just number of lines). If I have the points, turning them into lines should be fine.
If you write the derivative f’(t) of your function and plug it in the DifferentialEquations.jl package, you can define an error tolerance and you will get as solution f(t), sampled at irregular times. Use the resulting array of irregular times to break down your original function. PS: Yes, it sounds like using a sledgehammer to crack a nut.
It sounds like geometrically, you want to define a small circle around a point and then find the point where the function intersects the circle, then draw a circle around that point and find the next intersection and so on.
Fundamentally, this is a root finding problem in two dimensions. It should be possible to use Roots.jl or nlsolve, for example.