There is another solution if the trig does your head in, and that is to use affine transforms. Then you could use:-
Code:
line(0, 0, length, 0);
translate(length, 0);
then do a rotate, and carry on in the same vein (you will have to learn about pushing and popping the matrix though, to create a branching tree).
As for drawing trees, it is a classic for using lsystems (as you may not want entirely random angles, as many of the random angles will produce an unsatisfying result).

Update Sunday 18th April, I went a bit mad exploring the drawing of trees in processing (albeit using ruby-processing, but it is quite easy to translate) see my posting on the processing implementation discourse
http://processing.org/discourse/yabb2/num_1271596814.htmlOn my blog I have got simpler examples honest which do not involve the use of the context free DSL (
results nowhere near as impressive though).