No. [N.B. the first part of this answer addresses the original version of the question where the assumption $\kappa \neq 0$ is made.]
- The trivial counterexample: most people use the word "convex" in the "closed sense", in which a straight line is a convex curve. A straight line does not have non-vanishing curvature.
- Assuming that you actually meant "strictly convex", the answer is still no. Consider the curve $\mathbf{r}(t) = (t, t^4)$ for $t\in [-1,1]$. It is clear that $\mathbf{r}$ is strictly convex by inspecting its graph. But the curvature $\kappa(0) = 0$ (though $\kappa(t) \neq 0$ for every $t \neq 0$).
The above two cases document the failure of the "only if" part of the statement. Note that if we modify the statement to read
A $C^2$ regular convex curve must have curvature $\kappa \geq 0$ or $\kappa \leq 0$ for all $t \in [a,b]$
the statement is true, which you can prove using the definition of the curvature as the derivative of the tangent vector.
The "if" part of the statement, namely the claim
A $C^2$ regular curve with $\kappa \neq 0$ is convex
is false also, without further qualifications. Consider the curve in $\mathbb{R}^2$ represented in polar coordinates by
$$ \theta(t) = t, r(t) = t $$
for $t\in [1,100]$
This curve is clearly not convex, yet the curvature is strictly signed. A corrected statement should involve a "local" caveat, in the sense that
Given $C^2$ regular curve $\mathbf{r}$ with $\kappa \geq 0$ (or $\kappa \leq 0$), for every $t_0\in [a,b]$ there exists $[c,d]\subset [a,b]$ with $c < t_0 < d$ that $\mathbf{r}|_{[c,d]}$ is convex.
For a sketch of the proof(s):
- At $t_0\in (a,b)$, let $T$ be the unit tangent vector and $N$ the unit normal vector. Consider the coordinate system of $\mathbb{R}^2$ given by $\mathbf{r}(t_0)$ is the origin and the axes given by $T$ and $N$. In particular we can write
$$ \mathbf{r}(t) = \mathbf{r}(t_0) + X(t) T + Y(t) N $$
for some $C^2$ functions $X(t)$ and $Y(t)$. We know that $X'(t_0) \neq 0$. So since it is $C^2$ we know that in a neighbourhood it is non-zero. Thus $\mathbf{r}(t)$ can be interpreted as a graph of a function, for $|t-t_0|$ sufficiently small. (Think implicit/inverse function theorem.)
- By directly performing a computation you can relate the curvature $\kappa$ of $\mathbf{r}$ to the second derivative of this graph. In particular you see that the two should have the same sign.
- So we can conclude that a curve is "locally convex" if its curvature is "locally signed".
Let's work with the first definition. We have
\begin{align} \kappa (s) &= \left\| \frac{d\vec T}{ds}(s)\right\| \\ &= \lim_{\delta s\to 0}\frac 1 {\delta s}\left\| \vec T(s + \delta s) - \vec T(s) \right\| \\
&= \lim_{\delta s \to 0} \frac 1 {\delta s} \sqrt{(\vec T(s + \delta s) - \vec T(s)).(\vec T(s + \delta s) - \vec T(s))} \\
&= \lim_{\delta s \to 0} \frac 1 {\delta s} \sqrt{\| \vec T(s + \delta s)\|^2 + \| \vec T(s) \|^2 - 2\vec T(s).\vec T(s + \delta s)}\end{align}
But the curve is parameterised by arc length! So
$$ \| \vec T(s + \delta s)\|^2 = \| \vec T(s)\|^2 = 1$$
and
$$ \vec T(s).\vec T(s + \delta s) = \cos \Phi(s, s + \delta s),$$
where $\Phi(s, s + \delta s)$ is the angle between $\vec T(s)$ and $\vec T(s + \delta s)$.
Plugging this in, we get
\begin{align}
\kappa &= \lim_{\delta s \to 0} \frac 1 {\delta s} \sqrt{2 - 2 \cos \Phi(s, s + \delta s)} \\
&= \lim_{\delta s \to 0} \frac 1 {\delta s} 2 \sin \left( \frac { \Phi(s, s + \delta s) } {2}\right) \\
&= \lim_{\delta s \to 0} \frac {\Phi(s, s + \delta s)} {\delta s} \times \frac{\sin \left( \frac { \Phi(s, s + \delta s) } {2}\right)}{\frac{\Phi(s, s + \delta s)}{2}}
\end{align}
Clearly, $\lim_{\delta s \to 0} \Phi(s, s + \delta s) = 0$, so
\begin{align}
\kappa &= \lim_{\delta s \to 0} \frac {\Phi(s, s + \delta s)} {\delta s} \times \lim_{\Phi \to 0} \frac{\sin \left( \frac { \Phi } {2}\right)}{\frac{\Phi}{2}} \\
&= \lim_{\delta s \to 0} \frac {\Phi(s, s + \delta s)} {\delta s} \times 1 \\ &= \lim_{\delta s \to 0} \frac {\Phi(s, s + \delta s)} {\delta s}\end{align}
which agrees with the second definition.
Best Answer
You can use the following explanation. Here, $\theta$ denotes the angle from the $x$-axis to the tangent of the curve.
A positive $2\pi$-periodic function represents the curvature function of a simply closed, strictly convex $C^{2}$ plane curve if and only if $$\int_{0}^{2\pi}\displaystyle\frac{\cos \theta}{k(\theta)} \,\mathrm d\theta=\int_{0}^{2\pi}\displaystyle\frac{\sin \theta}{k(\theta)} \,\mathrm d\theta =0.$$
because if $k$ is the curvature function of some curve, then this relation follows directly from the fact that the curve is closed, i.e. that $\int_{0}^{L} T\,\mathrm ds=0$.
In the other direction: Given an arbitrary $k$, the associated curve, up to translation, is defined by $$x(\theta)=\int_{0}^{\theta}\displaystyle\frac{\cos\eta}{k(\eta)}\,\mathrm d\eta\qquad y(\theta)=\int_{0}^{\theta}\displaystyle\frac{\sin\eta}{k(\eta)}\,\mathrm d\eta$$ It is easy to check that this curve is closed and simple as $x(0) = y(0) = x(2\pi) = y(2\pi) = 0$.