Heads-I-Lose

Check-in [598ec92c32]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fix - Forgetting than list indexes start at 1 Which means I also need to wrap around the list if I get 16 segments. I.e. both 0 rads and 2*Pi rads are valid. This means I probably could have just simply added Pi (previous commit) to reverse the journey as I can just keep wrapping around. Oh well.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/master
Files: files | file ages | folders
SHA3-256: 598ec92c320398994f01864ce8e95fe627a4697dd1efd47972199bfc4315c899
User & Date: base@atomicules.co.uk 2014-12-12 12:49:38
Context
2014-12-14
21:53
Update README to suit osrm branch check-in: ee1cd9e7e0 user: base@atomicules.co.uk tags: trunk, origin/master
2014-12-12
12:49
Bug fix - Forgetting than list indexes start at 1 Which means I also need to wrap around the list if I get 16 segments. I.e. both 0 rads and 2*Pi rads are valid. This means I probably could have just simply added Pi (previous commit) to reverse the journey as I can just keep wrapping around. Oh well. check-in: 598ec92c32 user: base@atomicules.co.uk tags: trunk, origin/master
12:49
Commit in haste: Repent at leisure. Fix reverse journey Had not actually tried out my changes, or, it seems, used my brain at all in making them. - Can't simply just add Pi on, need to keep it within 2*Pi limit - Also forgot to get compass direction check-in: 3022ce9541 user: base@atomicules.co.uk tags: trunk, origin/master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headsilose.erl.

205
206
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
		end,
		Distance_headings_list).


get_compass_direction_for(Heading) ->
	%In a way this is a waste of time as could just do headwind, etc based on angles, but since already have some code, why not?
	Segment = 2*math:pi()/16,
	Segments = erlang:round(Heading/Segment),
	Compass = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"],

	lists:nth(Segments, Compass).


head_side_or_tail_wind(Direction, [Headwinds, Sidewinds, Tailwinds]) ->
	[Headwind, Sidewind, Tailwind] = lists:map(
		fun(Winds) ->
			lists:member(Direction, Winds)
		end,







|

>
|







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
		end,
		Distance_headings_list).


get_compass_direction_for(Heading) ->
	%In a way this is a waste of time as could just do headwind, etc based on angles, but since already have some code, why not?
	Segment = 2*math:pi()/16,
	Segments = erlang:round(Heading/Segment)+1,
	Compass = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"],
	%Handle the case of Segments = 16. Need to wrap around.
	nth_wrap(Segments, Compass).


head_side_or_tail_wind(Direction, [Headwinds, Sidewinds, Tailwinds]) ->
	[Headwind, Sidewind, Tailwind] = lists:map(
		fun(Winds) ->
			lists:member(Direction, Winds)
		end,