Computing curvature along planar intersection curves on a general surface $z = S(x,y)$ I am implementing a code that computes the curvature along curves of intersection between vertical planes and parametrised surfaces in 3D. In order to test this code, I have used the surface $S(x,y) = \cos x$ as a test function. The vertical plane P is defined as $y = -\frac{n_x}{n_y}x$ with normal $\mathbf{n}_p = [n_x\ \ n_y\ \ 0]^T$, where $n_x \!=\! -\!\sin\theta$ and $n_y \!=\! \cos\theta$. Here, $\theta\!\in\![0,2\pi]$ is the angle between P and the $xz$-plane that is an input in my code. I have implemented the code, but I am unable to get the correct curvature (I have an alternate means of computing the curvature for the test function because the curve of intersection is a linear scaling of the cos function). I am hoping that if I outline the method I used, someone can point out what I've done wrong. The method I have employed is as follows.
I first define the position vector $\mathbf{s} = [x\ \ y\ \ S(x,y)]^T$ and compute its partial derivatives $\mathbf{s}_x$, $\mathbf{s}_y$, $\mathbf{s}_{xx}$, $\mathbf{s}_{xy}$, and $\mathbf{s}_{yy}$. From this, I compute the unit normal of S as $\mathbf{n}_s = (\mathbf{s}_x\!\times\mathbf{s}_y)/|\mathbf{s}_x\!\times\mathbf{s}_y|$. The tangent along the curve of intersection is then $\mathbf{t} = \mathbf{n}_p\!\times\mathbf{n}_s$.
I then compute the coefficients of the first fundamental form, I, as: $$E=\mathbf{s}_x\!\cdot\mathbf{s}_x,\quad F=\mathbf{s}_x\!\cdot\mathbf{s}_y,\quad G=\mathbf{s}_y\!\cdot\mathbf{s}_y$$ Next, the coefficients of the second fundamental form, II: $$e=\mathbf{s}_{xx}\!\cdot\mathbf{n}_s,\quad f=\mathbf{s}_{xy}\!\cdot\mathbf{n}_s,\quad g=\mathbf{s}_{yy}\!\cdot\mathbf{n}_s$$
The tangent $\mathbf{t}$ of the intersection curve can be expressed as a linear combination of $\mathbf{s}_x$ and $\mathbf{s}_y$:
$$
\mathbf{t} = \left(\mathbf{t}\!\cdot\!\frac{\mathbf{s}_x}{|\mathbf{s}_x|}\right)\!\!\frac{\mathbf{s}_x}{|\mathbf{s}_x|} + \left(\mathbf{t}\!\cdot\!\frac{\mathbf{s}_y}{|\mathbf{s}_y|}\right)\!\!\frac{\mathbf{s}_y}{|\mathbf{s}_y|} = \left(\frac{\mathbf{t}\cdot\mathbf{s}_x}{\mathbf{s}_x\!\cdot\mathbf{s}_x}\right)\!\mathbf{s}_x + \left(\frac{\mathbf{t}\cdot\mathbf{s}_y}{\mathbf{s}_y\!\cdot\mathbf{s}_y}\right)\!\mathbf{s}_y = a\mathbf{s}_x + b\mathbf{s}_y.
$$
Lastly, I compute the normal curvature as:
$$
\kappa_n = \frac{\text{II}}{\text{I}} = \frac{ea^2 + 2fab + gb^2}{Ea^2 + 2Fab + Gb^2}
$$
Is the method outlined above the right way to compute the curvature along the intersection curve? Any help/advice would be very much appreciated!
$\bf{Edit}$: the code just so happens to compute the correct curvature when $x$ is an integer multiple of $\pi$, i.e. at the troughs/peaks of the cos function.
$\bf{Edit}$: It turns out that I don't actually want to be computing the 'normal' curvature in this case, as @Ted Shifrin has clearly pointed out in his answer. I want to be computing the curvature of the intersection curve 'in the vertical plane'.
 A: Corrugated surface
$$z = \cos x $$
has by usual differentiation main curvature
$$k_1 = \dfrac{-\cos x }{(1+\sin^2 x)^{1.5}},\;k_2=0;$$
At any orientation with respect to gutter generator direction using Euler's formula:
$$ k_n = k_1 \cos ^2 \psi  $$
It vanishes at $\psi= \dfrac{\pi}{2}$ due to straight extrusions.
EDIT1:
For surface in Monge form, both principal curvatures are obtained (usual symbols of partial derivatives) from the quadratic:
$$ k_n^2 -k_n \dfrac{(1+p^2)t+(1+q^2)r-pqs}{H^2}+\dfrac{rt-s^2}{H^4}=0 $$
A: I see that I misled you with my answer to your first post, as I misinterpreted the question. What I told you to compute was the normal curvature of the curve, which agrees with its curvature precisely when the plane slicing the surface contains the normal vector of the surface at the point. However, what gives you the answer is Meusnier's Formula (p. 51) of my text: The usual curvature and the normal curvature are related by
$$\text{II}(\vec v,\vec v) = \kappa_n = \kappa\cos\phi,$$
where $\phi$ is the angle between the principal normal and the surface normal. (The principal normal of your curve is going to be one of the two unit vectors in your slicing plane orthogonal to the tangent vector of the curve. Presumably your signed curvature requires that you pick an orientation on the slicing plane — i.e., a choice of normal vector to that plane.)
Your computation presumably gave the correct answer at the points where the slicing plane was actually normal to the surface.
