Search code examples
c#mathcurve

Calculate a specific curve with specific rotation, c#


I am trying to code for a game I am working on a specific curve with a specific rotation. I am not a great mathematician... At all... Tried searching for solutions for a few hours, but I'm affraid I do not find any solution.

So, a small picture to illustrate first:

enter image description here

This is an eighth of a circle, radius of 9, beggining is (0,0)

The end is now at about 6.364, -2.636. But I need this same curve, with a 45° direction at the end, but ending at aexactly 6.0,-3.0.

Could any of you show me how to do this? I need to be able to calculate precisly any point on this curve & its exact length. I would suppose using some kind of eliptical math could be a solution? I admit my math class are reaaaly far now and have now good clue for now...

Thank for any possible help


Solution

  • I think I found a quadratic curve which sastisfies your requirement:

    f(x) = -1/12 x^2 + 9
    

    Copy the following into https://www.desmos.com/calculator to see it:

    -\frac{1}{12}x^2+9
    

    f'(x) would be -1/6x, so when x=6, the derivative would be -1, which corresponds to a -45° inclination. There are probably infinite curves that satisfy your requirement but if my calculus isn't too rusty this is one of them.

    I tried to fit an ellipse with foci starting at y=6 here and starting at y=9 here to your points but the slope doesn't look like 45°. Also starting at any height k, here doesn't seem to work.