I am trying to do a constrained least-squares minimization on a toroidal surface with Euclidean distance. This is the equivalent of saying that I have torus with n dimensions, with side length d_i for each dimension i of these n dimensions and inside the torus I define a hyperplane through a number of equations of the form x_a_1 + x_a_2 + ... + x_a_k-1 - x_a_k = 0, where a_1 to a_k are indices for the dimensions involved in this equation and x_1 ... x_n are the usual coordinates in the n dimensions. The simplest example would be a 2-dimensional torus, with side lengths 1 and 1. If we consider the plane defined by the equation x_1 - x_2 = 0 and the point of coordinates .9 and .1, then the nearest point on the plane is (0,0), with Euclidean distance .1*sqrt(2).
Question: How hard is this problem in the general case? Is there a way of doing the projections using modulo algebra, or must one expand the torus into a lattice and consider the different ways of writing the hyperplane equations (for example, in the previous example, after expanding the line should be written as x_1 - x_2 = 1 to get the smallest projection vector).