Defining a smooth curve between 2 points with given angles I have a rectangle with an aspect ratio of 2:1. I want to define a smooth curve joining two opposite corners such that the curve's tangent is parallel to the longer edge of the rectangle at one corner, and at the other corner the tangent is at 45deg. For example, if the rectangle's longer edges are horizontal, a curve would enter horizontally at the bottom left and leave at the top right at an angle of 45deg.
How can I define a formula for that curve? I don't mind whether it's Bezier or elliptical etc, but being able to reproduce it accurately in inkscape will be very helpful.
 A: I forgot that I need to caculate the length of the curve and find a number of equidistant points along it, so a Bezier curve would make the second part easier. Fortunately Wikipedia's explanation of quadratic Beziers is quite clear and points out that P1 is where the two tangents meet, and P1 is easy to find:
P0's tangent is the x-axis, so a 45 degree line passing through P2 (2, 1) crosses it at P1 (1, 0).
Unfortunately, finding the length of a quadratic curve is rather complicated, and my calculus is rusty, but I think I can manage it.
A: A quadratic equation has the properties you want. Imagine a rectangle positioned long side down up against the y-axis - it must have a slope of 1 with a tangent at 45 degrees somewhere. The general form of the quadratic is:
$$y = ax^2 + bx + c$$
With slope:
$$y' = 2ax + b$$
We know that for y' we want:
$$1 = 2ax + b$$
But we also know that at x = 0 for y' we have:
$$0 = 2a(0) + b$$
$$b = 0$$
Which determines b as a constant. So substituting b = 0 and, for example, x = 2 (this is a unique value that sets the scale of the graph) into equation 3 gives:
$$a = \frac14$$
If our rectangle is above right of the origin then c = 0. So substituting all the constants into the general form gives:
$$y = \frac14x^2$$
$$y' = \frac12x$$
At x = 2 this yields both a y-value and a slope of 1, as desired.
Edit - To use the arc length formula with this curve first observe that the arc length l increases smoothly as we move along, therefore:
$$l(x + \epsilon) = l(x) + \epsilon l'(x)$$
As with all smooth curves. In particular:
$$l(x + \epsilon) - l(x) = \epsilon l'(x)$$
But we also know that:
$$s = \epsilon \sqrt(1 + y'^2)$$
From Pythagoras and the normal proof of the formula, where s is a small section of the curve. However, s equals the LHS of the second equation, so combining and cancelling:
$$l'(x) = \sqrt(1 + y'^2)$$
$$l'(x) = \sqrt(1 + \frac14x^2)$$
According to the Wolfram online integrator the integral of this is:
$$l(x) = \frac12 x\sqrt(\frac14x^2 + 1) + sinh^{-1}(\frac12x)$$
If you want to substitute for l(x) and solve for x you may have to do it numerically, or you could find the points using another numerical method.
