News:



  • April 27, 2024, 08:30:42 AM

Login with username, password and session length

Author Topic: Best approach to equally spaced points on a contour  (Read 6113 times)

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Best approach to equally spaced points on a contour
« on: July 04, 2009, 08:11:09 PM »
I'm not talking about a CAD method, I'm referring to a mathematical approach.

Suppose I have a contour, defined by a polynomial equation, e.g. y = A*x^1/2 + B*x + C*x^2 + D*x^3 + E*x^4. What I'd like to do is sample it at x values where the distances between points on the contour are the same distance.

What's a good approach?

It's pretty easy to take the derivative of the equation to get the instantaneous slope at any point. And I can do a fine sampling and sum distances between points for approximate length of the surface.

Suggestions for the best way to approach this problem?

Thanks in advance.

L.

Q. When you pat a dog on its head he will wag his tail. What will a goose do?
A. Paul Lynde: "Make him bark?"



AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Alan Hahn

  • Guest
  • Trade Count: (0)
Re: Best approach to equally spaced points on a contour
« Reply #1 on: July 04, 2009, 08:41:16 PM »
This is thinking out loud.

let ds=sqrt(dy^2+dx^2)--->where ds is an infinitesimal of s, the path length.

dy = (1/2A/sqrt(x)+B+2Cx+3Dx^2+4Ex^3)dx, (just the derivative of y(x) ---I don't vouch for mistakes!)

so ds =sqrt{(1/2A/sqrt(x)+B+2Cx+3Dx^2+4Ex^3)^2 +1} dx

s=integral of ds from x=0 to end, then if you want N points total, delta_s=s/N (+- 1 point, always get that wrong).

So now numerically integrate step by step (delta_s) from s=0 to s=end.

Not sure if there is an easier way or not.

Piece of cake!

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #2 on: July 04, 2009, 09:29:07 PM »
Wow, Alan what service! Thanks kindly.

Below are plots of the representative NACA00nn curve I was dealing with, and its slope.

The only thing I see is that the integration involves a lot of tiny steps of x, it's a bit iterative, which is what
I was trying to avoid. However, I have this very fast computer with dual Xeon quad CPUs, so it's not a real problem.

Essentially, we are moving x in tiny steps, and measuring distance to the previous point, until we have the distance we
want. I might take the last x step, and adjust it based on the distance error, so it converges to the proper value. I could
set a practical tolerance on the error. This would leave out the slope, I'd just be calculating a hypotenuse of a dx and dy
right triangle, square root of sum of squares.

What do you think? Iterative solutions may not be so pure mathematically, but why not? That's what we have computers for.

Thanks,

L.

"The learned is happy, nature to explore; The fool is happy, that he knows no more." -Alexander Pope

AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Alan Hahn

  • Guest
  • Trade Count: (0)
Re: Best approach to equally spaced points on a contour
« Reply #3 on: July 05, 2009, 08:53:30 AM »
Larry,
I'm kind of an iterative guy, and you are right that cpu power is cheap!

Analytically you could try to solve the integral equation for x(s) (and for y once you have x), but that looks pretty complicated to me, so that's why I think the iterative approach is faster (in "real" time), and plenty "good enough".

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #4 on: July 05, 2009, 02:51:05 PM »
Alan,

I believe we are thinking much alike here. I once told my computer science professor that
I despised computers (from working on them) and liked to write programs to punish them as
much as possible. My term for that was making it "Compute the Moon".. ;->

Although I have the NACA00nn equation for the airfoil that I always use for my own models, it
would be nice to read in a set of coordinates for any contour (perhaps interpolate using some
reasonable spline fit) and find equidistant points on the contour. I could implement a plug-in
"contour generator" which returns points on the contour for a normalized horizontal x position;
my crude iterative convergent method could be generic.

I already have people pointing out the obvious - I'm reinventing wheels, when I could simply
use a commercial program like Compufoil or Profili or Winfoil, or even model the wing panel in
3D and cut cross section slices to create rib templates. Yes, that might be the Easy Way, but
it ain't necessarily the Cowboy Way, the way that Roy or Gene or Hoppy would do it - or even
the way Sky King would do it!

Well, I'm sure you understand, this is a way for me to play with Visual BASIC and perhaps write
the next iteration of StuntRib. I'll likely call it StuntRib - the Movie! ;->

Thanks again for your thoughts and comments.

L.

"You should hammer your iron when it is glowing hot." -Publius Syrus
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Offline Randy Powell

  • 21 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 10478
  • TreeTop Flyer
Re: Best approach to equally spaced points on a contour
« Reply #5 on: July 12, 2009, 08:30:11 PM »
I wish I could still use the old StuntRib. I haven't installed a DOS emulator on my Linux system yet. I been having problems since I don't have a floppy drive anymore and I've been unable to find DOSS 6.22 ISO files.

But the Excel spread sheet still works more or less. Used it to generate the templates on the new plane. But I would look forward to a never, Winders compatible version of Stunt Rib!
Member in good standing of P.I.S.T
(Politically Incorrect Stunt Team)
AMA 67711
 Randy Powell

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #6 on: July 15, 2009, 09:05:35 AM »
Randy,

Having started with Assembler and then to C, which I loved, and then NOT going to C++, in spite of my object oriented classes in Ada and Modula-2, I've settled in on Visual BASIC (after scorning BASIC my working life). It serves well for what I need, and is a lot more readable.

As I believe I told you, I managed to lose the actual C source for the released version of StuntRib. I have some shards left, which I modified to allow a longer chord, not quite the same as the release, but usable. Anyway, since I used stdio with file redirection for the interface, I suspect you might simply MAKE a program with those sources on the typical unix system. Or not.

But if you would like those C sources, please let me know. I've pretty well translated them into VB6 now and have been using an Excel spreadsheet to test and experiment. Eventually I plan to build a stand alone Windows executable, hopefully a more useful program which I will release for general consumption.

I do tend to get hung up on "features", e.g. I was trying to handle elliptical wings (which have an amazing number of considerations for a reasonable design, IMO). And I have a dozen irons in the fire, none really getting very hot.

L.

"Food for thought is no substitute for the real thing." -Walt Kelly
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Offline phil c

  • 21 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 2480
Re: Best approach to equally spaced points on a contour
« Reply #7 on: July 19, 2009, 05:24:31 PM »
Can't quite figure out why you want equally spaced points on a non-uniform curve.  The equation for the NACA XXXX airfoils automatically spaces the points closer where the curvature is highest and farther apart as it gets flatter. 
phil Cartier

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #8 on: July 21, 2009, 05:34:07 PM »
Can't quite figure out why you want equally spaced points on a non-uniform curve.  The equation for the NACA XXXX airfoils automatically spaces the points closer where the curvature is highest and farther apart as it gets flatter. 

I'm not sure I understand what you are saying here, Phil. The equation is in the form y = f(x) where f(x) is a 5th order polynomial. You input a particular value of x (normalized range 0 to 1), and it returns a particular (normalized) value for y. Therein lies the problem. On the leading edge of the airfoil contour where the slope is the greatest, y points are further apart. If you want to get a fine curvature on your plot, you need a smaller x increment on the leading edge. In fact, to get a polyline to make a very faithful plot with a fixed x step, you need perhaps 5000 or more points. That's very wasteful, and means an unnecessarily large polyline object. OTOH, if you plot only 200 or less even steps of x, the leading edge loses the quality of its curvature.

The first image shows two airfoils, the red on was sampled with 5000 points, and the yellow one was 100 points. See the problem? Now, I used a graphical method on the second image, with 200 points, evenly spaced. See the difference?

If you use a laser cutter to cut a polyline with a bazillion points, its speed might be slowed, which could result in undesirable effects. Better all around to have a plot with fewer, but evenly spaced points on the contour.

Now, if I were using splines instead of polylines, I could be much more efficient, because all the work is done in spline equations, which are defined by a fit over specified points. I'm not sure what most smaller and less expensive laser cutters are capable of with respect to splines. For example, I had to convert DWG files to AutoCAD 2000 format to be usable on one commercial laser cutter equipment. And I don't remember when it occurred exactly, but some earlier version of AutoCAD (and other programs) did not attempt to deal directly with splines and converted them to simpler polylines.

Polyline segments may be straight lines and/or arcs. One might do something like measuring curvature between adjacent sets of 3 points, and adding an arc through three points at a time. I tried this on the three points on the LE with variable results, depending on x step size.

L.

"Keep in mind that neither success nor failure is ever final." -Roger Babson
 
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Offline Randy Powell

  • 21 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 10478
  • TreeTop Flyer
Re: Best approach to equally spaced points on a contour
« Reply #9 on: July 22, 2009, 11:08:19 AM »
Larry,

A windows executable would be great. I love virtualization.  Faked my wife out when her windows system died recently. I had copied everything previously (backup) and set up a linux account for her, installed VirtualBox and had her account auto run it and then auto run WinXP then maximize. She couldn't figure out how I transferred her whole computer onto mine. Fun stuff.
Member in good standing of P.I.S.T
(Politically Incorrect Stunt Team)
AMA 67711
 Randy Powell

Offline phil c

  • 21 supporter
  • Trade Count: (0)
  • Admiral
  • *
  • Posts: 2480
Re: Best approach to equally spaced points on a contour
« Reply #10 on: July 30, 2009, 09:12:50 AM »
[
Polyline segments may be straight lines and/or arcs. One might do something like measuring curvature between adjacent sets of 3 points, and adding an arc through three points at a time. I tried this on the three points on the LE with variable results, depending on x step size.

L.

"Keep in mind that neither success nor failure is ever final." -Roger Babson
 
[/quote]

Guess I was  confusing the NACA airfoil equation with something else.  Xfoil(I think), Profili, and most of the CAD programs I've used generate an airfoil shape with more points in the areas with high curvature automatically.  This would be taking either the program output(Xfoil and Profili) or converting a spline to a polyline in a CAD program.
phil Cartier

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #11 on: July 30, 2009, 10:37:11 AM »
Here's how to do it manually with a CAD programL

 Input a contour (DXF file, typically) with a lot of points, for a faithful shape. Use a DIVIDE function (in AutoCAD, most CAD programs have the capability), for a much smaller number of points - say 200. This will place POINT enties at equal spaces. Then delete the polyline contour, leaving the points. Finally, draw a new polyline, point by point, through the evenly spaced points.

I haven't looked at Xfoil or Profili for some time, can either do diagonal ribs?

L.

"A careful driver is one who honks his horn when he goes through a red light." -Henry Morgan
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
It seems like it should be so simple..
« Reply #12 on: August 18, 2009, 07:54:04 PM »
In general, I have my contour function y = F(x).

Given an x, I can solve it for a y value. I now have a point on the contour (x,y).

I can easily define the equation for a circle with center point at (x,y) and radius R.
Points (X,Y) on the circle are given by (X-x)2 + (Y-y)2 = R2.

Now, why can't I easily just find a (generic) common solution for the circle and the
contour function, which would have intersections at two points, defining my "equal
spaced" points on the contour?

I realize that what I've suggested, allowing each point to seek the next point at an
equal distance from it, adjusting and converging, is achieving the same thing with an
iterative method. But it seems I should simply be able to write some nice clean function
for the intersect points.

A real mathematician wouldn't have to resort to an iterative method..  ::)

Comments? Sorry to continue to beat a dead horse pulp.

L.

"Anyone who cannot cope with mathematics is not fully human. At best he is a
tolerable subhuman who has learned to wear shoes, bathe and not make messes in the
house." -- Robert A. Heinlein, Lazarus Long, Time Enough for Love
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..

Offline Larry Cunningham

  • Red Hot Lover
  • Trade Count: (0)
  • Captain
  • *****
  • Posts: 855
  • Klaatu barada nikto my ass
    • Stephanie Miller
Re: Best approach to equally spaced points on a contour
« Reply #13 on: September 02, 2009, 12:39:23 PM »
OK, it turns out that in almost every common case, arc length is best measured by numerical integration:

"In most cases, including even simple curves, there are no closed-form solutions of arc length and numerical integration is necessary." from http://en.wikipedia.org/wiki/Arc_length

So, solving the circle equation for X as f(Y) and plugging that in for X in the polynomial for the contour to find a closed-form solution is not going to be fruitful.

I think what I want boils down to calculating arc length by numerical integration, very accurately, using a fine x increment. Then, decide how many segments n I want, and divide the arc length L by n. L/n is then the length of each segment, and my iterative seeking of the next point, say using the same (or smaller) increment of x. Maybe the same increment of x would be better; my plan is to allow the last segment that I calculate to be whatever length is left. I'll know when I'm on the last segment when the distance from the last point to the end of the contour is less than or equal to the segment length I'm using.

I know I'm moving slowly on this silly little problem. I've got a dozen other irons in the fire and nothing is getting very hot. Z@@ZZZ

L.

"When you stop learning, stop listening, stop looking and asking questions, always new questions, then it is time to die." - Lillian Smith
AMA 247439 - '09, '10, '11, '12 and '13 Supporter of this site..


Advertise Here
Tags:
 


Advertise Here