Calculation of the quadrant curve between two points xy

I have two (x, y) start and end points. I want to animate from start to finish, but instead of going in a linear way, I want to create a curved path.

I’m sure that I’m not looking for easing, because I do not want to influence the speed of the animation, I just want to calculate the curved path.

I realized that I needed some kind of breakpoint, as shown in this image:

enter image description here

But I have no idea how to implement it. I would like to create a function that takes the following parameters

function calculateXY(start, end, controlpoint, percentage); 

Where the percentage will be from 0 to 100% and where 0 will return the starting position and 100% ending position.

The solution does not have to be in Objective-C, it can be in any programming language. I just can't get around the math :)

+6
source share
2 answers

Check this link and specifically Equation 2, which looks easy to implement in code.

Found a fragment that does this for you.

+3
source

See the Cocoa Bezier path: (NSBezierPath) .

It seems like this may not support quadratic Bezier curves, so you need to convert to a cube .

0
source

Source: https://habr.com/ru/post/900230/


All Articles