Advertisement

Determining possible arc of movement

Started by February 16, 2015 05:05 AM
4 comments, last by ferrous 9 years, 11 months ago

Hi,

I'm currently at a loss trying to determine the inner maths behind a movement pattern I'm trying to establish (top-down, 2d).

Essentially, the 'red sphere' has a speed and a maximum amount of rotation it can do every tick.

As per the graph below, lower movement speeds would result in limited rotation, whereas faster movement allows for longer arcs.

Any position in blue is valid.

[attachment=25946:ArcOfMovement.png]

Trying to dissect the problem, I'm imagined that the possibilities are determined by two circles that intersect (can be seen as the white outlines to the right and left) and that the upper arc is simply a measure of distance (a 3rd circle essentially).

I'm having a rough time trying to determine the exact coordinates/matrix of positions that would be considered valid based on a given speed and allowed angle rotation.

Anyone familiar with anything similar?

Hey, I've done this =)

If you do a search for Dubin's Curves, you'll see the math behind it all for finding valid positions. You are right, it's essentially two circles, and all movement is actually coming off of some tangent on one of the two circles. I think if you dig around a bit more you can even find the relationship between turning circle, velocity and maximum angle of rotation, though it's probably not necessary, you can keep it abstract, and I don't think players will care. (ie just make it up, with a throttle slider or set of speeds controlling the size of the circles in whatever fashion you feel like) That was pretty much my plan, with something like three speeds:

Cautious - low distance, small turn radius (maybe .1 x distance, .5 x radius)

Combat - medium distance, medium turn radius (1.0, 1.0)

Full Throttle - high distance, large turn radius (2.0 distance, 3.0 x radius)

(or however you want it, maybe per ship custom values for those speeds, or a full slider to help give a sense of momentum)

oh yeah, here was the prototype I did, with pathfinding:

http://joshv.itburns.net/RadialAttempt.html

Though for space, you probably don't need pathfinding, you can at least play with the movement.

Advertisement

Hey, I've done this =)

If you do a search for Dubin's Curves, you'll see the math behind it all for finding valid positions. You are right, it's essentially two circles, and all movement is actually coming off of some tangent on one of the two circles. I think if you dig around a bit more you can even find the relationship between turning circle, velocity and maximum angle of rotation, though it's probably not necessary, you can keep it abstract, and I don't think players will care. (ie just make it up, with a throttle slider or set of speeds controlling the size of the circles in whatever fashion you feel like) That was pretty much my plan, with something like three speeds:

Cautious - low distance, small turn radius (maybe .1 x distance, .5 x radius)

Combat - medium distance, medium turn radius (1.0, 1.0)

Full Throttle - high distance, large turn radius (2.0 distance, 3.0 x radius)

(or however you want it, maybe per ship custom values for those speeds, or a full slider to help give a sense of momentum)

oh yeah, here was the prototype I did, with pathfinding:

http://joshv.itburns.net/RadialAttempt.html

Though for space, you probably don't need pathfinding, you can at least play with the movement.

Thanks a bunch, that will give me somewhere to start!

Do you have the source code of that logic laying around? No worries, I won't copy/paste it :P

My code is ugly and needs a cleanup path, but I can point you to the resources I used:

https://gieseanw.wordpress.com/2012/10/21/a-comprehensive-step-by-step-tutorial-to-computing-dubins-paths/

http://planning.cs.uiuc.edu/node820.html#sec:geodesic

http://www.gamasutra.com/view/feature/3096/toward_more_realistic_pathfinding.php


My code is ugly and needs a cleanup path, but I can point you to the resources I used:
https://gieseanw.wordpress.com/2012/10/21/a-comprehensive-step-by-step-tutorial-to-computing-dubins-paths/

You'd be right, it is indeed Dubin's curve.

What's more frightening is that I actually ended up with the right approach with pen and paper drawing circles and triangles to figure out the relationship.

Putting it into actionable motion (working algorithm) is an entirely different challenge though!

I'm also left wondering how I want to interact with acceleration too. My original though is that, the fastest the vehicle goes, the less efficient it should be at rotating (making sharper turns) precisely because it is being dragged outwards, but I'm not sure whether I'm making this tougher than it needs to be :P


My code is ugly and needs a cleanup path, but I can point you to the resources I used:
https://gieseanw.wordpress.com/2012/10/21/a-comprehensive-step-by-step-tutorial-to-computing-dubins-paths/

You'd be right, it is indeed Dubin's curve.

What's more frightening is that I actually ended up with the right approach with pen and paper drawing circles and triangles to figure out the relationship.

Putting it into actionable motion (working algorithm) is an entirely different challenge though!

I'm also left wondering how I want to interact with acceleration too. My original though is that, the fastest the vehicle goes, the less efficient it should be at rotating (making sharper turns) precisely because it is being dragged outwards, but I'm not sure whether I'm making this tougher than it needs to be tongue.png

Yeah, you're doing 2d ships in space if I remember correctly, so go with something that feels intuitive and is easy to code. It gets difficult fast, if you are using some sort of interface similar to crimson steam pirates, where you drag the desired destination, and you were to want to the radius to change as you drag*. I think if I recall correctly what they do is look at how far you went on the previous turn, and use that as the basis for both your turn radius for the current turn and the min/max distance you can drag your ship's destination for the next turn. (Example: The unit moved 60 units last turn, so this turn it can move a minimum of 30 units, a max of 90, and it's turn radius is 16)

You could also go with a separate throttle slider, and play with how much they can move it up or down per turn. Less all in one, but more obvious as to what's going on.

(Apologies to math and physics folks, this is sort of designer-y type stuff at this point)

*Though maybe I'm just overthinking it, if you did a simple distance check first, then had that determine radius, that might work for dragging the ship's destination farther away.

EDIT: Yup, I've overthinking it, it looks like Crimson Steam Pirates just linearly increases the radius with distance dragged, with their max movement being a 90 degree turn, which I think is how they simplified the problem.

This topic is closed to new replies.

Advertisement