# Calculate X axis distance to a reference point

I'm not very experienced in solving mathematical problems, but i need to calculate the distance on the X axis between the camera (D) and a reference point (M) knowing only the distance from the center of the cameras view to the reference point, the distance from the camera to the reference point and the angle between the center of the cameras view and the reference point.

Image describing my problem

Center of View From D ---- 120cm x ---- M
.                            / |
.                         /  |
.                      /   |
.           180cm z /    |
.                /     |
.             /      |
.          /       |
. /20°\ /        |
.    /         |
D ----------
?cm x


I hope the "image" helps to understand what i'm trying to achieve. How do i calculate the distance between D and M on the X Axis?

EDIT 09.08.2019

Thanks to Toby Mak's answer i was able to solve my problem. Here is how i solved the remaining parts:

With Toby Mak's formula i calculated $$\angle DCM$$. $$\angle CMD$$ is then calculated like this: 180 - 20 - $$\angle DCM$$.

Lets say that the right bottom corner is "K".
I know that $$\angle CMK$$ is 90° so $$\angle KMD$$ must therefore be 90 - $$\angle CMD$$.
And i also know that $$\angle DKM$$ is 90°. $$\angle MDK$$ is therefore 90 - $$\angle KMD$$

To calculate the final length "x" from "D" to "K" i used this formula:
z * $$\frac{\sin \angle KMD}{\sin \angle DKM}$$

Let $$C$$ be the centre of view. Using the law of sines:
$$\frac{\sin \angle DCM}{180} = \frac{\sin 20º}{120}$$ $$120 \sin \angle DCM = 180 \sin 20º$$ $$\sin \angle DCM = \frac{3}{2} \sin 20º$$ $$\angle DCM = \sin^{-1} \left(\frac{3}{2} \sin 20º \right)$$
Once you find $$\angle DCM$$, find $$\angle CMD$$. Then note that you have a right angle at $$M$$, so use that to find the other angle at $$M$$.
All you have left is then simple, right-angled trigonometry to find the horizontal distance between $$D$$ and $$M$$.