A vector in the plane is an arrow that points from the origin to some other point (x,y).
it can be written as a "sum" of two simpler vectors, simpler because they are either horizontal or vertical. to find the terms in this sum, we ask of our vector (x,y) how much it points in the hporizontal direction, [answer (x,0)], and how much of it points in the vertical direction, [answer (0,y)].
one way to tell that a vector such as (0,6) does not point at all in the hporizontal direction is to note that it is perpendicular to the standard horizontal vector (1,0).
since dot products measure perpendicularity, they help decompose a vector into horizontal and vertical parts.
To say (0,6) is perpendicular to (1,0), means that as functions with only two values, they take on their values on different points in the domain. i.e. (0,6) is "supported" only on the second entry while (1,0) is supported on the first entry. so when we multiply their values: 0.1 + 6.0, we just get zero.
we also get zero when their values on these points cancel each other out, as in (2,1) and (-1,2), so the dot product is 2(-1) +(1(2).
to tell whether a function f is supported on the same or opposite points of its domain from another standard function like sin(nx) we also multiply them f(x)sin(nx), and then see how big this product is by integrating it.
for instance if f is large where sinj(nx) is small the integral should be small, and also if the values of f cancel out those of sin(nx).
Since vectors are just functions which have only two domain points, this idea of perpendicularity of functions is a direct generalization of that of vectors, and allows us to decide how much f points in the direction of sin(nx), and hence to write f as a sum of various standard functions sin(nx), cos(mx).
note we have to choose different standard functions here as functions like (1,0,...,0) with only one non zero entry are not detectable by integrating.
Actually sin and cos are not the best choices, better are e^nx and e^inx , since these standard functions are eigenfunctions for the operator D of differentiation.
of course sinx = (1/2i)[e^(x) - e^(ix)] and cos(x) = (1/2)(e^x + e^(ix)), so the distinction is not fatal.