tag:blogger.com,1999:blog-2272960549867699733.post5331375737741482566..comments2022-04-11T10:29:45.289-07:00Comments on gludion: Distance to a Quadratic bezier curveUnknownnoreply@blogger.comBlogger22125tag:blogger.com,1999:blog-2272960549867699733.post-23032598333056387452014-04-14T16:02:37.688-07:002014-04-14T16:02:37.688-07:00Something related
http://microbians.com/?page=mat...Something related<br /><br />http://microbians.com/?page=math&id=math-quadraticbezierthroughthreepoints<br />http://microbians.com/?page=math&id=math-quadraticbezieroffsetingAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-85073883191268935862013-04-25T14:06:01.475-07:002013-04-25T14:06:01.475-07:00Thanks for this post--it is helpful. However--the...Thanks for this post--it is helpful. However--there are some areas where the math gloss makes things a little hard to follow--specifically where you develop the at3 + bt² + ct + d = 0. Is there any sort of link to this derivation available? Thanksanzatzihttps://www.blogger.com/profile/15210571914862436229noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-50678109170697668972013-04-22T22:51:30.808-07:002013-04-22T22:51:30.808-07:00Thank you so much! I've been trying to figure ...Thank you so much! I've been trying to figure out how to do this for quite a while. It was driving me crazy!jbsullihttps://www.blogger.com/profile/14362047840517774362noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-61768227283642564322012-11-27T07:38:37.360-08:002012-11-27T07:38:37.360-08:00There is somethink weird going on inside the quadr...There is somethink weird going on inside the quadratic (D=0) section. It look, it "snap" to the inflection point thus giving incorrect results. I rewrote your code to HLSL and this image is what I get: http://goo.gl/Ge1PE . Note that even this is special case (P0 == P2), its wrong anytime the angle is too sharp (in my test case up to P0[-80;0], P1[0;0] P2[-80; 50]). I still am not able Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-43578982680081055192012-10-12T07:49:50.697-07:002012-10-12T07:49:50.697-07:00Thank you very much for posting this. It was exact...Thank you very much for posting this. It was exactly what I was looking for for a game I am working on.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-57046558794209988142012-09-30T15:59:10.513-07:002012-09-30T15:59:10.513-07:00I'm a little confused by your expression of &q...I'm a little confused by your expression of "MP". This is the line segment from M to P(t'), right? You use the expanded expression:<br /><br /> (M - (1-t)²P0 + 2t(1-t)P1 +t²P2).(A+Bt) = 0<br /><br />since this is supposed to be the vector M-P(t'), should that be:<br /><br /><br /> (M - ((1-t)²P₀ + 2t(1-t)P₁ +t²P₂)) · (A+Bₜ) = 0<br /><br />instead? The one that is currentlyUnknownhttps://www.blogger.com/profile/13461418051535966555noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-1972619362896030822012-08-06T07:50:49.294-07:002012-08-06T07:50:49.294-07:00I updated the class and the demo as suggested by m...I updated the class and the demo as suggested by makc3d... sorry for the long delay !! ;)gludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-64217146758808265532012-05-20T13:52:54.882-07:002012-05-20T13:52:54.882-07:00great post , thanks :)great post , thanks :)Ahmed Kotbhttps://www.blogger.com/profile/15108338360177948211noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-4728238423948325072012-02-07T06:52:36.068-08:002012-02-07T06:52:36.068-08:00I want to know on which side the point lies.(side ...I want to know on which side the point lies.(side where distance is negative or side where distance is positive). Your negative distance is helpful to me. But curious to know how a distance is coming out negative.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-84410534771378289862011-01-13T08:09:10.366-08:002011-01-13T08:09:10.366-08:00Sorry, I don't know..
But it seems that Google...Sorry, I don't know..<br />But it seems that Google does ;-)gludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-23861700791446136032011-01-13T06:46:47.576-08:002011-01-13T06:46:47.576-08:00Thanks! I suspected it was the same, but I didn...Thanks! I suspected it was the same, but I didn't check it. I must have put a sign wrong somewhere in my code. BTW do you know how the formula looks to check if two quadratic bezier's intersect? Or if they don't the points on the curves that are closest to each other?<br /><br />Thanks!<br /><br />/PerAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-10087274651933911462011-01-13T06:23:25.130-08:002011-01-13T06:23:25.130-08:00Hello, thanks for sharing!
However, in your formu...Hello, thanks for sharing!<br /><br />However, in your formula (a = B.2*(2P1 - P0 - P2)), it's actually equivalent to:<br />a = -2*B.B, because B = P2-2P1+P0.<br /><br />So, I think both our solutions are about the same (probably all your a,b,c,d are multiplied by -2 or 2, which doesn't change the validity of the equation).<br />In my formula, the purpose of A and B was precisely to gludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-69683455310670240372011-01-13T05:37:36.936-08:002011-01-13T05:37:36.936-08:00Thank you for posting this! I had some strange res...Thank you for posting this! I had some strange results with the code though. So I did the same for a cubic bezier and it work perfectly, giving a 5th degree polynomial.<br /><br />I then did the calculus for the quadratic bezier myself and came up with a different solution, I think...<br /><br />Setting A = P1 - P0 and B = P2 - P1 - A<br /><br />I got a = B.2*(2P1 - P0 - P2) . is the dot product<Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-65874321646314860902010-08-24T23:00:11.853-07:002010-08-24T23:00:11.853-07:00Thanks very much for this post.
Aways great to fin...Thanks very much for this post.<br />Aways great to find complex things simplified.<br />:)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-50239762431603560762009-09-03T07:48:11.883-07:002009-09-03T07:48:11.883-07:00wow !!
you're absolutely right... I didn't...wow !!<br />you're absolutely right... I didn't think about this case :/<br /><br />I will add your suggestion ASAP.<br />thx a lot for your input :Dgludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-35509535349485836552009-09-03T06:50:31.756-07:002009-09-03T06:50:31.756-07:00BTW, a complete solution should always check dista...BTW, a complete solution should always check distance to both endpoints (whether or not the result is null) as there are certain cases where this returns the wrong distance because there are a few corner cases in the initial premise - the shortest distance is always tangent to the curve.<br /><br />See this image for an incorrect response from this function:<br /><br />http://www.onetacoshort.comJeff Wardhttps://www.blogger.com/profile/13631881438835050703noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-60575055103462379522009-09-03T06:36:04.070-07:002009-09-03T06:36:04.070-07:00Those wikipedia gifs are indeed awesome. Thanks f...Those wikipedia gifs are indeed awesome. Thanks for your post!Jeff Wardhttps://www.blogger.com/profile/13631881438835050703noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-6879399672816401652009-08-31T01:53:12.297-07:002009-08-31T01:53:12.297-07:00yes, the dots disappear if no point P of the bezie...yes, the dots disappear if no point P of the bezier curve meets the condition MP.dP/dt = 0.<br />In this case, the function returns null.<br />In my game, it usually corresponds to a case of point M colliding another curve.<br /><br />But actually you're right, it should provide one of the endpoints in such cases. <br /><br />It's easy to add some code testing which one of the 2 endPointsgludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-54619162981569465362009-08-30T13:08:59.517-07:002009-08-30T13:08:59.517-07:00no I mean that at certain positions dots just disa...no I mean that at certain positions dots just disappear, when they should remain at the segment endpoints.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-90187514434489726582009-08-28T01:38:17.257-07:002009-08-28T01:38:17.257-07:00oh got it.. you probably suggest I should mention ...oh got it.. you probably suggest I should mention it in the post. Now it's edited. Thanks ;)gludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-35688017934270323352009-08-28T01:31:03.643-07:002009-08-28T01:31:03.643-07:00Mh.. do you mean that I don't check the soluti...Mh.. do you mean that I don't check the solution for t are in [0,1] interval?.. I just checked my code and it's done at line 137:<br />if (t>=0 && t<=1) <br />Then, I don't get it.. Can you send me (olive_at_gludion.com) a screenshot showing the problem?gludionhttps://www.blogger.com/profile/01982306234493880464noreply@blogger.comtag:blogger.com,1999:blog-2272960549867699733.post-21127961436261511352009-08-27T11:48:45.054-07:002009-08-27T11:48:45.054-07:00seems like you didnt trim your solution to actual ...seems like you didnt trim your solution to actual segmentAnonymousnoreply@blogger.com