Archive

Archive for the ‘Uncategorized’ Category

How to calculate the average angle of bearings

August 26th, 2010 Ed No comments

This is going to be a tediously dull post, but given the amount of faffing I did, I don’t want to forget it!

Firstly, this is mostly not my maths – this is thanks to @helenbowyer, @bluerhinos and a parent of a scout who saw a link to my site on @rmappleby’s blog and then saw my tweet asking for help!

The problem is what happens when you cross the 0/360 boundary – how to average 5 degrees and 355 degrees to get 0 degrees. A “mean” would give 180 degrees – oops!

The answer is trigonometry, treating the angles as vectors.

First get the SIN of the angle, and divide by the COS of it. Then take the “ATAN2″ of it to get the final result. Tada!

For my application, I am putting the last 40 values into an ArrayList and calculating a weighted average (in Utilities.weightedAverage()) – you can replace this with any averaging function. Here’s the Java:

sinTotals.add(Math.sin(angleInRadians));
cosTotals.add(Math.cos(angleInRadians));

if (sinTotals.size() > 40) {
	sinTotals.remove(0);
	cosTotals.remove(0);
}
double sinAverage = Utilities.weightedAverage(sinTotals);
double cosAverage = Utilities.weightedAverage(cosTotals);

double direction =
     (Math.toDegrees(Math.atan2(sinAverage, cosAverage)) + 360) % 360;
Categories: Uncategorized Tags:

Developing RSA plugins using Eclipse

May 14th, 2010 Ed No comments

If you’re developing plugins for RSA, you’ll probably have one RSA open and a runtime RSA, both eating huge amounts of memory. To reduce the memory footprint, I’m using Eclipse to develop, but still launching a runtime RSA.

To do this, install RSA and eclipse (separately), then in your eclipse:

Install the JRE:
1. Windows > Preferences > Java > Installed JREs
2. Add c:\Program Files\IBM\SDP\jdk\jre
3. Tick its tick-box

Set the Target Platform:
1. Windows > Preferences > Plugin-in Development > Target Platform
2. Browse for c:\Program Files\IBM\SDP
3. Tick “Build target platform based on the target’s installed plugins”
4. Click “Reload”

Running as RSA
1. Run > Run Configurations
2. Change the Run as product to: com.ibm.rational.rsa4ws.product.v75.ide (or equivalent)

Tada! I’ve found I get far less out of memory errors and things are generally quicker.

Categories: Uncategorized Tags: , ,

Wild Camping and Night Photography by Torchlight

April 25th, 2010 Ed 2 comments

On the 17th April I set off to the Black Mountains for a weekend solo hike, wild-camping overnight, to gain more experience for the “Scout Terrain 1 Assessment” and “Walking Group Leader Assessment”.

Day 1 was a 25km route (horizontally), scarily that doesn’t include 1.1km ascent and 800m descent – very knackering, but I did rescue a stray dog on route!

After eating my home-made boil in the bags and waiting for it to get dark enough, I put my camera on my jumper on a rock (there was no way I was going to carry a 3kg tripod around the place), and these were the (edited) results:

For those that care, the waterfall image was taken first, with an exposure of 30s at F9, ISO 100.

The tree was taken 20mins later after much experimenting, with an exposure of 4 minutes, F9, ISO 100. This meant there was long enough for the stars to streak across the sky. I felt this distracted from the photo, so removed them – you can see them in the original out-of-the-camera image on the right (there were even more of them after tweaking the brightness levels, but you get the idea). I didn’t have the patience to enable the noise reduction function on the camera – the one where it takes the photo, then takes another photo of black for the same length of time – in hindsight, I wish I had, but hey!

Both images involved painting the area that I wanted to show up with a super-bright LED head-torch. With the waterfall image, I set the exposure to 30s, and quickly walked above the waterfall to light the area around the top, then quickly came back to light the actual waterfall. The tree shot meant using a (tempermental) shutter-release cable (£6 from ebay, so can’t expect much more), and sitting behind the camera moving the torch evenly over the tree.

So that was fun. I went to bed and woke up in the morning feeling sunburnt and knackered. Day 2’s route was a mere 16km, this time descending a total of 820m and ascending 435m.

Really can’t complain waking up here: