Finding a point on trajectory in which we should change move vector

Started by
3 comments, last by Irlan Robson 7 years, 2 months ago

Hello guys, I need some advice with this tricky task.

We have some wall (red line on the image). Our round object is moving along this wall by move direction vector on some distance R from the wall.

The problem is to find a point where we should change object move direction vector (blue dot with arrow). We don't have any information about angle of intersection, but we can do raycast at some point to find normal and point of intersection with ray.

Any help will be appreciated :)

w2MF5j-VRqc.jpg

Advertisement

I think I've got a hint for you:
qu4NAiY.png

If you can find the orange line segment, you are 99% done. Just find the orange line segment, normalize it, scale it by R, then translate it so that one endpoint is on the intersection point between your two wall line segments. This will give you the position of the blue dot.

Finding the orange line segment should be pretty easy as well: If you look at the two wall line segments, you can kind of tell that they form an angle between them. The orange line segment divides that angle exactly in half. You should be able to figure out all the rest from here :)

Well, looks like you've answered your question already.

Shift the collision plane by R along the plane normal and derive the contact point from the minimum time of impact via ray-cast.

You can also implement a iterative local plane solver. Note that for accute angles (not your case) you might need a large number of iteration to converge. I never implemented this algorithm, but it was covered at the end of this talk:

http://box2d.org/files/GDC2014/GDC2014_ErinCatto.zip

Just find the orange line segment, normalize it, scale it by R, then translate it so that one endpoint is on the intersection point between your two wall line segments. This will give you the position of the blue dot.

Yeah, It will be pretty easy task then. The main problem that I don't know intersection point, I even don't know if I actually have it :)

As you can understand, I'm trying to implement cover movement mechanics. I don't know which shape it has, I have only normal to surface and movement direction. All I can do is raycast at some point and say "Raycast returned a normal to surface that is equals to my current, move further" or "Raycast returned a normal to surface that differs from my current, I need to consider rotation at some point". So I need somehow to find this point based only from data I can get from raycasting.

Well, looks like you've answered your question already.

Shift the collision plane by R along the plane normal and derive the contact point from the minimum time of impact via ray-cast.

Well I think I have no opportunity to move my collision shapes, actually it is even not a plane, this is a some shape (see the picture below)

kgGVJJ50AqY.jpg

So maybe you can advice me some other method of achieving my goals that would be applicable in my case? It can be not 100% precise but good enough to use it in runtime. Thanks a lot :)

Oh, I see. The solution is obviously shape representation dependent. In 2D, a convex polygon is typically represented by a set of vertices and intersecting planes. Hence, one option, hypotetically, is inflate the planes by the sphere radius at initialization time.

Alternatively, I would extend the ray vs. static polygon test to dynamic sphere vs. static polygon test. I haven't tried this yet, but here is an example:

A ray:

p = p1 + t * s

A plane taking a radius r into account:

dot(n, p) = d +/- r

Solve for t:

dot(n, p1) + t * dot(n, s) = d +/- r

t = ( +/- r - ( dot(n, p1) - d ) ) / dot(n, s)

I would use Real Time Collision Detection, page 219-220, as a reference.

Since the ray is paralell to the left wall the ray cast will have failed leaving the intersection point on the right wall as the solution to this simple problem.

Hope that helps.

This topic is closed to new replies.

Advertisement