Define a curve mathematically

curvesgeometry

EDIT 2

Sorry about this but as you've guessed I'm no maths ace…. Let me explain further. I'm going to start with the curve of a circle because its a simple function.

for f(x) = Sqrt(r^2 – x^2) where r = 3

For one quadrant of the circle the length of the curve equals pi/2 * r = 4.71

I want to find 4 points along the curve of equal length so

4.71 / 5 = 0.942

  • 0.942
  • 1.884
  • 2.826

  • 3.768

how would I go about finding the co-ordinates of the above lengths along the circles curve

Maths is descriptive but sometimes it takes a little time to explain what your tying to find away to express! :/

EDITED by author

My end goal is to define a method in a program that generates a curve between user defined points A and B. Points A and B are expressed in Cartesian form. The curve also needs to be formed from a number of points. This number is also user defined.

enter image description here

The first, last and number of points are user defined. In the above example being:

  • number of points = 9
  • p1 = x1, y1
  • p9 = x9, y7

In the above example the points are :

  • p1 = x1, y1
  • p2 = x2, y ?
  • p3 = x3, y ?
  • p4 = x4, y ?
  • p5 = x5, y ?
  • p6 = x6, y ?
  • p7 = x7, y ?
  • p8 = x8, y ?
  • p9 = x9, y 7

I need to find a formula to define the above ? and understand the effects it has on the curve.

So far I'm looking into using the offset between p2 and p1 (x8, y6), subtracting an arbitrary number from offset.y then recursively subtracting the quotient * 2 from the remainder, until this has repeated offset.x times.

I'm not sure that made sense I'm still writing it.

Best Answer

Let $S$ denote the starting point and $E$ the end point.

One of the most versatile type of curves connecting $S$ to $E$ are the (quadratic) Bézier curves where the current point $M$ is described in the following way (for values of "time" $t$ from $t=0$ where $M$ coincides $S$ to $t=1$ where $M=E$).

$$M=\color{red}{(1-t)^2} S + \color{red}{2 (1-t) t} C + \color{red}{t^2} E.\tag{1}$$

where $C$ is an arbitrary control point, which is in fact necessarily at the intersection of (predefined ?) tangents in $S$ and $E$.

Practically, in your case, (1) is transformed into :

$$\binom{x}{y}=(1-t)^2 \binom{1}{1} + 2 (1-t) t \binom{3}{6} + t^2 \binom{9}{7}\tag{2}$$

(2) can be expanded into

$$\begin{cases}x&=&(1-2t+t^2)+(2t-2t^2)3+t^2 9&=& \ \ \ 4t^2+4t+1\\ y&=&(1-2t+t^2)+(2t-2t^2)6+t^2 7&=&-4t^2+10t+1\end{cases}$$

(check, by taking $t=0$ and $t=1$, that we get points $S$ and $E$ resp.!)

The curve one obtains is in fact an arc of parabola (with oblique axis) as one can see on the following figure :

enter image description here

Please note that I have taken arbitrarily 9 intermediate points for time values $t=0.1, t=0.2...$. This can obviously be modified.

Remark : In (1) $\color{red}{(1-t)^2}, \ \ \color{red}{2 (1-t) t}, \ \ \color{red}{t^2}$ can be considered as weights placed on points $S,C,E$ resp. in order to "attract" $M$ in a different way for each value of $t$. The sum of these weights is $1$, whatever the value of $t$. For example, when $t=1/2$, these weights are $1/4,1/2,1/4$ : in this case, the power of attraction of $C$ is more important than that of $S$ or $E$.

Here is the corresponding Matlab program that, I think, can be understood in its great lines with my comments.

   S=[1;1];% starting point
   E=[9;7];% end point (as in your figure)
   C=[3;6];% control point (can be placed everywhere)
   t=linspace(0,1,101);% set of 101 values 0, 0.01, 0.02... 1.
   s=1-t;% the same in the other direction 1, 0.99, 0.98... 0.
   M=S*(s.^2)+C*(2*s.*t)+E*(t.^2);
   plot(M(1,:),M(2,:),'b');
   SCE=[S,C,E];plot(SCE(1,:),SCE(2,:),'r');
   plot(M(1,1:10:101),M(2,1:10:101),'or');
Related Question