Wednesday, December 28, 2011

Austin Yacht Club - Beer Can Race - Which Way To Go



Overview

At the Austin Yacht Club, each summer there is a unofficial race each Friday evening called the Beer Can Race.  It involves:

  • Start and Finish same place
    • Use bouys at entrance to AYC
    • Imaginary line between 
  • Race around 3 marks in Lake Travis, TX 
    • The marks are B, E, and K  
    • In any direction as long as all the marks are rounded.
  • The boats start at handicapped times
    • Slower boats go first
    • Faster boats follow w/ handicap
  • The 1st & 2nd Place winners 
    • Get a bottle of wine!
    • Add 30 seconds handicap next race
The idea, with the handicap, is that if everyone sailed perfectly, we'd all finish at the same time.

AYC Beer Can Racer


You can view the AYC Beer Can Racer web app here: http://acft.ws/bddq

The AYC Beer Can Racer app shown above determines the fastest route around the required marks using the wind direction and speed provided.

Background
This summer I was sailing a beer can race with Ray Shull and as we approached the starting line I wondered which direction he would take.  Ray asked me to reach into the cabin and get a chart for him.  He looked at the wind direction and then the chart and said "We going to E!".  "Wow" I said, "could I have a copy of that chart?"  He laughed and said something to the effect that I should figure it out for myself - "it would do you good!"

I had no idea how to pursue this.  I wondered what was involved in the calculations. I'd been out of college for more then 30 years and hadn't used much math since.  I couldn't remember the difference between a tangent and a cosine.

So I started researching.  The first interesting web site was our own AYC.  There I found two things that would helped me.

Marks


First, I found the map of AYC Racing Marks http://www.austinyachtclub.org/racing_info/marks  When I viewed the source I found the latitude and longitude of the marks I needed, namely E, K and B.

Next, also from the AYC site, the weather page http://www.austinyachtclub.org/WX/details.htm where I find the current wind direction and speed.  Of course it would be possible to write a mobile app that supported getting the current wind direction and speed using the capabilities of the phone but I didn't want to have to support all the different smart phones.  I thought if I could plot the current best route given the speed and direction of the wind, that would be a good start.

Distance
Now that I had the latitude and longitude of the beer can marks, I needed to know two more things about the marks, the distance between them and the bearing between them all.  I found this web site that provided that solution: http://www.movable-type.co.uk/scripts/latlong.html I just plugged in my lats/longs and viola - I got the distance and bearing.
Distance between two points

This is where I got lost.  I didn't quite understand, given all the information I had, what to do next.  Could I use trig and figure the angles the boat would travel and guess at the speed? Should I assume constant speed in all wind directions? Surely I would go different speeds - but how should I guess-estimate that? What should I do about tacking, about land, low water, shifty winds, etc.

Luckily I found something that helped a lot.  I found polar data for a Ranger 23 here http://www.arvelgentry.com/r23/r23_polars.pdf.  I don't know anything about a Ranger 23 but it seemed about the right size boat for my purpose.  And it gave me some data to work with - namely the boat speed at different True Wind Angles (TWA) for a given wind speed.

Ranger 23 Polars


Web app
So now I had all the data I needed.  I was able to write a very simple web app that works on either Chrome, Safari or Opera desktop browsers. It also works on IPhone because it uses the Safari browser and the Android also.  I'm not sure about the other desktop or mobile browsers.

The following is a screen shot from my Android:


Pages
There are three pages for the app.

The first page is a Google map that uses the wind speed/direction from the AYC weather page and plots the fastest route.  You can change the speed and direction.

There's also a button on the bottom ("Data") that takes you to a page which is a summary of all the speeds / wind direction and best routes.

Summary of all Wind Directions and Speed


There are two buttons on this page, one which is to a line graph for all the wind directions at a specific wind speed.  Note that S is the Start/Finish point.
Chart of all wind directions for specific speed

The "Map" button returns you to the map.

Calculating the time for each Route


I ignore changing land obstacles due to changes in level of water.  I try to guess the route from Start / Finish to / from B & K.   As you can see from the map plotting, I show the angles used to clear land obstacles when going in these directions.  I assume constant wind.  I  tack when heading are less then 45 degrees.  If the TWA is less then 45, I fall off to 45 and then using trig figure out the two legs of the triangle.  Though the Range 23 can sail windward at less then 45 degrees, for my solution, I ignored those angles as the boats I've sailed can't point that high.

All the routes plotted are based on time - what is the fastest route?  The fastest route is determined by looking at the possible paths for each route.  The time to sail each path is calculated by dividing the distance by the boat speed.  The boat speed is obtained from the polar tables using the TWA for the wind direction/speed.

Example calculation

Let's assume we have a  SSE wind with 8 knots.  There are numerous routes that have to be calculated (KEB, BEK, KBE, BKE, EKB, and EBK).

Each of these routes are made up of smaller paths.  Let's consider the BEK route.  The paths that make up this route are


  1. S to A (the tack point away from land)
  2. A to B
  3. B to E 
  4. E to K
  5. K to Z (the tack point away from land)
  6. Z to S (back to the start/finish line)


For demonstration, I'm going to look at three paths of the BEK, namely:


  1. S to A
  2. A to B
  3. B to E


Now "A" and "Z"  are pseudo marks that represents a point that extends far enough into the harbor that when rounded avoids the shore line.  The sailboat has to extend past this point before tacking to mark B.

S to A



The drawing above, S to A, shows the wind direction coming from SSE which is 157.  The sailboat is going in the direction of S (the Start) to A (the point past the land obstacle).  The bearing is 61.  The right and left values are the angles that are perpendicular to the bearing.  This helps to determine if the wind direction is behind, as in this case, or in front, ie a head wind.
Polar 105

In this case the true wind angle, TWA,  is 96.  Using the Rangers polar data, we use the polar for the next available TWA which is 105.  Looking up the chart, the speed is determined to be 5.665.  Since the distance is 0.3373, then the time to travel from S to A is 0.059 (Time = Distance divided by Speed (T = D/S)).

A to B

A to B
In the diagram above, A to B, the wind direction is behind the sailboat and the TWA is 166.  




Again, from the above table, the polar twa is 165 and the speed is 3.792.  The time to travel from A to B is 0.441.

B to E

This next path shows how the sailboat must tack to make the mark.  
B to E - Step 1
In going from B to E, the TW is 27.  The sailboat can't sail directly into the wind, it has to "fall off".  Falling off means changing the direction of the sailboat so that there is a larger TWA.  In this case, if the sailboat changes its bearing so as to increase the angle to the wind, the first possible position would be an TWA of 44 since that's the smallest angle this sailboat's polars provide (note I'm ignoring the 36 wind angle as most boats can't point that high).

In the diagram above, the sailboat takes a new bearing which is a polar TWA of 44 degrees.  So what needs to be done now is calculate the length of the New Bearing and the leg from the Tack to mark E.

Using trigonometry, the distance of the New Bearing to the Tack location and the distance from the Tack location to mark E can be calculated.

Note that a Tack makes a 90 degree turn.  Therefore we have a right triangle with the hypotenuse being the original Bearing.

Let's call the Bearing "c".  Using the Pythagorean theorem, a^2 + b^2 = c^2\!\,.

So what is the length of a, the new bearing?  Remembering trig, a = sin(a) * c.   

A is the polar of 44 minus 27 which is 17.  First though we have to convert degrees to radians and the formula is:
 sin(27 * (PI / 180) which gives us 0.276485.

Substituting the values of a and c, using a = sin(a) * c, the distance of the Tack (a) is 0.7047.

Now using Pythagorean, and knowing c & a, we can calculate b:

b = square root (c squared - a squared) =  2.44963.

So now we have our total distance for this New Bearning (b) and Tack (a):
b + a = 0.7047 + 2.44963 = 3.15433

Using the polar data for 44 TWA, see below,


We have the time for this path of B to E:

Time = distance / speed

Time = (a + b) / 4.729;

Time = 3.15433 / 4.729

Time = 0.667

Summary

So continue as above for all the paths that make up BEK route and summing their times, the route takes 1.811 hours to complete.

This process has to be done for all the possible routes and the route with the least amount of time is what is desired.


Web 2.0 Development For the Single Java Developer

Overview

Have you searched for an application development tool that is open source, java, and based on web 2.0 standards? Has all the technology features and requirements of integrating multiple products into a cohesive development tool suite made the technological decision more difficult then it needs to be?
I recently decided to start my own business after years of working for companies like IBM & Dell. As an independent consultant, I needed a software development tool that could maximize my productivity and utilize my experience.
This article outlines my technical requirements and decision-making process.
Requirements for a Web 2.0 Development Tool
Some of the features of a web 2.0 development tool might be: easy and rich interactions with external services via web services, rich and easy to use UI widgets, a web-based development solution that runs in the major browsers (zero install footprint), seamless integration between the client and server, usage of standard debugging tools (ie FireBug and Eclipse), based on standard Java technologies such as Spring, JaxWS, Acegi and Hibernate.
In order to be productive as a single java developer team I would like to be sheltered from all the low level setup and integration of the various technologies. I would like to have an application development environment that combines the best of breed web 2.0 development technologies into one development environment tool that helps me be productive while delivering cutting edge solutions.
A few features I personally require:
  • Web 2.0 UI: The developers tool is written with the tool
  • Rich UI Widgets: UI widgets like Dojo for a Rich Internet Application (RIA)
  • Web Browser Runtime: zero install footprint with no proprietary plugin
  • Security System based on Spring Acegi: proven and robust security solution
  • Seamless database integration: easy to build web forms for CRUD operation of the database schema
  • Java support: full support of Java programming on the server: - I don't want to have to learn YAL (Yet Another Language)
  • Ease of deployment: support open source severs like Tomcat and JBoss
  • Open Source: active community with source code readily available - a solution whose design is based on established standards
Selecting an Easy to Use Web 2.0 Development Tool
Since I want to write a web-based application that may be inter or intranet website or both, I would like the developer application to be built with the same technology that I will use. This is why I want the development tool to be web-based. For the UI, the very UI tools that are used in the final deployable web-based application should be the same components used in the developers tool. If the final end product I develop utilizes Dojo widgets then my developer tool should use those same Dojo widgets. I think some call that "eating your own dog food"!
I did some personal research into what javascript client library would be the best for me to learn. I decided that it would be Dojo for various reasons one of which was I really liked the way it looked! But when I was learning Dojo, I was a little overwhelmed with how much there was to learn and all the moving parts. With the incorporation of Dojo into the development tool that learning curve could be reduced tremendously and I like that idea.
I would like a drag and drop development tool that runs in a browser that hides the complexity of working with Javascript toolkits like Dojo. I also want it to make setting up security such as snap that it's hard to believe you're running on top of something like Spring Acegi.
If you've ever setup Spring Security with Acegi you know how difficult it can be. I think that Spring Acegi rocks and would like to have a development tool that supports it seamlessly. By that I mean having Acegi integrated into the developer tool and requiring from the developer a few definitions such as which table has the user id and password to enable security.
Database access can be the hardest part. The integration of the database schema should be evident when building UI components - the components should understand the keys (both primary and foreign), the data types, how to present to the UI and how to scroll and such. I should be able to create a functional sophisticated CRUD (Create Read Update Delete) pattern UI in minutes with no coding!
The deployment of the application should be a single mouse click - the requested war or ear should be generated and placed in a specific directory for easy retrieval. There should be no maintenance of ANT or Maven build scripts. My web-based deployable artifact should be generated quickly and be deployed it to any of the popular web servers: Tomcat, JBoss, GlassFish, WebLogic and WebSphere.
If you are a single java developer looking at web 2.0 development consider these items as you kick the tires on the various solutions available.
Barton Hammond
Austin, TX
After defining my requirements, I set out to find a tool that could meet my needs. I rapidly weeded out solutions that were proprietary (e.g., Adobe Flex), not based on Java (e.g., Ruby on Rails), or lacking a visual UI builder (e.g., Spring Roo).
Through this process I ran across an open source product called WaveMaker. After downloading the product and working with it for several weeks, I felt it provided a good fit with my requirements. I was also impressed with the friendly open source developer community for WaveMaker.
The tool I found that meets my requirements is http://wavemaker.com.
If you are a single Java developers who are looking to optimize productivity while harnessing web 2.0 and open source, you should consider looking at WaveMaker. The easy things are extremely easy and the difficult things are not so difficult.