Heads-I-Lose

Check-in [5c494abd30]
Login

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

Overview
Comment:Do head | tail properly

Wasn't thinking straight when I first wrote that, obviously

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/master
Files: files | file ages | folders
SHA3-256: 5c494abd30c131f2e926ced19d81089fd8e090fb824c2819ce942370e9004de4
User & Date: base@atomicules.co.uk 2014-11-28 21:03:09
Context
2014-11-28
21:29
Make use of atan2 unsigned

Hadn't realised it returns negative numbers. check-in: 0fe524de48 user: base@atomicules.co.uk tags: trunk, origin/master

21:03
Do head | tail properly

Wasn't thinking straight when I first wrote that, obviously check-in: 5c494abd30 user: base@atomicules.co.uk tags: trunk, origin/master

20:12
WIP - 1st attempt at bringing together polyline and OSRM functionality

Compiles, but doesn't yet run.

The general principle is that it will get a previously saved polyline
and convert this into a list of compass headings and distances. It will
then sum up the distances of head, side and tail winds to see which
wins.

For the time being I'm focusing on summing up headwinds only.

Adds the following functions:

- build_list_of_wind_directions

Previously this didn't exist as a standalone function, rather it was
built into the main headsilose routine. Before it was fed with a
direction of travel and based on this it would work out which 16 point
compass headings were head, side or tail winds. Now it needs to work a
bit in reverse (although I haven't made the necessary changes yet - I
don't think1) and instead feed it with the actual wind direction and
it will use this to build the list of head, side and tail winds.

- get_compass_direction_for

Convert an angle into a 16-point compass direction

- head_side_or_tail_wind

Decided whether, for a given direction of heading, it is a head, side
or tailwind. Uses the lists from build_list_of_wind_directions.
check-in: 3a98087e88 user: base@atomicules.co.uk tags: trunk, origin/master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headsilose.erl.

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
		lists:map(fun(X) ->
			nth_wrap(Index+X, Compass) end,
			WindList)
		end,
		[HeadwindList, SidewindList, TailwindList]).


convert_lats_longs_to_distance_heading([_, _, Rest])  -> 
	%All co-ords are diff, so just ignore first two
	convert_lats_longs_to_distance_heading_(Rest, []).
convert_lats_longs_to_distance_heading_([Lat, Lon, Rest], List_distance_headings) ->
	%Want to map through the list convert co-ords to distance and heading
	Distance = math:sqrt(math:pow(Lat,2) + math:pow(Lon,2)),
	Heading = math:atan2(Lon, Lat),
	Compass_direction = get_compass_direction_for(Heading),
	convert_lats_longs_to_distance_heading_(Rest, [{Distance, Compass_direction}]++List_distance_headings);
convert_lats_longs_to_distance_heading_([], List_distance_headings) ->
	lists:reverse(List_distance_headings).







|


|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
		lists:map(fun(X) ->
			nth_wrap(Index+X, Compass) end,
			WindList)
		end,
		[HeadwindList, SidewindList, TailwindList]).


convert_lats_longs_to_distance_heading([_Head1 | [ _Head2 | Rest]])  -> 
	%All co-ords are diff, so just ignore first two
	convert_lats_longs_to_distance_heading_(Rest, []).
convert_lats_longs_to_distance_heading_([Lat | [Lon | Rest]], List_distance_headings) ->
	%Want to map through the list convert co-ords to distance and heading
	Distance = math:sqrt(math:pow(Lat,2) + math:pow(Lon,2)),
	Heading = math:atan2(Lon, Lat),
	Compass_direction = get_compass_direction_for(Heading),
	convert_lats_longs_to_distance_heading_(Rest, [{Distance, Compass_direction}]++List_distance_headings);
convert_lats_longs_to_distance_heading_([], List_distance_headings) ->
	lists:reverse(List_distance_headings).