diff --git a/docs/Proportional-Interval-Stamp/Proportional-Interval-Stamp.mdx b/docs/Proportional-Interval-Stamp/Proportional-Interval-Stamp.mdx index 96b81b0..dcdfa29 100644 --- a/docs/Proportional-Interval-Stamp/Proportional-Interval-Stamp.mdx +++ b/docs/Proportional-Interval-Stamp/Proportional-Interval-Stamp.mdx @@ -131,7 +131,7 @@ I'll soon explain it with precise mathematical formulas, so don't worry about it Proportional interval has another benefit: Strokes have more consistent appearance! Watch the start and end points of the fixed interval stroke. -Because the stroke radius drops to zero at these points, these dots are too sparser to keep a continuous feeling. +Because the stroke radius drops to zero at these points, these dots are too sparser to keep a continuous apperance. In contrast, the proportional interval is consistent all along the stroke. Actually, it's a [fractal](https://en.wikipedia.org/wiki/Fractal) when a radius comes to zero. @@ -202,7 +202,7 @@ $$ As $x = L$, we know the total stamp number on the edge, remind that $\cos\theta L = r_0-r_1$: $$ -\tag{3} n(L) = \frac{L}{\eta (r_0-r_1)}\ln \frac{r_0}{r_1} +\tag{3} n_L = \frac{L}{\eta (r_0-r_1)}\ln \frac{r_0}{r_1} $$ We will soon use the formula (1)(2)(3) in our code. @@ -219,20 +219,21 @@ Label the two roots with $x_1$ and $x_2$. ![locate stamp](./locate-stamp.png) To calculate the nearest stamp point (the black dot in the figure) between $x_1$ and $x_2$, -we need to compute the number of stamps from $x_1$ to the polyline's first vertex, which is also called stamp index at $x_1$. +we need to compute the number of stamps from $x_1$ to the polyline's first vertex, which is also called stamp index (or stamp count) at $x_1$. According to formula (1), on the current edge, the number of stamps from vertex0 to $x_1$ is $n(x_1)$. -Label the stamp index of vertex0 as $n_0$, and label vertex1's as $n_1$. +Label the stamp index of vertex0 as $n_{s_0}$, and label vertex1's as $n_{s_1}$. +(The symbol $s$ represents the arc from the first to current vertex). ![store](./store-n.png) -Therefore, the stamp index of $x_1$ is $n_0 + n(x_1)$. +Therefore, the stamp index of $x_1$ is $n_{s_0} + n(x_1)$. Because we place footprints at the points with integer stamp index, -the ceiling of $n_0 + n(x_1)$ is the nearest stamp's index, -denoted as $n_\mathrm{nearest} = \lceil n_0 + n(x_1) \rceil$. -Replace it into the formula (2) to get its position $x_{\mathrm{nearest}} = x(\lceil n_0 + n(x_1) \rceil)$, +the ceiling of $n_{s_0} + n(x_1)$ is the nearest stamp's index, +denoted as $n_\mathrm{nearest} = \lceil n_{s_0} + n(x_1) \rceil$. +Replace it into the formula (2) to get its position $x_{\mathrm{nearest}} = x(\lceil n_{s_0} + n(x_1) \rceil)$, and all other positions $x(n_\mathrm{nearest} + 1)$, $x(n_\mathrm{nearest} + 2) \dots$ -Additionally, to determine $n_0$ and $n_1$, we can compute the prefix sum of the $n(L)$ in formula (3) over all edges. +Additionally, to determine $n_{s_0}$ and $n_{s_1}$, we can compute the prefix sum of the $n_L$ in formula (3) over all edges. Put them into vertex data and pass them into fragment shader, exactly same as the value `length` in the Stamp section. ## Implementation @@ -249,8 +250,8 @@ This will bring numeric errors, which we surely want to avoid. A simple solution is to add a small number to the radii, as demoed in the code above. For a more rigorous approach, you can implement checks to prevent $r_0/r_1$ in the logarithm from becoming zero or excessively large. -Also, it's worth noting that if calculating the prefix sum value of $n(L)$ with CPU, -maybe you want to push $\eta$ times $n(L)$, $\eta n(L)$ instead of $n(L)$ itself into vertex buffer. +Also, it's worth noting that if calculating the prefix sum value of $n_L$ with CPU, +maybe you want to push $\eta$ times $n_L$, $\eta n_L$ instead of $n_L$ itself into vertex buffer. Because $\eta$ is a value changed more frequently, you won't want to recompute the prefix sum every time it changes. ## Proof of properties diff --git a/docs/Proportional-Interval-Stamp/store-n.png b/docs/Proportional-Interval-Stamp/store-n.png index d7254c4..98168b0 100644 Binary files a/docs/Proportional-Interval-Stamp/store-n.png and b/docs/Proportional-Interval-Stamp/store-n.png differ