[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Assumption help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 10
Thread images: 1

File: river.jpg (63KB, 481x459px) Image search: [Google]
river.jpg
63KB, 481x459px
So for homework I got the map (see picture) between column 8 and 9 lies a river, and a bridge located at 8,3 and 8,10. So if I wanted to get from 1,1 to 16,16 for example I need to find the distance to a bridge, and then from the bridge to the other point. Because I need to program this, I want to try and make a general assumption regarding which bridge to choose. Or am I better off calculating the distances to and from each bridge and testing which one has the shortest distance?
>>
>>79145
Are you using Euclidian or Manhattan geometry?

Because with the latter, as long as you're not actually doubling back, which bridge you use makes no difference.
>>
>>79157
We have to use Euclidian.

>>79153
I also though of something similar, but I saw some special cases where it could be invalid. Also I do not understand what you mean with i and j, as there are 4 variables being used, (x1,x2,y1,y2)
>>
Right now I am going to use
if A and B to the left OR A and B to the right
result = distance
else
result = 1 + min(A to bridge1 + bridge1 to B, A to bridge2 + bridge2 to B)
>>
>>79176
Unless I can make a simpler assumption about it. As this is only part of the homework and the specific function will be used millions of times for the follow up questions, I would like to keep unnecesary calculations to a minimum.
>>
>>79173
You've only got two bridges to consider, so just square the offsets from the origin to each bridge, and from each bridge to the destination, and take the lower sum.

Bonus points for checking if you have to cross a bridge at all.

>So if I wanted to get from 1,1 to 16,16
b1 (8,3): x1 = 8-1, x2=16-8. y1=3-1, y2=16-3
b1 (8,3): x1 = 7, x2=8. y1=2, y2=15
b1 (8,3): meansquare = 342

b2 (8,10): x1 = 8-1, x2=16-8. y1=10-1, y2=16-10
b2 (8,10): x1 = 7, x2=8. y1=9, y2=6
b2 (8,10): meansquare = 213

So in this case, you go with b2. Note that you've not had to do any division, just multiplication (or addition).

You can actually ignore the x components entirely, so long as the bridges all have the same x coordinate.
>>
>>79157
He needs a general rule, so it happens that he needs to go back if he choses a wrong bridge.

But in either case the answer is simple: Look at the line where the distance to both bridges is equal. This line divides the area into two parts. For all points in one region one bridge is closer than the other.

In your example, it is the line between the squares with y=6 and y=7. So if y <= 6 you pick the upper bridge, if y >= 7 you pick the lower bridge.

In general the area is subdivided into so called Voronoi cells depending on the distance to given seeds.

https://en.wikipedia.org/wiki/Voronoi_diagram

Note that in the Manhattan metric the cells are delimited by horizontal lines, vertical lines, and lines at 45° angle. In your example the metric doesn't matter since the two bridges define the same cells in both metrics.
>>
Ok so you want to go to 16,16
Use this pretty simple formula (16/2)*83+x (here x=2)
You will find a equilateral triangle
>>
>>79185
Call me Mr. Thick, but if you're at 4,5 and you want to go to 11,10, going to the upper bridge because 5 is less than 6 doesn't seem the optimal route.
>>
>>79213
Yeah, because I only checked the distance from the starting position to the bridge, not the distance from the starting position to the end point, sorry.

I think it's probably easier to go with >>79176 or better >>79181 since the squares calculated can be used in the computation of the distance.
Thread posts: 10
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.