I have simple code, which flags nodes with in region enclosed by cylinder. On implementing the code, the result is mild tilt of the cylinder observed case with $\theta=90^{\circ}$.
The algorithm for checking any point inside arbitrarily oriented cylinder is as follows. Let $\vec{r}$ be the vector joining center $\vec{c}$ and arbitrary point $\vec{o}$, and $$\vec{r}=\vec{c}-\vec{o}.$$ For orientation vector $\vec{o}$, the projection of $\vec{r}$ on it is, $$ u = \vec{r}\cdot\vec{o}.$$ Therefore, the perpendicular vector is, $$\vec{p}=\vec{r}-u\cdot\vec{o}.$$ For a cylinder of length $2l$ and radius $a$, check $$\vec{p}.\vec{p}<a^2 \hspace{1cm} \text{for } -l\leq u \leq l. $$
The actual issue: The above algorithm is implemented in Fortran. The code checks for points in Cartesian grid if inside the cylinder. Following being the test case: The cylinder makes an angle $\theta=90^{\circ}$ in the yz-plane with respect to y-axis. Therefore, the orientation vector $\vec{o}$ is (0, 1, 0).
Case 1:
Orientation vector is assigned directly with $\vec{o}=(0.0,1.0,0.0)$. This results in perfect cylinder with $\theta=90^{\circ}.$
Case 2:
Orientation vector is specified with intrinsic Fortran functions with double precision accuracy dsin
and dcos
with $\vec{o}=(0.0, \sin(\pi/2.0), \cos(\pi/2.0))$ with $\pi$ value assigned with more than 20 significant decimal points. The resulting cylinder results in mild tilt.
The highlighted region indicates the extra material due to tilt of cylinder with respect to Cartesian axes. I also tried architecture specific maximum precision "pi" value. This also results in same problem.
This shows like the actual angle made by cylinder is not $90^\circ$. Can anyone suggest valid solution for this problem. I need to use the inbuilt trigonometric functions for arbitrary angles and looking for accurate cell flagging method.
Note: All operations are performed with double precision accuracy.
Paraview
and use color palette as "print" $\endgroup$ – SKPS Jun 18 '16 at 13:41