An online text explaining rotation of axes includes this step:

x = X cos $\displaystyle \theta$ - Y sin $\displaystyle \theta$

y = X sin $\displaystyle \theta$ + Y cos $\displaystyle \theta$

By solving Equations (above) for X and Y we obtain

X = x cos $\displaystyle \theta$ +y sin $\displaystyle \theta$

Y = -x sin $\displaystyle \theta$ + y cos $\displaystyle \theta$

How do they get from the upper equations to the lower ones? Thanks in advance.