[RESOLVED] Equation of curve through three points.-VBForums

Thread: [RESOLVED] Equation of curve through three points.

1. [RESOLVED] Equation of curve through three points.

Can someone help me here?
I need the equation of a curve that passes through three known points. At two points the tangential angle of curve is 0. The third known point is the point of contraflexure. Is there a cubic equation that is simple to determine from these coordinates?

2. Re: Equation of curve through three points.

Originally Posted by sgrya1
Can someone help me here?
I need the equation of a curve that passes through three known points. At two points the tangential angle of curve is 0. The third known point is the point of contraflexure. Is there a cubic equation that is simple to determine from these coordinates?
Don't think you can do it with a single cubic polynomial. Since you have 3 fixed points plus 2 derivatives, that's 5 constraints - for that you need a 4th order polynomial (or perhaps 2 cubic splines that are joined).

Since you used the word contraflexure, does that mean this is a beam bending situation? If so, then I'd think you could use beam equations, which are 4th order. Another possibility might be a single cubic Bezier, though I'm not sure it would match the requirements exactly.

3. Re: Equation of curve through three points.

Originally Posted by VBAhack
Since you used the word contraflexure, does that mean this is a beam bending situation?
A slab actually. If your familiar with engineering I'll see if i can explain this a bit better.

I'm looking to find the levels of a post tensioned cables running through a slab. The point of contraflexure is actually the point at which the tendon changes curvature.

Been out of uni for about 7 years so lost a bit of what I may have learnt. A Cubic Bezier definately doesn't ring a bell though. Was hoping that it might be simple.

4. Re: Equation of curve through three points.

Originally Posted by sgrya1
Been out of uni for about 7 years so lost a bit of what I may have learnt.
Heck, it's been >>20 years in my case! I had basic solid mechanics, but not much specific to Civil.

A pair of joined cubic splines isn't really very difficult to construct. It just means solving a set of linear equations - easy to do with Excel matrix functions.

A 4th order polynomial would be even easier (or about the same). Is there some reason you don't want to use a 4th order poly?

5. Re: Equation of curve through three points.

With all the computer programs these days my job is sadly almost becoming data entry. Don't often have too much of a need to even construct 4th order polynomial equations. Tendon profiles are often installed with a relatively significant tolerance and I can't imagine there'd be a vast difference to a 4th order polynomial or a "Cubic Benzier" curve. Any tips on constucting a 4th order polynomial equation with the coords and angles above?

6. Re: Equation of curve through three points.

4th order poly:

y = ax4 + bx3 + cx2 + dx + e

y' = 4ax3 + 3bx2 + 2cx + d

call your points left to right along the x-axis p1, p2 p3

y'(x1) = 0 = y'(x3)

this yields a set of 5 linear equations in 5 unknowns (i.e. a, b, c, d, e)

y'(x1) = 0 = 4*a*(x1)3 + 3*b*(x1)2 + 2*c*(x1) + d
y1 = a*(x1)4 + b*(x1)3 + c*(x1)2 + d*(x1) + e
y2 = a*(x2)4 + b*(x2)3 + c*(x2)2 + d*(x2) + e
y3 = a*(x3)4 + b*(x3)3 + c*(x3)2 + d*(x3) + e
y'(x3) = 0 = 4*a*(x3)3 + 3*b*(x3)2 + 2*c*(x3) + d

In matrix notation:

[A] [c] = [b]

Code:
```┌                                 ┐ ┌   ┐   ┌    ┐
│ 4*x1^3   3*x1^2   2*x1    1   0 │ │ a │   │  0 │
│   x1^4     x1^3   x1^2   x1   1 │ │ b │   │ y1 │
│   x2^4     x2^3   x2^2   x2   1 │ │ c │ = │ y2 │
│   x3^4     x3^3   x3^2   x3   1 │ │ d │   │ y3 │
│ 4*x3^3   3*x3^2   2*x3    1   0 │ │ e │   │  0 │
└                                 ┘ └   ┘   └    ┘```
c = [A]-1b ......easy w/ Excel (=mmult(minverse(A),b))

Looking at your plot, I came up with:

P1 = (0.5, 8)
P2 = (7,6)
P3 = (20,0)

resulting in:

a = 1.03742E-05
b = 0.001732484
c = -0.061785885
d = 0.060481335
e = 7.984988595

7. Re: Equation of curve through three points.

Actually, this problem is a perfect situation for 2 joined cubic splines - 3 points with known end conditions (i.e. zero derivative):

We have 2 cubic splines

y = ax3 + bx2 + cx + d ....for x =< 7
y' = 3ax2 + 2bx + c
y'' = 6ax + 2b

y = ex3 + fx2 + gx + h ....for x > 7
y' = 3ex2 + 2fx + g
y'' = 6ex + 2f

There will be a total of 8 equations with 8 unknowns:

1: 0 = 3ax12 + 2bx1 + c
2: y1 = ax13 + bx12 + cx1 + d
3: y2 = ax23 + bx22 + cx2 + d
4: 0 = 3ax22 + 2bx2 + c - 3ex22 - 2fx2 - g
5: 0 = 6ax2 + 2b - 6ex2 - 2f
6: y2 = ex23 + fx22 + gx2 + h
7: y3 = ex33 + fx32 + gx3 + h
8: 0 = 3ex32 + 2fx3 + g

Equations (1) and (8) are the end conditions with zero slope. Equations (2) and (3) are points P1 and P2 using the 1st cubic spline. Equations (6) and (7) are points P2 and P3 using the 2nd cubic spline. Equation (4) matches the slope (1st derivative) of the 2 splines at P2. And, equation (5) matches the curvature (2nd derivative) of the 2 splines at P2.

In matrix form:

[A][c] = [b]

Code:
```┌                                                       ┐  ┌   ┐    ┌    ┐
│3x1^2   2x1     1      0       0        0      0      0│  │ a │    │  0 │
│x1^3    x1^2    x1     1       0        0      0      0│  │ b │    │ y1 │
│x2^3    x2^2    x2     1       0        0      0      0│  │ c │    │ y2 │
│3x2^2   2x2     1      0      -3x2^2   -2x2   -1      0│  │ d │  = │  0 │
│6x2     2       0      0      -6x2     -2      0      0│  │ e │    │  0 │
│0       0       0      0      x2^3     x2^2    x2     1│  │ f │    │ y2 │
│0       0       0      0      x3^3     x3^2    x3     1│  │ g │    │ y3 │
│0       0       0      0      3x3^2    2x3     1      0│  │ h │    │  0 │
└                                                       ┘  └   ┘    └    ┘```
Everything is known except a-h. The solution is: [c] = [A]-1[b]

Resulting in:

a = 0.001820665
b = -0.061902594
c = 0.060537096
d = 7.984979518
e = 0.002275831
f = -0.071461083
g = 0.127446518
h = 7.828857533

Plot is very similiar to the other one

8. Re: Equation of curve through three points.

This all rings a big bell. I did statistics as a minor in a seperate degree and also created a vb project for my final year engineering project that did exactly this. Just not 4th order polynomials. And I've forgotten it all. I had to generate concrete mix designs from huge amounts of test data, curve fitting which required matrix calculations from the test data.

For some reason I thought that it'd be a little easier. Thankyou. Your help is not falling on someone who doesn't understand.

Task now is to code it up. Hoping the old project is on my computer back in Aus.

Rep Up!

9. Re: Equation of curve through three points.

Originally Posted by sgrya1
I have been accused (but not convicted) of going overboard sometimes. Glad to help........

10. Re: [RESOLVED] Equation of curve through three points.

VBAhack,

This is embarasing. I knew how to do this in university but it seems to have slipped my mind.

As far as I remembered I highlighted the range of cells that my inverse matrix would be outputted to and entered say =MINVERSE(\$B\$6:\$F\$10) into the first cell then pressed CTRL+ENTER and the MINVERSE matrix would be generated.

Is it something to do with the \$ signs that I'm using?

Haven't had any luck coding this thing yet but I've tried.

Can you tell me what I've forgotten?

11. Re: [RESOLVED] Equation of curve through three points.

The key sequence for entering an array forumula is:

CTRL+SHIFT+ENTER

Just look in help using 'array' as a keyword. Good luck.

12. Re: [RESOLVED] Equation of curve through three points.

Hey sgrya1,

Something doesn't seem right about this - in particular the point of contraflecture. If contraflecture. means the location where the curvature is zero, which I think it does, then due to symmetry, the point of contraflecture should be midway between the end points, unless there is an imposed curvature at either end.

Just for kicks, I fit a cubic polynomial to the end points, enforcing zero slope, and completely igorning the 2nd point. The result, of course, was zero curvature at the midway point. Oddly enough, the value I read from your graph for the point of contraflecture. (7,6) pretty much matches a point on the curve if the coordinates are reversed. Check out the attached spreadsheet.

13. Re: [RESOLVED] Equation of curve through three points.

Is there a way I could enforce the point of zero curvature to a specified point (so that it is not necessarily at the midpoint)?

How would I create say a 2nd order polynomial curve with just two defined points. The first has a gradient of 0 and the second has 0 curvature.

I could then combine two curves to create three point curve.

The attached is an example but I can't sem to unprotect it and see what it's doing with the office 2007 that I have here.

14. Re: [RESOLVED] Equation of curve through three points.

Originally Posted by sgrya1
Is there a way I could enforce the point of zero curvature to a specified point (so that it is not necessarily at the midpoint)?
Yes, but you'd need a single 4th order polynomial or two 3rd order polynomials that are joined, but only if all you are specifying is the x location of the interior point that has zero curvature. If you also want to specify the y value, then you'd need a 5th order poly or two 4th order polys that are joined.

Originally Posted by sgrya1
How would I create say a 2nd order polynomial curve with just two defined points. The first has a gradient of 0 and the second has 0 curvature.
Can't do it with 2nd order polynomials - the curvature is constant - just differentiate twice and you'll see. For these kinds of problems, you can pretty much forget about 2nd order polynomials - they just don't work very well.

The best approach to answering these kinds of questions is to use the concept of # equations = # unkowns.

For example, consider a 4th order polynomial. It has 5 unknowns, thus 5 equations (can also call them constraints) are needed. In the case of your first question about specifying the location of zero curvature, here is the logic. You have 2 endpoints - that's 2 constraints/equations. You have zero slope at those 2 endpoints - 2 more, for a total of 4. That leaves one additional condition that can be specified. It can be the y-value at a particular x-value, or the slope at a particular x-value, or the curvature at a particular x-value, etc. If you choose the x location where the curvature is zero, you can't also specify the y value or the slope - that would be too many constraints - a higher order poly would be needed.

Similarly, with 2 joined 3rd order polys, you need 8 equations. Here is the logic. You have 2 endpoints and 2 slopes, that 4 equations. You have an interior point (i.e. x location) that is common to both polys - 5th equation. You want the slopes of both polys to match at the common point - 6th equation. You want the curvature of both polys to match at the common point - 7th equation. Finally, you want the curvature at a specified x value to be zero - 8th equation. By the way, the point where the polys join doesn't necessarily have to be the same point where the curvature is zero - it can be but doesn't have to.

Attached is a plot showing 5 different sets of joined cubic polynomials - each set has the same 2 endpoints with zero slope but a different choice for the x location of zero curvature. The dots represent the chosen x locations of zero curvature. By the way, plots of 4th order polys w/ varying x locations of zero curvature will look similar.

Hope this helps.
.

15. Re: [RESOLVED] Equation of curve through three points.

I can’t thank you enough for this. Feel like a dumb kid in year 9.
I’ve tried generating the forth order polynomials but I’m getting some odd results. All the constraints are met but it’s not what I’m after. Is there another restraint (or restraints) that I can add? Your cubic solution chart in your last post is what I expect but I can’t replicate it even though your instructions are as clear as day. Ideally I stick with the 4th order polynomial as it’s simpler.

Do you still have the spreadsheet you used to generate those curves? The first 4 equations are obviously simple enough to get but I’m struggling to work out what equations 5 – 8 are given that each one needs to satisfy two equations .
y = ax3 + bx2 + cx + d Cubic Eqn 1
y' = 3ax2 + 2bx + c Slope
y'' = 6ax + 2b Curvature
y = ex3 + fx2 + gx + h Cubic Eqn 2
y' = 3ex2 + 2fx + g Slope
y'' = 6ex + 2f Curvature

Eqn 1 y1 = a*x13 + b*x14 + c*x1 + d End Point 1
Eqn 2 y2 = e*x23 + f*x24 + g*x2 + h End Point 2
Eqn 3 y'(x1) = 0 = 3*a*x12 + 2*b*x1 + c Slope at End Point 1
Eqn 4 y'(x2) = 0 = 3*e*x22 + 2*f*x2 + g Slope at End Point 2

16. Re: [RESOLVED] Equation of curve through three points.

4th order poly results look right - the further you depart from the midpoint as the location of zero curvature, the wilder the curve - I got the same result.

Joining two cubic polys and forcing the join point to have zero curvature I believe will give you the result you are seeking. It is much better behaved. Per my previous post, even though the point of zero curvature doesn't have to be the join point, if they differ you'll get results that are similar to the 4th order poly.

In joining two cubic polys, the remaining 4 equations have to do with ensuring continuity of point, slope, and curvature at the join point, and forcing zero curvature where you want it. Assumming the point of zero curvature and the join point are the same (i.e. x3):

Eqn 1: y1 = a*x13 + b*x12 + c*x1 + d .......... End Point 1 (yours has typo - 2nd term should be power 2, not 4)
Eqn 2: y2 = e*x23 + f*x22 + g*x2 + h .......... End Point 2 (same comment)
Eqn 3: y'(x1) = 0 = 3*a*x12 + 2*b*x1 + c .......... Slope at End Point 1
Eqn 4: y'(x2) = 0 = 3*e*x22 + 2*f*x2 + g .......... Slope at End Point 2
Eqn 5: 0 = a*x33+ b*x32 + c*x3 + d - e*x33 - f*x32 - g*x3 - h ..... join point is common to both polys
Eqn 6: 0 = 3*a*x32 + 2*b*x3 + c - 3*e*x32 - 2*f*x3 - g ............... slope continuity at join point
Eqn 7: 0 = 6*a*x3+ 2*b - 6*e*x3 - 2*f .................... curvature continuity at join point
Eqn 8: y''(x3) = 0 = 6*e*x3 + 2*f ......................... zero curvature at interior point

Equation 5 just says that y3 in the 1st poly = y3 in the 2nd poly. Equation 6 is the same only slope. Equation 7 is the same only curvature. Equation 7 could have alternatively been written as: 0 = 6*a*x3 + 2*b. The result will be the same. The way I did it is more general in that it's easier to have the point of zero curvature be a different point than the join point - equation 8 would just be 0 = 6*e*x4 + 2*f or 0 = 6*a*x4 + 2*b depending on where x4 is.

I suggest you play around with having the join point and point of zero curvature differ - just to see how the result changes.

Have fun
.

17. Re: [RESOLVED] Equation of curve through three points.

I loved math through university. It was a game as I understood it well. I must be getting older and am understanding how some people got frustrated.

Why can't I get the same results? I've checked all the formulas and they all seem logical. I've also checked and rechecked the matrices a number of times.

Attached is what I've put together but one curve is not complying with the constraints. Can you post your excel sheet so I can cross check them?

BTW, how do you add a single point to the curve in excel?

18. Re: [RESOLVED] Equation of curve through three points.

Another question, I've found a textbook that says that I should join two 2nd order polynomials for the tendon profile. Not sure of the science behind which (2nd order or 3rd order) would be more suitable for post tensioned concrete design but I need a square matrix to invert.

y = ax2 + bx + c Cubic Eqn 1
y' =2ax + b Slope
y'' =2a Curvature
y = dx2 + ex + f Cubic Eqn 2
y' = 2dx + e Slope
y'' = 2d Curvature

Yields 6 unknowns but I still see that there should be 8 constraints as per the 3rd order polynomial problem. Do I just add extra redundant variables?

19. Re: [RESOLVED] Equation of curve through three points.

Originally Posted by sgrya1
Why can't I get the same results? I've checked all the formulas and they all seem logical. I've also checked and rechecked the matrices a number of times
You have a typo in cell G42. You have -x_3^2 which is oddly interpreted by Excel as (-x_3)^2. The formula should be -(x_3^2). I spotted it right away because F42-I42 should just be the negatives of B42-E42. That makes the difference. Actually, F42 is also a typo, but it doesn't matter since an odd power is involved.

Originally Posted by sgrya1
BTW, how do you add a single point to the curve in excel?
If you are referring to how I put symbols only on the points of zero curvature, I didn't add new points. In Excel charts, you can selectively turn symbols on. Here's how to do it:

- Click the curve once to highlight
- Move the cursor along the curve until you find the point you want to have a symbol. If you do it slowly, Excel will tell you the coordinates of each point as the cursor passes over it
- Click once to highlight the point of interest and pause for a second
- Double click the point to bring up the Format Data Point dialog box and choose the marker you want
- Repeat for the other points for which you want markers shown

Originally Posted by sgrya1
Another question, I've found a textbook that says that I should join two 2nd order polynomials for the tendon profile. Not sure of the science behind which (2nd order or 3rd order) would be more suitable for post tensioned concrete design but I need a square matrix to invert.

Yields 6 unknowns but I still see that there should be 8 constraints as per the 3rd order polynomial problem. Do I just add extra redundant variables?
If you join two 2nd order ploys, you can only have 6 equations since there are 6 unknowns. In this case, you don't get to choose the interior point of zero curvature. You can't even enforce slope and curvature continuity at the join point. You need to specify the end points and slope, which is 4 equations. Making the join point common to both polys makes 5. That leaves 1 equation - you can enforce slope continuity or curvature continuity but not both. Try it - I doubt that you'll be very happy with the result. You simply can't enforce 8 conditions when joining two parabolas - you only get 6.

Having said that, if your textbook says you should use 2nd order equations, it is probably worth investigating more. I don't know anything about the appropriate math models for post-tensioned concrete tendon profiles.

20. Re: [RESOLVED] Equation of curve through three points.

Just to correct some sloppiness on my part. In a couple of places, I equated curvature with the 2nd derivative. They aren't the same thing, though in structures they often are since slopes are small. If y = f(x), the curvature, k is:

k = y'' / (1 + y'2)3/2

The 2nd derivative (y'') is a major component of curvature and approximates curvature if the slope is small compared to 1. On the other hand, if the 2nd derivative is zero, the curvature is zero (provided the slope is reasonable).

21. Re: [RESOLVED] Equation of curve through three points.

Greetings all:

I am interested in this thread regarding calculating the profile of prestressing cables. What I have is slightly different in condition. I am no math wizard, unfortunately.

I have a beam of length L and cable profile (reverse parabola).

What I know are the following:
1. Coordinate (x1,y1) --> Profile of tendon at high point @ x = 0
2. Coordinate (x2,y2) --> Profile of tendon at low point @ x = L/2
3. Coordinate (x3,y3) --> Profile of tendon at high point @ x = L

Is there an easy way to generate the profile of the cables such as shown in this link (figures 4,5 and 9a)

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured