Colliding a Bezier Patch and a linesegment
Someone mentioned something about completing the square, but I''m not sure how to do that in this case...
Pragma: I''m afraid I don''t know what an ''implicit representation'' is, and I don''t see how finding the normal helps from a collision-detection point of view (which is mainly what I''m aiming at here).
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
u can be expressed as a simple quadratic in the form Au^2 + Bu + C = 0, where A, B, and C are:
A = (avv + bv + e)
B = (cvv + dv + g)
C = (fvv + hv + i - x0 - jt)
So theoretically, we can now solve for u using the quadratic equation:
(quadratic eq: x = (-b +/- sqrt(b^2-4ac))/2a)
u = ( -(cvv+dv+g) +/- sqrt( (cvv+dv+g)^2 - 4 * (avv+bv+e) * (fvv+hv+i-x0-jt) ) ) / 2 * (avv+bv+e)
In a similar way, we can take the Y dimension and solve V as:
A = (auu + cu + f)
B = (buu + du + h)
C = (euu + du + i - y0 - kt)
v = ( -(buu + du + h) +/- sqrt( (buu+du+h)^2 - 4 * (auu+cu+f) * (euu+du+i-y0-kt) ) ) / 2 * (auu+cu+f)
And then we simply (

Having said that, anyone feel like actually *doing* it?

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Hmm... Maybe we could do implicit differentiation and then rearrange it and integrate to solve for u, or something along those lines...
Given a real-valued function g(x,y,z), the implicit surface is the set of all points such that g(x,y,z) = 0. This is in contrast to an explicit representation where you have (x,y,z) = f(u,v) for u and v in some domain set.
Implicit representations are used in stuff like metaballs and fluid simulations and are a lot easier to deal with in raytracing, but a bitch to edit. Parametric surfaces are the norm in 3d modelling and cad, but they are a bitch to raytrace.
It''s in general a very hard problem to go from explicit to implicit representations, and even harder to go the other way. Usually it''s just done with approximations.
Oh, and the only reason I mentioned the normal is because that''s usually the first thing you want to find after you do a ray intersection query. It''s useful for lighting or for doing collision response, but if you don''t need it, don''t worry about it.

"Math is hard" -Barbie
quote:
Original post by Pragma
Given a real-valued function g(x,y,z), the implicit surface is the set of all points such that g(x,y,z) = 0. This is in contrast to an explicit representation where you have (x,y,z) = f(u,v) for u and v in some domain set.
Implicit representations are used in stuff like metaballs and fluid simulations and are a lot easier to deal with in raytracing, but a bitch to edit. Parametric surfaces are the norm in 3d modelling and cad, but they are a bitch to raytrace.
Oh, I get it - like with isosurfaces, you mean. Funnily enough, I''ve been doing some work on those... but nothing realtime.
vanillacoke: hum. That''s an arse.
Perhaps we need to try a different type of solution to this - algorithmic or something?
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Anyway, that''s what I did. I''m gonna try to make my computer solve the system, and then we''ll know for sure.
unfortunatly i wouldnt know of a better way to do it. the best thing i did in this respect was doing intersection with a simple cubic and a line: already a 4th degree function. you can solve it, but coding things to make computers work with non-real numbers is kinda slow.
anyway i dont know a better way to solve this equation, and get u & v, witch is kind of critical, cos how are you going to test if you actually hit the patch or went past it if you dont have u,v coords?
yet even how much it pains me to say so... i think implementing a good approximation algoritm is going to be the fastest solution here. aswell in coding time as in execution time. and besides the results will be accurate enough for this application.