18
$\begingroup$

I want to create a Chinese-style curved roof programmatically, something like in the right part of this picture:

Chinese roof

As seen in the picture, the roof appears to have four curved segments, which intersect at the diagonals.

I would appreciate a formula as starting point where I can tweak the parameters.

$\endgroup$
  • 2
    $\begingroup$ You might also want to take a look at this paper. $\endgroup$ – J. M. is a poor mathematician Nov 20 '11 at 10:34
  • $\begingroup$ That's a useful paper, thanks! $\endgroup$ – Faikus Nov 21 '11 at 12:07
  • $\begingroup$ You're on your own with making the surface look "tiled", though. That's a trickier proposition... :) $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 12:09
14
$\begingroup$

One (rather rough) starting point is the following surface, based on the Lamé curve:

$$\begin{align*}x&=v|\cos\,u|^p \cos\,u\\y&=v|\sin\,u|^p \sin\,u\\z&=\frac{hv}{c^2}(v-2c)\end{align*}$$

where $p > 1$, $h,c > 0$ are adjustable parameters, $0 \leq u \leq 2\pi$, and $v$ ranges over nonnegative values.

Here's an example, with $p=2$, $c=3$, $h=2$, and $0 \leq v \leq 4$:

fake Chinese roof

$\endgroup$
  • $\begingroup$ An excellent starting point, thanks! $\endgroup$ – Faikus Nov 17 '11 at 14:14
12
$\begingroup$

I am not sure what you are looking for exactly, but to me this roof really looks like a pyramid to which is added the bottom of a sphere: $$z=H - \max(\lvert x\rvert,\lvert y\rvert) + R - \sqrt{R^2-x^2-y^2},$$ where $H$ is the height of the center of the roof, and $R$ is the radius of this supposed sphere, which you can definitely tweak.

enter image description here

In the above example, I chose $x\in\{-1,1\}$ and $y\in\{-1,1\}$, so of course $R$ should not be smaller than $\sqrt{2}$, but the limit depends on the ranges you choose for $x$ and $y$.

$\endgroup$
  • $\begingroup$ A very interesting approach! $\endgroup$ – Faikus Nov 17 '11 at 15:07
8
$\begingroup$

I figured I could improve on the first answer I gave; some more tweaking with the $z$-component led me to the parametric equations

$$\begin{align*}x&=v|\cos\,u|^p \cos\,u\\y&=v|\sin\,u|^p \sin\,u\\z&=\frac{hv}{c} \left(\left(\frac{v}{c}+2f-2\right)\cos^2 2u-2f\right)\end{align*}$$

where $f > 0$ is an additional adjustable parameter.

Here is the case $p=1$, $c=9/10$, $h=1/2$, $f=2/3$, and $0 \leq v \leq 3/2$:

improved Chinese roof

I derived these new equations by starting with the parametric equations of a cone, replacing the circular cross sections with Lamé curve cross sections, and tweaking the $z$-component such that the sweeping ray linearly interpolates between a line (between corners) and a parabola (on the corners).

$\endgroup$
1
$\begingroup$

\begin{align} x &= \frac{u+v}{2}\\ y &= \frac{u-v}{2}\\ z &= -0.3 \sin { ((\frac{|u+v|}{2} + \frac{|u-v|}{2})(\frac{|u+v|}{2} + \frac{|u-v|}{2}+1) \frac{\pi}{2} }) \end{align} \begin{align} -1 < u < 1, -1 < v < 1 \end{align}

Drawn with Gnuplot (I hope you can plot a better one)

From Side:

Side

Edit: Perhaps, this shows better: gnuplot2

$\endgroup$
  • $\begingroup$ It was sort of intended that the edges be curved instead of being straight... you might still be able to tweak that with an approach similar to Felix's. $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 11:54
  • $\begingroup$ Added side 2d plot, and a 3d plot with better resolution. $\endgroup$ – saeedgnu Nov 21 '11 at 12:26
  • $\begingroup$ Here is a better view of a Chinese roof. As I've said, note that the edges are curved. Yours are straight. You need to change your equation a bit so that the edges are curved. $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 12:31
  • $\begingroup$ Yeah, I focused on inner edges for now, not outer edges. I'm trying to do that. $\endgroup$ – saeedgnu Nov 21 '11 at 13:52
  • $\begingroup$ That's why I said that Felix's approach might apply. Adding a spherical term or factor might be one simple way to curl your edges. (Unfortunately, I can't experiment at the moment...) $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.