From 8ce7f12fbbde081929413816fabac7c730c3116b Mon Sep 17 00:00:00 2001 From: utensil Date: Thu, 19 Sep 2024 22:48:07 +0800 Subject: [PATCH] Add: Ray marching (naive) --- trees/ag-0001.tree | 2 +- trees/ag-000N.tree | 2 +- trees/ag-000V.tree | 2 +- trees/ag-000W.tree | 2 +- trees/ag-0018.tree | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 trees/ag-0018.tree diff --git a/trees/ag-0001.tree b/trees/ag-0001.tree index f293e27..b7c83a7 100644 --- a/trees/ag-0001.tree +++ b/trees/ag-0001.tree @@ -8,7 +8,7 @@ \author{utensil} \date{2024-08-13} -\meta{pdf}{true} +% \meta{pdf}{true} % definition theorem lemma construction observation % convention corollary axiom example exercise proof diff --git a/trees/ag-000N.tree b/trees/ag-000N.tree index 4598874..1aa949e 100644 --- a/trees/ag-000N.tree +++ b/trees/ag-000N.tree @@ -16,5 +16,5 @@ \transclude{ag-000V} \transclude{ag-000W} - +\transclude{ag-0018} } diff --git a/trees/ag-000V.tree b/trees/ag-000V.tree index a829a9c..df560ac 100644 --- a/trees/ag-000V.tree +++ b/trees/ag-000V.tree @@ -14,7 +14,7 @@ \refdeft{ray equation}{sec. 1.1 eq. 3}{gillespie2024ray}{ \p{ -A \newvocab{ray} anchored at #{\boldsymbol{r}_o} in the direction of the unit vector #{\boldsymbol{r}_d} can be parametrically defined as +A \newvocab{ray} anchored at origin #{\boldsymbol{r}_o} in the direction of the unit vector #{\boldsymbol{r}_d} can be parametrically defined as ##{ diff --git a/trees/ag-000W.tree b/trees/ag-000W.tree index 0ec4d85..8adc44f 100644 --- a/trees/ag-000W.tree +++ b/trees/ag-000W.tree @@ -21,7 +21,7 @@ F(t)=0 correspond to \newvocab{ray intersection}s with the implicit surface.} -\p{Implicit surface \newvocab{ray-tracing} algorithms simply apply one of the multitude of numerical root finding methods to solve this equation. +\p{Implicit surface \newvocab{ray-casting}/\newvocab{ray-tracing}/\newvocab{ray-marching} algorithms simply apply one of the multitude of numerical root finding methods to solve this equation. } } diff --git a/trees/ag-0018.tree b/trees/ag-0018.tree new file mode 100644 index 0000000..bf3473c --- /dev/null +++ b/trees/ag-0018.tree @@ -0,0 +1,55 @@ +\import{cg-macros} +% clifford hopf spin tt ag math draft cg +\tag{cg} + +% definition theorem lemma construction observation +% convention corollary axiom example exercise proof +% discussion remark notation +% \taxon{} +% \refcardt{lemma}{}{}{}{ + +% kostecki2011introduction leinster2016basic nakahira2023diagrammatic rosiak2022sheaf + +% cox1997ideals gathmann2013commutative hart1996sphere gillespie2024ray winchenbach2024lipschitz + +\def\alg/input[x]{\textbf{Input:} \x \\ } +\def\alg/inputc[x]{\phantom{\textbf{Input:}} \x \\ } +\def\alg/param[x]{\textbf{Parameters:} \x \\ } +\def\alg/paramc[x]{\phantom{\textbf{Parameters:}} \x \\ } +\def\alg/output[x]{\textbf{Output:} \x \\ } +\def\alg/outputc[x]{\phantom{\textbf{Output:}} \x \\ } + +\def\ro{\mathbf{r}_o} +\def\rd{\mathbf{r}_d} +\def\rt{\mathbf{r}_t} +\def\dt{\Delta t} +\def\eps{\varepsilon} +\def\tmax{t_{\max}} + +\card{algorithm}{ray marching (naïve)}{ +\minialg{ +% \begin{algorithm*}{Ray marching (naive)}{} +\alg/input{$\ro \in \RR^3$, ray origin} +\alg/inputc{$\rd \in \RR^3$, unit ray direction} +\alg/inputc{$f: \RR^3 \to \RR$, implicit surface function} +\alg/param{$\dt$, step size} +\alg/paramc{$\eps>0$, stopping tolerance} +\alg/paramc{$\tmax>0$, maximum ray time} +\alg/output{$t^*$, the time of the first intersection, $\tmax$ if no intersection occurs} +\begin{algorithmic} + \Procedure{RayMarch}{$\ro,\rd,f;\dt, \eps,\tmax$} + \State $t \gets 0$ + \While{$t < \tmax $} + \State $\rt \gets \ro + t \rd $ \Comment{current point along ray} + \State $f_t \gets f(\rt)$ \Comment{current function value} + \If{$f_t < \eps$} \Comment{stopping condition} + \State \textbf{return} $t$ + \EndIf + \State $t \gets t + \dt$ \Comment{take step} + \EndWhile + \State \textbf{return} $\tmax$ \Comment{ray does not hit surface} + \EndProcedure +\end{algorithmic} +% \end{algorithm*} +} +}