HA!!
Done it I think.
For some reason my equation to get the angle via inverse sin had the values dividing the wrong way – I was dividing the base length by the hypotenuse or the other way round – which meant that I was coming out with a value greater than 1 which, it appears, an inverse sine can’t do (I have no idea how this works btw).
I swapped them round and came to a result which worked and then had to take that value away from 90 degrees so that it was rotating in the direction I needed.
Works perfectly now…
//I have two slide values that control the Base length and the height of the triangle (the altitude)
//half the base length to get me a value that creates a right angle triangle essentially
m = thisComp.layer("DRIVER_all_sides").effect("length - X")("Slider")/2;
//pythagorus to find the length of the hypotenuse
a = thisComp.layer("DRIVER_all_sides").effect("length - X")("Slider")/2;
b = thisComp.layer("DRIVER_all_sides").effect("HEIGHT_TRIANGLE")("Slider");
x = Math.sqrt(((a*a) + (b*b)));
//get the angle via inverse sin
q = Math.asin(m/x);
//convert this to degrees
p = (radiansToDegrees(q));
//final result needs offsetting so it rotates the correct way when I change the base triangle value
90-p