Commit 793e1542 authored by Conor McCoid's avatar Conor McCoid
Browse files

Tetra: rewrote 3D algo in article

parent 13caa5bb
...@@ -454,44 +454,43 @@ They are presented in Table \ref{tab:corners}. ...@@ -454,44 +454,43 @@ They are presented in Table \ref{tab:corners}.
\item[Step 1: Change of coordinates.] \item[Step 1: Change of coordinates.]
As described in Section \ref{sec:coords}, $V$ is transformed into $Y$ and $U$ into $X$. As described in Section \ref{sec:coords}, $V$ is transformed into $Y$ and $U$ into $X$.
\item[Step 2: Select plane of $Y$, $P$.] \item[Step 2: Select plane $P_\gamma$ of $Y$.]
Calculate $p_i$, $q_i$ and $r_i$ for all vertices of $X$. Calculate $\pxi{i}$, $\qxi{i}$ and $\rxi{i}$ for all vertices of $X$, $i=1,\dots,4$.
\begin{description} \begin{description}
\item[Step 2a: Intersections between $P$ and edges of $X$.] \item[Step 2a: Intersections between $P_\gamma$ and edges of $X$.]
Test if $\sign(p_i) \neq \sign(p_j)$. Test if $\sign(\pxi{i}) \neq \sign(\pxi{j})$.
If so, calculate the intersection between $p=0$ and the edge connecting the $i$--th and $j$--th vertices of $X$. If so, calculate the intersection between $p_\gamma=0$ and the edge connecting the $i$--th and $j$--th vertices of $X$, found using the coordinates $q^{ij}_\gamma$ and $r_\gamma^{ij}$.
If $q_\gamma^{ij}$, $r_\gamma^{ij}$ and $1-q_\gamma^{ij}-r_\gamma^{ij}$ are all non-negative then the intersection is a corner of the polyhedron of intersection.
Repeat for all pairs of $i$ and $j$. Repeat for all pairs of $i$ and $j$.
\item[Step 2b: Intersection between $G$ and $F$.] \item[Step 2b: Intersection between $G$ and edges of $Y$.]
Select a reference line of the right angle triangle $F$. Select an edge of $Y$ that lies in $P_\gamma$.
Calculate $s_i$ and $t_i$ for all vertices of $G$. Without loss of generality, suppose this aligns with $q_\gamma=p_\eta=0$.
Test if $\sign(q_\gamma^{ij}) \neq \sign(q_\gamma^{ik})$
If so, calculate the intersection $t_{\gamma,\eta}^{ijk}$ between $G$ and this edge of $Y$.
If $t_{\gamma,\eta}^{ijk} \in [0,1]$ then this intersection is a corner of the polyhedron of intersection.
Repeat for all pairs of $ij$ and $ik$.
\begin{description} \begin{description}
\item[Step 2bi: Intersections between edges of $Y$ and faces of $X$.] \item[Step 2bi: Intersections between edges of $Y$ and faces of $X$.]
Test if $\sign(s_i) \neq \sign(s_j)$. Test if $\sign(t_{\gamma,\eta}^{ijk}) \neq \sign(t_{\gamma,\eta}^{ijl})$.
If so, calculate the intersection between this edge of $G$ and $s=0$. If so, the vertex of $Y$ at $t_{\gamma,\eta}=0$ lies in $X$.
Repeat for all pairs of $i$ and $j$. Likewise, if $\sign(1-t_{\gamma,\eta}^{ijk}) \neq \sign(1-t_{\gamma,\eta}^{ijl})$ then the vertex of $Y$ at $t_{\gamma,\eta}=1$ lies in $X$.
Let $t_{\min}$ be the smallest value of $t$ found in this way, and $t_{\max}$ the largest.
\end{description} \end{description}
Repeat step 2b for each reference line of $F$. Repeat step 2b for each edge of $Y$ that lies in $P_\gamma$.
\item[Step 2c: Intersections between $F$ and edges of $X$]
If $\sign(s_i)=1$ for all reference lines of $F$ then the $i$--th vertex of $G$ is an intersection between $F$ and an edge of $X$.
\end{description} \end{description}
Repeat step 2 for each face of $Y$. Repeat step 2 for each face of $Y$.
It is not necessary to repeat step 2b for edges considered in previous instances of step 2, nor step 2bi for previously considered vertices.
\item[Step 3: Vertices of $X$ in $Y$.] \item[Step 3: Vertices of $X$ in $Y$.]
Compare all values of $p_i$ for the $i$--th vertex of $X$. Compare all values of $\pxi{i}$ for the $i$--th vertex of $X$.
If $\sign(p_i) = 1$ for all $P$ then the $i$--th vertex lies inside $Y$. If $\sign(\pxi{i}) = 1$ for all $\gamma$ then the $i$--th vertex lies inside $Y$.
\item[Step 4: Edges of $Y$.] \item[Step 4: Undo change of coordinates.]
Select an edge of $Y$. Transform the intersections between edges of $X$ and faces of $Y$ (2a) and those between edges of $Y$ and faces of $X$ (2b) into the original coordinates.
Let $T_1$ be the smallest value of $t_{\min}$ found for this edge, and $T_2$ the largest value of $t_{\max}$. The transformation from $(p,q,r)$--coordinates has been shown in Table \ref{tab:XwithY}.
If either $T_1, T_2 \in [0,1]$ then the corresponding point is an intersection between this edge of $Y$ and a face of $X$. The transformation from $t$--coordinate is presented in Table \ref{tab:YwithX}.
If either $0,1 \in [T_1, T_2]$ then the corresponding vertex of $Y$ lies inside $X$.
\item[Step 5: Undo change of coordinates.]
Transform the intersections between edges of $X$ and faces of $Y$ (2c) and those between edges of $Y$ and faces of $X$ (4) into the original coordinates.
The transformations between $(s,t)$--coordinates and $(p,q,r)$--coordinates are found in Tables \ref{tab:XwithY} and \ref{tab:YwithX}.
Take the numbers listed in the tables, multiply by the respective vectors $\vec{v}_i$, sum the results and add $\vec{v}_0$ for the positions in original coordinates. Take the numbers listed in the tables, multiply by the respective vectors $\vec{v}_i$, sum the results and add $\vec{v}_0$ for the positions in original coordinates.
\end{description} \end{description}
...@@ -506,10 +505,15 @@ Take the numbers listed in the tables, multiply by the respective vectors $\vec{ ...@@ -506,10 +505,15 @@ Take the numbers listed in the tables, multiply by the respective vectors $\vec{
$y=0,x+y+z=1$ & $t$ & & $1-t$ \\ $y=0,x+y+z=1$ & $t$ & & $1-t$ \\
$x=0,x+y+z=1$ & & $1-t$ & $t$ $x=0,x+y+z=1$ & & $1-t$ & $t$
\end{tabular} \end{tabular}
\caption{Position of the intersection $(0,t)$ between an edge of $Y$ and a face of $X$ in original coordinates as functions of $(s,t)$--coordinates.} \caption{Position of the intersection between an edge of $Y$ and a face of $X$ in original coordinates as functions of its $t$--coordinate.}
\label{tab:YwithX} \label{tab:YwithX}
\end{table} \end{table}
Note that step 2b may be completed after step 2a has been completed for all planes $P_\gamma$.
Likewise, step 2bi may be completed after all instances of step 2b.
This means the algorithm can be parallelized by having steps 2a, 2b and 2bi run by separate threads.
One could also have each plane $P_\gamma$ run by separate threads, though information about which edges and vertices have already been considered would need to be passed between these threads.
\section{Consistency errors} \section{Consistency errors}
If the algorithm is to be robust, an error on the order of machine epsilon can only cause a change in the volume of the polyhedron of intersection on the same order of magnitude. If the algorithm is to be robust, an error on the order of machine epsilon can only cause a change in the volume of the polyhedron of intersection on the same order of magnitude.
...@@ -1180,7 +1184,7 @@ This algorithm is consistent. ...@@ -1180,7 +1184,7 @@ This algorithm is consistent.
Outline: Outline:
\begin{itemize} \begin{itemize}
\item Prove each step of the algorithm is self-consistent; \item Prove each step of the algorithm is self-consistent;
\item Prove each step is consistent with the previous step; \item Prove each step is consistent with the previous step; % i am concerned that the calculated intersections may form a non-convex object which will cause an incorrect number of intersections to be calculated - either prevent this by taking convex hulls at each step or prove it isn't a problem
\item Induction. \item Induction.
\end{itemize} \end{itemize}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment