Finding point x units further down nonlinear function

Started by
19 comments, last by taxfromdk 11 years, 10 months ago
Given a function on the form:

f(x)=1-(x*0.8)^1.25
(constants may change)

I would like to be able to determine the point (x,y) that lies n units from the y-axis along the function path.

[EDIT]
I would like to be able to determine the point (x,y) that lies n units (following the function) from the point f(0).
[/EDIT]

Is there a method to do this, or am I forced to walk the function in small steps?

Thanx in advance

Tax
Advertisement
You can invert the function so that you have x as a function of y instead. Then you just calculate your x as f[sup]-1[/sup](y+n).
Okay, to do the algebra:

From your equation above, let c (constant) = 1, s (scale) = 0.8 and p (power) = 1.25

y = c - (x * s) ^ p
y - c = -(x * s) ^ p
(y - c) ^ (1 / p) = - (x * s) <= note, this step is not strictly accurate in all cases
-(y - c) ^ (1 / p) = x * s
-s * ((y - c) ^ (1 / p)) = x

This seems simple enough, but note the questionable step where we root both sides. Functions like quadratics, cubics etc may have multiple x values that have the same y value, so a general formula for uniquely inverting the function is impossible. Apparently there's a proof by Able that proves that even getting all roots algebraically is impossible.

It is possible that there's an exact solution for *your* problem because I note there's no (x - b) type of terms. I believe this means that the number of roots will not grow with the power. I suggest playing a bit with different values and see whether you encounter the multiple roots problem.

Okay, to do the algebra:

From your equation above, let c (constant) = 1, s (scale) = 0.8 and p (power) = 1.25

y = c - (x * s) ^ p
y - c = -(x * s) ^ p
(y - c) ^ (1 / p) = - (x * s) <= note, this step is not strictly accurate in all cases
-(y - c) ^ (1 / p) = x * s
-s * ((y - c) ^ (1 / p)) = x

This seems simple enough, but note the questionable step where we root both sides. Functions like quadratics, cubics etc may have multiple x values that have the same y value, so a general formula for uniquely inverting the function is impossible. Apparently there's a proof by Able that proves that even getting all roots algebraically is impossible

Let me expand on this, Abel's theorem states there is no systematic, closed-form formula to extract roots of polynomials of degree greater than four, using only elementary operations. However, some classes of polynomials *do* have a closed-form solution (for instance if there is only one term x^p, it can be solved by taking the p'th root, and other particular constructions can be solved as well). But no general solution exists.

Note that this doesn't rule out numerical solutions, which are, by the way, generally used for polynomials of degree three and greater, because the analytical formulae tend to get really messy. Check out the fourth degree solution if you don't believe me.

Of course this is not very useful because OP's equation is not a polynomial - polynomials admit integer exponents only. Such a function with a positive real exponent does have multiple roots (usually) but at most one is real - all others are complex.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Thanks Bacterius, I was unclear of the effect of real number exponents on this. Plus I was assuming p >= 1.
Hi guys,

First of all thank you for your time. :)

I am afraid that I have not been clear enough stating my problem, so I will briefly describe my application.

I am working on a vertex shader that will bend a flat game world so it will appear to be round like a small planet. I do this by picking a origin under the observing camera and offsetting all vertices in the world downwards. The offset is chosen by measuring the distance between the vertex and the origin in the horizontal plane, inserting that into my function to get the offset.

The problem is that the offset is chosen on basis on the X axis, and not the actual distance travelled along the line. It was the point based on the distance travelled I am trying to find.

I am not sure the extra math is noticable in the shader, but I just got curius on how to solve the problem.

I hope this makes things a bit clearer. And thanx again.

Tax

I would like to be able to determine the point (x,y) that lies n units from the y-axis along the function path.


*cough* won't f(5) make it 5 units away from y axis? f(5) will return y value = distance to x axis. So (f(5), 5) is your point in the function path. Replace 5 with n to get general case, which you need.

The only problem is, it might be -n and n are both n units away from y axis. Your function isn't symmetrical, therefore it's up to you to decide which side you want.
Yes that is true, but that is not what I am looking fore. It turns out to be harder to explain. :)

The case is that I want the point on the function that is 5 units from f(0) following the curvature of the line. Imagine drawing the function on the floor, and rolling a wheel along the dunction. When the wheel has rolled D units, that is the point I want.

I am sorry for having a hard time explaining my problem.

Tax
So do you mean you want the arc length?
I think sicrane has the right idea. are dealing with a perfectly spherical planet with no mountains and valleys? If it helps you much, the length of the short arc between two points on a unit sphere is simply acos( dot product(point A, point B)), but I suppose you don't know what point B is and that's what you're trying to determine, so... As for plotting the path, if you have the vector pointing from the centre of the planet to point A, and the vector pointing along the direction of the path then you can use those two vectors as the input for the parametric circle equation, which you can use to plot the path. Of course, none of this may help you, if I'm misinterpreting what you're aiming for. Is there any particular reason you're using a flat representation for some aspects, but spherical for other aspects (other than, say, bitmap textures are flat)?

This topic is closed to new replies.

Advertisement