Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

2D CG calculator?

Status
Not open for further replies.

HgTX

Civil/Environmental
Aug 3, 2004
3,722
Is there a cheap CG calculator out there for complex shapes (with curves & re-entrant portions)?

This would have to be a 2-step process:
1. Input shape. Ideally by scanning something hand-drawn.
2. Calculate location of CG.

I think major CAD and design programs will do this, but is there anything small out there that does just this?

Back when I was smarter, I could have written #2, but I'm not that smart any more.

Hg

Eng-Tips policies: faq731-376
 
Replies continue below

Recommended for you

There may be some image processing application that could take in a photograph, binarize the shape, and calculate the centroid.

TTFN

FAQ731-376
 
Similar to IRstuff's thinking. If you can get the sketch/drawing into CAD, which should be possible you can then use the CAD to find the centroid.

There are free 2D packages though I'm not sure they include this kind of thing or just the basic drawing.

If the scanner thing defeats you, for relatively simple parts you could import the image into the CAD and trace over it.

Posting guidelines faq731-376 (probably not aimed specifically at you)
What is Engineering anyway: faq1088-1484
 
In short, no I haven't seen a simple app to do that.

The simplest way is to cut your section out of card and then hang it from several points. The cg is always directly below the point of suspension.

But you knew that.

You can digitize a curve very nicely with the enigmatically named, excellent, and free, "Digitize it! 2004".

But that is only half the battle. A table of coordinates has no area properties in itself, as you have to know what is inside and what is outside the section.

The obvious thing to do is to flood fill the shape defined by those points and then take a first moment in x and y to give the cg location, but that needs programming.

The way I'd do it would be as follows

Draw a boundary outside the shape.

for each pixel inside the boundary draw a line between the boundary and the pixel. If it cuts the section's outline an odd number of times it is inside the section.

Another way would be to split the shape up into triangles, but again you have the problem of deciding whether a triangle has positive or negative area.


Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Once the coordinates of the shape are available it is easy to get the area properties. There are a number of free programs that will do it, including:

Theory and spreadsheet solution:

Excel UDF

Excel macro and section property formulas for defined shapes:



Doug Jenkins
Interactive Design Services
 
You can digitize a curve very nicely with the enigmatically named, excellent, and free, "Digitize it! 2004".

Thanks for that Greg, but

When I run it I get a message that Grid32.ocx is not installed or properly registered (Vista with Service Pack 2). I have copied Grid32.ocx to the Windows/System32 directory, but still no good.

Any ideas?

For others looking for the download:

I think it should not have the "!". Digitizeit! is a video digitising program.

There is also a program called DigitizeIt 1.5, which is free to download, but is cripple-ware with a 20 day trial period (about $50 to register I think).


I think I might write my own digitizing program in Excel :)

Doug Jenkins
Interactive Design Services
 
I have attached an Excel spreadsheet with a User Defined Function call DigitGraph which will extract coordinates from a polyline traced over an imported image of a graph, or any other shape. The coordinates can then be used with the spreadsheets posted earlier to find shape properties of closed shapes.

Obviously any output should be given a careful sanity check before you rely on it.

Any questions or comments, please let me know.

Doug Jenkins
Interactive Design Services
 
The file I posted yesterday gives the wrong answers.

I copied and pasted the "Axes" rectangle, to show what it looks like, and forgot that the copied object has the same name as the original, so the function reads the size and the position of the little sample box, rather than the correct one.

Corrected spreadsheet attached.

Doug Jenkins
Interactive Design Services
 
Thanks! I'll play with this & see what I get.

Hg

Eng-Tips policies: faq731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor