I am curious as to how the below two equations of a line are derived:
$$x\sin(t)-y\cos(t)+p=0\tag{1}\label{1}$$
where $t$ is the angle the line makes from $+x$-axis and $p$ is the shortest distance from the line to the origin (length of vector from origin to line orthogonally).
$t$ is given by $\arctan(y/x)$ and $p$ can be found by knowing a point $(x,y)$ on the line after finding $t$.
Another equation of the line is:
$$x\cos(t)+y\sin(t)=r\tag{2}\label{2}$$
It is basically the same idea. $r$ is the shortest distance from the line to the origin, which is again the length of a vector pointing orthogonally to the line.
The Question:
The two equations are different yet similar. I am not sure how they are derived. I have attempted to derive the equation \eqref{2} below, but I am stuck with regards to deriving equation \eqref{1}
I tried to derive the second equation as follows (I need verification):
The dot product of two vectors is $0$ if and only if they are perpendicular. Given a line containing two points pointed to by two vectors $\langle x,y\rangle$ and $\langle x_0,y_0\rangle$.
The vector from $\langle x_0,y_0\rangle$ to $\langle x,y\rangle$ is the vector $\langle x-x_0,y-y_0\rangle$.
We can use the unit circle to define a unit vector, $n$, (contained in the unit circle) normal to our line,
$$\langle nx,ny\rangle=\langle\cos t,\sin t\rangle$$
If a point $(x,y)$ lies on our line, it must satisfy the equation $\langle\cos t,\sin t\rangle*\langle x-x_0,y-y_0\rangle=0$, where $*$ is the dot product.
Multiplying out, you get:
$$\langle\cos t,\sin t\rangle*\langle x-x_0,y-y_0\rangle=x\cos t-x_0\cos t+y\sin t-y_0\sin t=x\cos t+y\sin t-(x_0\cos t+y_0\sin t)$$
Let $r=x_0\cos t+y_0\sin t$. Then equation can be rewritten as:
$$x\sin t+y\cos t=r$$
where $r$ is the shortest distance from origin to the line, i.e, the length of the vector pointing from origin to the line orthogonally. Is this correct?

Let the foot of normal from the origin have coordinates $(p\cos t,p\sin t)$. The parameter $t$ is the direction angle of the normal, while $p$ is the distance of the origin to the line.
Then you express that the segment from the foot of normal to any point on the line is orthogonal to the normal,
$$(x-p\cos t)\cos t+(y-p\sin t)\sin t=0$$ or
$$\color{green}{x\cos t +y\sin t=p}.$$
If you instead parameterize with the direction angle of the line itself, $t'=t+\pi/2$ and
$$-x\sin t'+y\cos t'=p,$$ also written
$$\color{green}{x\sin t'-y\cos t'+p=0}.$$