This paper presents a new, computer-implementable algorithm for determining Bell inequalities. The algorithm is very general: one can use it to derive the Bell inequalities for any of the experiments that are usually considered for this purpose, such as the Bohm-Bell experiment, the Clauser-Horne experiment, or the experiments with spin 1, 3/2, 2 and 5/2 particles proposed by Mermin, Schwarz and Garg. As an example, this paper applies the algorithm to the Clauser-Horne experiment. The algorithm, which is based on simple notions from n-dimensional Euclidean geometry, gives a simple geometrical interpretation to the Bell inequalities. The algorithm allows one to demonstrate that a set of Bell inequalities is complete. The algorithm uses special hidden variables that were first used by Wigner and Belinfante. This paper also shows how to use finite group theory to express a set of Bell inequalities in a form that makes its invariance under relabellings explicit.