Advertisement

Colliding a Bezier Patch and a linesegment

Started by April 20, 2003 02:01 PM
24 comments, last by superpig 21 years, 9 months ago
Pragma, I think your solution is beyond me at this point, so I''m gonna have to try to solve it with simple algebra.
You know what I never noticed before?
I''m having trouble rearranging that equation to get u, v, and t on their own.

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

Advertisement
Oh, here''s a possible:

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 () substitute one into the other, giving one of U or V in terms of T. Then we repeat the process using the third equation, giving a second expression for either U or V and T, and then solve the last two equations simultaneously to find T.

Having said that, anyone feel like actually *doing* it? Or is there an easier way than this?

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

Right, that''s the method I had thought out in my head. I will try to solve it, hopefully my TI-89 will be able to do most of it for me. I tried giving it the simultaneous bi-quadratic equations, and it just ran out of memory, so I will have to do part of the work myself. I don''t know of a better way to solve it, and I only hope that this solution is actually closed-form.
You know what I never noticed before?
I tries solving that system, with disastrous results. When you complete the square to solve for u and then substitute that into the y equation, you end up getting this ridiculous sextic equation of v, with square roots and a bunch of crazy shit. There is no analytic solution of sextic equations, so I don''t think this method is going to work. Any new suggestions?
Hmm... Maybe we could do implicit differentiation and then rearrange it and integrate to solve for u, or something along those lines...
You know what I never noticed before?
What I mean by an implicit representation of a surface:

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
"Math is hard" -Barbie
Advertisement
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

Hey, I think I found the solution: Buy Mathematica.
Anyway, that''s what I did. I''m gonna try to make my computer solve the system, and then we''ll know for sure.
You know what I never noticed before?
Well, Mathematica doesn''t seem to be much help here. I tried to have Mathematica solve the system, but it didn''t finish evaluating the system. I think I will try running it overnight, and see if it gives me anything then.
You know what I never noticed before?
well vanillacoke i could have told you as much: if you go that way you get a 6th degree function: 3 dimensions * cubic=2 = 6...

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.

This topic is closed to new replies.

Advertisement