December 21, 2005

1st hack at a polar

As folks who check this website know, I've been collecting a lot of data on a GPS during Wednesday night races.
I've finally gotten around to attempting to make a polar chart for Surprise, but it's been harder than I initially thought it would be.
I'm not satisifed with it yet and I have no doubt it in not very accurate, but I'll post it here, anyway.
042805.gif

I used Matlab to process the data, and generate the polar plot. I had hoped I could get a least-squares fit to something like a cardiod, but there were no built in functions to do that. When I tried to do it myself, I had some strange problems.

A cardioid is a polar function in the form r(theta)=a * cos(theta + phi) + 1. theta is the angle, representing the wind angle, and r is the distance from the center, representing the speed of the boat. It's shaped a little bit like a heart, hence the name.

Part of the process is to take partial derivatives of the square of the error function, in this case it is: [a*cos(theta+phi)=r(theta)]^2
with respect to the parameters, in this case, a and phi. What this does is to find values for the parameters that minimize the error between the data and the assumed function. Of course, knowing the correct function is important. and I'm just guessing.

For some reason the partial derivative of this error equation with respect to a is equal to its partial derivative with respect to phi, so instead of having two equations to use, I had one. That causes me some trouble, and I'm curious why this is the case. I'm wondering if I am doing something wrong, but I have checked my texts, and don't see an error at this time.

This problem is not the only one I've encountered. The equation is also nonlinear and that has made it made it too difficult for me to find an answer so far. I was going to find a way to do a nonlinear least-squares fit. There's a lot of information on it out there, but I have yet to finish that research.

Another thing I've realized is I took no data above a beat. The least squares curve fit assumes some non zero value ought to be there. Some time I will need to spend some time luffing and gathering data on that part of the curve.

I'm hesitant to add data from other days to this one, since the conditions can vary. I might be able to do it after I rotate the data to find a mean wind direction, which is proving harder to do that I thought. If the least squares fit would work, I'd have an angle (phi), which I could subtract out of the data. It seems to be a chicken and egg thing or a catch-22, or something like that.

I'm also considering doing some sort of piece-wise analysis, that is, take the data from beam-reach to windward and fit a curve to that and then so the same for the other quadrants, or something along those lines. Anyway, It's an interesting mental exercise, hopefuly I can come up with something useful sometime.

What I did here was to use a 7th order polynomial. I originally plotted it on a cartesian graph, and then replotted it on the polar.

Another thing I found was that the function doesn't meet up at the 360 degree point. I might consider using some sort of spline function. But I'm very hazy on that so I have more learning to do. It's really kind of fun, I can see why guys like Newton loved this stuff, but I would have had a hard time without tools like computers.

Posted by Bob at December 21, 2005 03:05 PM