last day (14 days later) » 

5:48 AM
0
Q: Get points from a UIBezierPath

Maximus S I drew the above BezierPath by doing: // location is where the user touches screen. // location will be the maximum of the graph CGPoint origin = CGPointMake(xStart, 620.0); CGPoint endpt = CGPointMake(xEnd, 620.0); CGPoint midpt1 = midPointForPoints(origin, location); C...

 
This is such a great video. Anyone who uses Bezier path must watch this. thanks @matt
 
Are you sure you solved for t correctly here? It doesn't quite feel right, though it may just be a different factorization. wolframalpha.com/input/?i=x+%3D+%281-t%29%5E2*X_0+%2B+2*t*%281-t%29*X‌​_1+%2B+t%5E2+*X_2+solve+for+t
 
I am not sure how to check whether I solved for t right. This is my python version: gist.github.com/woniesong92/c7f79c812f1ae8be21f5
 
also, when you say you don't get the correct point, how far off is it? Does it ever work (for straight lines, or simpler curves)? Bezier can be very sensitive to small errors in t at different points in the curve.
 
First of all, thanks for helping me @RobNapier. The first problem that I recognize is that t-value is not in the bounds [0,1] when X is greater than some value (midpoint of the screen). I would love to get help from you in a chat too if that's possible.
 
5:48 AM
sure; that's probably easiest.
 
Hey Rob! Thanks so much.
 
sure. I don't know if you were able to read the link, but WolframAlpha will do the algebra for you: wolframalpha.com/input/?i=x+%3D+%281-t%29%5E2*X_0+%2B+2*t*%281-t%29*X‌​_1+%2B+t%5E2+*X_2+solve+for+t
Just go to wolframalpha.com and enter "x = (1-t)^2*X_0 + 2*t*(1-t)*X_1 + t^2 *X_2 solve for t"
 
ok just a moment
Let my try to compute this in python and see if I get a different result
or actually I can just plug in numbers for the variables in wolfram alpha! I am gonna do that..
Oh I see, I get a different t value
So I think I should change my function to resemble wolfram alpha's equation and see if I get the right t values
 
seems a good start
 
just a minute :)
 
6:02 AM
gotta run now; good luck w/ it. You may be interested in this project, which does a lot of Bezier point calculations (including computing distance along the path). github.com/iosptl/ios7ptl/blob/master/ch21-Text/CurvyText/… . I have a few blog posts about how to calculate Bezier very quickly here: robnapier.net/faster-bezier
(but for you specific issue, solving for t is probably a very good answer)
 
oh ok Rob
Thank you for your help. I will talk to fang
The points are more similar, but I do still have some discrepancy
 

last day (14 days later) »