Is there a way to simplify this $$\Big|\;|x+y|+|x-y|+z\;\Big|+\Big|\;|x+y|+|x-y|-z\;\Big|=r$$
so that it turns out something like:
$$|ax+by+cz|+|dx+ey+fz|+\cdots=ur$$
where $a$, $b$, $c$, ..., $u$ is a constant?
Or is there a way to at least simplify it so that there is only 1 layer deep of abs() function?
Side notes: This is for a fast collision detection of a AABB and a ray. If you graph the formula above (with r related to the size of the box), it will show a 3d box. I have used the same method to make a fast 2d box collision detection but have no idea how to make it 3d as I was stuck on this step...
Edit: Yes, I know I can use max(a,b,c) =ur to discribe this. And I'm turning it around so that I can find all the "break" points (should be 8 of them??) of this function:
$$y=\Big|\;|P_x+P_y|+|P_x-P_y|+P_z\;\Big|+\Big|\;|P_x+P_y|+|P_x-P_y|-P_z\;\Big|$$ $$where$$ $$P=(V_1+(V_2-V_1)x)$$ (V1 and V2 is a given 3D vector.)
so that I can calculate quickly what x has to be so that the function above return the smallest value possible.
(Also, everything is real number. Don't want to deal with complex number today...)
Actually... should I just ask what the break point is...Errrr... Sorry. New user here.
I would suggest working through different cases -
i) For $x \ge y \ge 0, x \ge \frac{|z|}{2},\Big|\;|x+y|+|x-y|+z\;\Big|+\Big|\;|x+y|+|x-y|-z\;\Big|=r$ becomes (where $r \ge 0$)
$2x + z + 2x - z = r, x = \frac{r}{4}$
ii) For $x \ge y \ge 0, x \lt \frac{|z|}{2}$, $2x + z - (2x - z) = r, z = \pm \frac{r}{2}$
iii) For $y \ge x \ge 0, y \ge \frac{|z|}{2}$, $4y = r, y = \frac{r}{4}$
iv) For $y \ge x \ge 0, y \lt \frac{|z|}{2}$, $2z = r, z = \pm \frac{r}{2}$
Checking all other cases, the final set of equations become -
i) For $|x| \ge |y|, |x| \ge \frac{|z|}{2}, x = \pm \frac{r}{4}$
ii) For $|x| \ge |y|, |x| \lt \frac{|z|}{2}$, $z = \pm \frac{r}{2}$
iii) For $|y| \ge |x|, y \ge \frac{|z|}{2}$, $y = \pm \frac{r}{4}$
iv) For $|y| \ge |x|, |y| \lt \frac{|z|}{2}$, $z = \pm \frac{r}{2}$
So you get $6$ planes, $x = \pm \frac{r}{4}, y = \pm \frac{r}{4}, z = \pm \frac{r}{2}$. It is obvious what the shape of the bound region would be.