
function to_cardinal_2d(a, d) = [
	d * sin(a),
	d * cos(a)
];
function move_polar_2d(p, angle, dist) = to_cardinal_2d(angle, dist) + p;
function line_len_2d(p) = sqrt(p[0]*p[0] + p[1]*p[1]);
function line_len_3d(p) = sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2]);
function angle_2d(p) = atan2(p[0], p[1]);

function _tangent_single_angle_2d(to, r, other_side) =  angle_2d(to) + ((other_side) ? -1 : 1)*acos(r / line_len_2d(to));
function tangent_single_2d(to, r, center, other_side=false) = 
	move_polar_2d(center, _tangent_single_angle_2d(to - center, r, other_side), r);

