You should remember that the scalar projection of a vector represents the length of the vector projection, hence, projecting the vector `barx` to the vector `bary` yields:
`s = |x|*cos theta = x*bary`
Notice that `theta` is the angle made by vector `barx` to vector `bary` and |x| expresses the length of vector `barx` .
You need to picture the vectors `barx` and `bary` and you need to project the vector `bar x` to `bar y` . Notice that a right angle triangle is formed. You may evaluate the length of projection of vector `bar x` on `bar y` using cosine function in right angle triangle.
`cos theta = s/|x| =gt s = |x|cos theta`
s expresses the adjacent side to angle `theta`
|x| represents the hypotenuse of right angle triangle
This value of scalar projection depends on the angle the vector `bar x` makes to the vector`bar y` such that:
`theta lt pi/2 =gt s = |x|`
`theta gt pi/2 =gt s = -|x|`