\documentclass[12pt, varwidth, border={5mm 5mm 5mm 5mm}]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
% Underlining package
\usepackage{ulem}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{intersections}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}
% \usepackage[a4paper, portrait, margin=1cm]{geometry}
\usepackage{pgf}

% Define variables for the angles, line lengths, and distance between lines
\def\angle{random(30,60)} % best results are for 30 to 150
\def\linelength{4}
\def\paralleldistance{1.6}
\def\transangle{0} % keep at 0 to pevent diagram not being drawing properly
\def\transprojectinglength{1.6}
\def\rotationAngle{random(10,20)}  % can use 0 to 360

% Calculate the translength
\pgfmathsetmacro{\translength}{2*\transprojectinglength + \paralleldistance/cos((90-\angle) + \transangle)}

% Calculate the x and y components of the first parallel line starting at 0, 0\
\pgfmathsetmacro{\parIstartx}{0}
\pgfmathsetmacro{\parIstarty}{0}
\pgfmathsetmacro{\parIendx}{\linelength*cos(\angle)}
\pgfmathsetmacro{\parIendy}{\linelength*sin(\angle)}

% Calculate the x and y offsets for the second line; use x shift only
\pgfmathsetmacro{\xoffset}{\paralleldistance/sin(\angle)}
\pgfmathsetmacro{\yoffset}{0}

% Calculate the x and y components of the second parallel line starting at 0, 0\
\pgfmathsetmacro{\parIIstartx}{0 + \xoffset}
\pgfmathsetmacro{\parIIstarty}{0 + \yoffset}
\pgfmathsetmacro{\parIIendx}{\parIendx + \xoffset}
\pgfmathsetmacro{\parIIendy}{\parIendy + \yoffset}

% Calculate the x and y components of the transversal vector
\pgfmathsetmacro{\transparIendx}{0.5*\translength*cos(\transangle)}
\pgfmathsetmacro{\transparIendy}{0.5*\translength*sin(\transangle)}

% Calculate the midpoint of the parallel lines
\pgfmathsetmacro{\midpointx}{0.5*\parIendx + 0.5*\xoffset}
\pgfmathsetmacro{\midpointy}{0.5*\parIendy}

% Calculate the start and end points of the transversal
\pgfmathsetmacro{\transstartx}{\midpointx -1* \transparIendx}
\pgfmathsetmacro{\transstarty}{\midpointy -1* \transparIendy}
\pgfmathsetmacro{\transendx}{\midpointx + \transparIendx}
\pgfmathsetmacro{\transendy}{\midpointy + \transparIendy}


% Draw the diagram
\begin{document}
    \begin{tikzpicture}
      \begin{scope}[rotate=\rotationAngle]
        % Draw the first line
        \draw[<->>, >={Stealth[scale=1.3]}, name path=P1] (\parIstartx, \parIstarty) -- (\parIendx, \parIendy);
        % Draw the second line with the calculated offsets
        \draw[<->>, >={Stealth[scale=1.3]}, name path=P2] (\parIIstartx, \parIIstarty) -- (\parIIendx, \parIIendy);
        % Draw the transversal through the middle of the parallel lines
        \draw[<->, >=Stealth, name path=P3] (\transstartx, \transstarty) -- (\transendx, \transendy);
        
        \path [name intersections={of=P1 and P3,by=A}];
        \path [name intersections={of=P2 and P3,by=B}];

        % Draw the angle
        \coordinate (p1s) at (\parIstartx, \parIstarty);
        \coordinate (p1e) at (\parIendx, \parIendy);
        \coordinate (p2s) at (\parIIstartx,\parIIstarty);
        \coordinate (p2e) at (\parIIendx, \parIIendy);
        \coordinate (ts) at (\transstartx, \transstarty);
        \coordinate (te) at (\transendx, \transendy);

        % order for vertices go in anticlockwise order te--A--p1e
        %% Point A
        \draw pic["$a$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=te--A--p1e};
        \draw pic["$b$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=p1e--A--ts};
        \draw pic["$c$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=ts--A--p1s};
        \draw pic["$d$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=p1s--A--te};
       
        %%  Point B
        \draw pic["$e$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=te--B--p2e};
        \draw pic["$f$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=p2e--B--ts};
        \draw pic["$g$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=ts--B--p2s};
        \draw pic["$h$", draw=black, -, angle eccentricity=1.6, angle radius=0.4cm] {angle=p2s--B--te};

      \end{scope}
    \end{tikzpicture}
\end{document}
