# Defining an oblique plane to draw

I'm trying to define an oblique plane with the points A, B and C to use in a scope environment and then draw a circle in it using 2D. In previous drawings I managed to get away with options like canvas is xy plane at z= but this time I'm not seeing how I can do that.

Is there a way to define planes to draw in using three points? How may I define that plane to draw? Using x={(a1,b1,c1)} and y={(a2,b2,c2)}?

Right now, what I have is this:

\documentclass{article}

\usepackage{tkz-euclide}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{75}{100}

\begin{tikzpicture}[tdplot_main_coords]

\foreach \i in {0,3}{
\begin{scope}[canvas is xy plane at z=\i]
\tkzDefPoints{0/0/O\i, 2/0/A\i}
\tkzDefRegPolygon[sides=8](O\i,A\i)
\begin{scope}[opacity=0]
\tkzLabelRegPolygon(O\i){P1\i,P2\i, P3\i, P4\i,P5\i,P6\i, P7\i, P8\i}
\end{scope}
\tkzDrawPolygon(P1\i,P2\i, P3\i, P4\i,P5\i,P6\i, P7\i, P8\i)
\end{scope}
}

\foreach \i in {1,...,8}{
\draw (P\i0) -- (P\i3);
}

\tkzLabelPoint[above](P13){$$A$$}
\tkzLabelPoint[above](P63){$$B$$}
\tkzLabelPoint[right](P30){$$C$$}
\end{tikzpicture}
\end{document}


Any help is massively appreciated!

You can compute the basis vectors of the plane. This can be done by computing cross products of differences between the three points, and normalizing them. (I use a slightly modified version of \tdplotcrossprod because the built-in version tends to swallow signs.) To illustrate this I draw a circle at the barycenter of the three points but you can adjust this to your needs. BTW, tkz-euclide does not bring great advantages in this scenario, but unfortunately it obscures the components of the coordinate, which is fine in 2d but not in 3d when you need them for further operations, so I dropped it.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{75}{120}

\begin{tikzpicture}[tdplot_main_coords,
declare function={x8(\i)=2*cos(\i*45-45);
y8(\i)=2*sin(\i*45-45);}]
\path foreach \j in {0,3} {foreach \i in {1,...,8}
{({x8(\i)},{y8(\i)},{\j}) coordinate (P\i\j)}};
\draw foreach \j in {0,3}
{plot[samples at={1,...,8}] (P\x\j) -- cycle};
\foreach \i in {1,...,8}{
\draw (P\i0) -- (P\i3);
}
\path (P13) node[above] {$A$} (P63) node[above] {$B$}
(P30) node[right] {$C$};
%\show\tdplotcrossprod
\def\tdplotcrossprod(#1,#2,#3)(#4,#5,#6){%
\pgfmathsetmacro{\tdplotresx}{(#2) * (#6) - (#3) * (#5)}%
\pgfmathsetmacro{\tdplotresy}{(#3) * (#4) - (#1) * (#6)}%
\pgfmathsetmacro {\tdplotresz }{(#1) * (#5) - (#2) * (#4)}}
% compute the normal on the plane
\tdplotcrossprod({x8(1)-x8(6)},{y8(1)-y8(6)},0)({x8(1)-x8(3)},{y8(1)-y8(3)},3)
\pgfmathsetmacro{\normalization}{sqrt(\tdplotresx*\tdplotresx+\tdplotresy*\tdplotresy+\tdplotresz*\tdplotresz)}
\pgfmathsetmacro{\nAx}{\tdplotresx/\normalization}
\pgfmathsetmacro{\nAy}{\tdplotresy/\normalization}
\pgfmathsetmacro{\nAz}{\tdplotresz/\normalization}
% compute the x-vector of the plane
\pgfmathsetmacro{\normalization}{sqrt((x8(1)-x8(6))*(x8(1)-x8(6))+(y8(1)-y8(6))*(y8(1)-y8(6)))}
\pgfmathsetmacro{\exx}{(x8(6)-x8(1))/\normalization}
\pgfmathsetmacro{\exy}{(y8(6)-y8(1))/\normalization}
\pgfmathsetmacro{\exz}{0}
% compute the y-vector of the plane
\tdplotcrossprod(\nAx,\nAy,\nAz)(\exx,\exy,\exz)
\pgfmathsetmacro{\normalization}{sqrt(\tdplotresx*\tdplotresx+\tdplotresy*\tdplotresy+\tdplotresz*\tdplotresz)}
\pgfmathsetmacro{\eyx}{\tdplotresx/\normalization}
\pgfmathsetmacro{\eyy}{\tdplotresy/\normalization}
\pgfmathsetmacro{\eyz}{\tdplotresz/\normalization}
\typeout{(ex)=(\exx,\exy,\exz), (ey)=(\eyx,\eyy,\eyz), (ez)=(\nAx,\nAy,\nAz)}
%
\path (\exx,\exy,\exz) coordinate (ex)
(\eyx,\eyy,\eyz) coordinate (ey)
(\nAx,\nAy,\nAz) coordinate (ez)
({(x8(1)+x8(3)+x8(6))/3},{(y8(1)+y8(3)+y8(6))/3},2) coordinate (P);
\begin{scope}[x={(ex)},y={(ey)},z={(ez)}]%,canvas is xy plane at z=0]