Freesteel Blog » 2012 » May
Thursday, May 31st, 2012 at 10:56 pm - Kayak Dive
Monday, May 28th, 2012 at 7:38 pm - Machining
Another interesting calculation bug, to go with the previous one, that has been in my code for decades, occurred as a result of not properly factoring down a quadratic equation.
The danger area is when such an equation approaches a perfect square, and the calculation isn’t at the margin.
A very simple example of a safe situation is the line y = m x + c intersecting a circle radius r centred on the origin, so that:
r^2 = y^2 + x^2 = (m x + c)^2 + x^2
0 = x^2 (m^2 + 1) + 2 x (m c) + (c^2 – r^2) = x^2 a + 2 x b2 + c
Solving this quadratic equation using the standard formula gives:
x = -b2 / a +- sqrt(b2^2 – a c) / a
= -m c / (m^2 + 1) +- sqrt(m^2 c^2 – (m^2 + 1) (c^2 – r^2)) / (m^2 + 1)
The value inside the square root expands to -c^2 + m^2 r^2 + r^2, and you’re going to get no solution when this is negative, corresponding to no intersection with the circle. (As a sanity check, set r = 0 and no line that is not through the origin hits it.)
The margin, when this value is 0, corresponds to a double contact point (a tangency) between the line and the circle, and it really doesn’t matter if you get it completely accurate; you’re barely intersecting the geometry at all.
In the following case I found such a use of the quadratic equation where the margin was not at all marginal, and the presence of a collision mattered.
Becka has joined us to the Liverpool Canoe Club because she wants us to make more use of these torture machines where you paddle with your ever tired arms all day and never take a break to go diving or anything more fun like that.
Apart from the threatened mono-activity, the club is completely friendly and lent us the boats to take on their weekend trip to Anglesey.
Except this is England, so it’s a bit like comparing Southport pleasure beach in the grey and windy February rain to Walt Disney World in the blazing sunshine with all its smiling people. They are in the same market. But this is home and it’s available two hours down the M6, and there are a lot of good reasons not to live in Florida.
This is just a quick log with pictures for my memory. Andrew and Ju booked a cottage on Anglesey for their May holiday and brought their kayaks. The week had classic welsh weather with wind, rain and clag, with a sprinkling of sun, but not enough to actually warm anything. We consulted magicseaweed.com daily to get the low-down on wind and waves (we wanted neither). One of the reasons that Anglesey is a top sea kayaking spot is that it is an island with four sides, so at least one of them is sheltered from the worst of the sea state on any day.
View from bedroom window on Saturday morning before setting off
Saturday 5 May
North wind. We drove to the cottage in Llanddona, dumped our stuff, then went south to Aberffraw, parked for Porth Cwyfan and dragged our boats across slippery rocks and seaweed to reach the water. This is where Becka and I had launched several times in order to dive the Kimya out from Malltraeth Sands. Today we paddled west with no tanks nearly to Rhosneigr and back.
Tuesday, May 1st, 2012 at 10:30 am - Cave
There’s a handy canoe club down at the docks about a quarter of a mile from home, which we have never yet joined. Becka booked us into an introduction to canoeing course there to get us started — somehow able to convince herself that even after 10 years of kayak diving she’s a beginner. The instructors made the fatal mistake of not asking anyone how much they already know, so after a long lecture about which end of the paddle was which it was too late to break it to them, and we had to play along. One of the tangible disadvantages is that beginner canoeists don’t get spraydecks.
Becka selected the sea kayak from the rack, because that’s what she is most familiar with. I selected the smallest fun boat I could fit into, because that’s what I am most unfamiliar with. It didn’t take her long to realize that I had got it right, and we swapped over. We should be ready for a white water river trip at this rate.