Jump to content
Sign in to follow this  
igneous01

Trigonometry - Create equidistant markers along all roads in a circular area

Recommended Posts

So this is my fantastic problem:

I want to acquire an array of positions along a road where I can spawn some units/buildings. Right now im using markers to more visually see where these positions will be, and Im stuck.

Im out of ideas on any formula or methods for doing this - I can make it work on the first marker (check to see if the distance is between 200~250 of original marker) however all other markers still follow this distance constraint (which needs to check for distance ~400 and ~200, right?)

So here is a picture of what I have managed to do with my script:

where it is now:

2011082500001.th.jpg

and what I want it to do

2011082500002.th.jpg

so far I have managed to calculate the most outer bound road segment from the point of origin (the area where spawning takes place), and the segment most closest to the point of origin. But How do I check for all possible road ways (as there are multiple intersections) and create markers that are equidistant between each other (distA == B && distA == C).

Ive tried For loop nested inside a foreach (for loop using road selection, and this being checked against a foreach loop making sure its within distance of all other points in array) but this doesnt work because its checking against all points.

So, any math guru's around here that can provide some theory or formula to getting this to work?

Share this post


Link to post
Share on other sites

I had a look at this but nearRoads does not seem to be too reliable. 9 out of 10 times it's not returning road segments that are close to the points that I'm generating. So..that sort of shut me down right away.

Share this post


Link to post
Share on other sites

I'm using isOnRoad for something similar. It works very reliably.

ez41Q.jpg

Share this post


Link to post
Share on other sites

I'm calculating the points radially every 1 degree and stepping out a 100m at a time.... so a point may not necessarily be on the road but most likely will end up near a road.

Might have a re-think about the calcs and using isOnRoad.

Cheers for that.

Share this post


Link to post
Share on other sites

I do similar. I'm creating clutter objects near roads and putting IEDs in some of them.

Take an isOnRoad position, choose a random direction, move in 7 metre steps until we're !isOnRoad, create a clutter object like a dead dog or pile of tyres, stick an IED object under that and a cunningly crafted trigger (thanks Sickboy, Sekra, Soul and wld) on that.

Boom. :D

Share this post


Link to post
Share on other sites

What about: roadsConnectedTo

You start at some road, go the next and check which roads that is connected to. You check which you road you came from and then you go to the next. During the checks you check the distance covered and put a marker if necessary or whatever.

If a there is more than 2 roads connected to a road then you have an intersection and you remember the intersection and finishes the current. When that's done you go back and start from the other road of the intersection.

Share this post


Link to post
Share on other sites
What about: roadsConnectedTo

You start at some road, go the next and check which roads that is connected to...

If the OP is interested in this solution, I've already written something like this (RUBE_findRoute & RUBE_plotRoute), included in my RUBE library (see at bottom; oh and there are some demo mission over at CIT)

You may run RUBE_findRoute with a starting and ending position/road-object, which returns you a list of all road-objects on that route. Then you could iterate over that list of road-objects, while placing down whatever you feel like - say, every third road-object or something...

Share this post


Link to post
Share on other sites
If the OP is interested in this solution, I've already written something like this (RUBE_findRoute & RUBE_plotRoute), included in my RUBE library (see at bottom; oh and there are some demo mission over at CIT)

You may run RUBE_findRoute with a starting and ending position/road-object, which returns you a list of all road-objects on that route. Then you could iterate over that list of road-objects, while placing down whatever you feel like - say, every third road-object or something...

thank you Ruebe, i will have a look at that as Im running short of ideas on getting road segments evenly spaced.

My idea now was to draw an imaginary line between two final road segments (the two roads that are furthest from the center, and are furthest away from each other) and divide this by a spacing, then check the nearest segments that are closest to these points, and attach them to the road.

I will do some more experiment, thanks for the responses

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×