We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Bending Moment Diagrams
Page Index Toggle Pages: 1
Bending Moment Diagrams (Read 2062 times)
Bending Moment Diagrams
Mar 26th, 2009, 11:18am
 
I am kinda new to processing and am looking to write a simple program to draws the shear and bending moment diagrams for a beam.

The user can input parameters such as:

- Length of Beam
- Location of Loads
- Magnitude of those loads
- The Material of the Beam

The output of the programs is:

- The shear force and bending moment diagrams
- The deflection shape of the beam

---------------------------------------------------------------

Do I need a special library to create various fields for user input and store the input for calculation?

If so which one do you recommend?

Re: Bending Moment Diagrams
Reply #1 - Mar 26th, 2009, 12:04pm
 
Search GUI in the Libraries page. I think controlP5 is the most popular (perhaps the only one, since SpringGUI seems no longer supported).
Re: Bending Moment Diagrams
Reply #2 - Mar 26th, 2009, 11:43pm
 
I know I may be getting way ahead of myself but I plan to include an image recognition system which allows the user to first draw their own shear and moment diagrams.  The sketched diagrams is then compared with the actual answer diagrams to see if the user has drawn the diagrams correctly.

Can anybody give me some advice as to how this can be done?  

Thanks you
Re: Bending Moment Diagrams
Reply #3 - Mar 27th, 2009, 9:53am
 
Wow.  That's going to be a hard problem.  Here's how I'd go about it:

First, I'd forget about any kind of standard image analysis.  I think that will be very difficult to implement, and not very robust to the question you're really trying to answer, which is "does the student understand bending moments well enough to intuitively draw a graph that's basically correct?"

Given that you're really trying to answer that question, and given that the answer relates back to the underlying math of bending moments (which I won't, for a moment, claim to understand), I would try to analyze the user's drawing to extract from it the constants and coefficients that plug into the bending moment formula.  You can then compare those to the "known" constants and coefficients that your program selected in constructing the problem, and see if they're "close enough".

To take a simpler example, let's say instead of bending moments we were working with projectile motion (parabolic arcs).  The student would read a story problem or whatever, and draw their version of the projectile's path.  Presumably we'd give them a grid to draw against, so that questions of scale and such were not an issue.  Then we'd run a least-squares estimation against the formula:

y = y0 + (x^2 * g*sec(theta)) / 2*v0^2 + x*tan(theta)

Basically, for every x value on the graph, we measure the student's y value, and use least-squares to find the constants y0, theta, v0 that best fits the graph.  We know the exact, "correct" values of those constants from whatever the original problem statement was, and can then determine whether the drawing was close enough to correct that we can infer that the student understands the material.

In your case, you'll do the same thing but with a different formula--the bending moment formula--looking for whatever constants and coefficients that formula uses..  
Re: Bending Moment Diagrams
Reply #4 - Mar 28th, 2009, 11:50pm
 
thanks for the reply Cloister

That does seem like a much more robust solution and its probably what im going to do now.  I assume that you will need to scan the sketched graph and somehow detect the color pixels and convert this to y values.  This is then compared with the actual values from calculation.  

As some sections of the diagram are potentially parabolic , one problem would be how tolerant should the comparison be?  There are key points in the diagram where there wont be any problems, it is the  span between these key points that i am worried about
Re: Bending Moment Diagrams
Reply #5 - Mar 29th, 2009, 3:54pm
 
I am trying to use controlp5 now but can anybody tell me if its possible to add tabs where the name labels of the tabs are replaced by imagebButton?

For example, the code below produce tabs named "something" and "extra", but i want to use imageButtons to replace those tab names.  Is it possible to do that?
Code:

import controlP5.*;


ControlP5 controlP5;

int myColorBackground = color(0,0,0);

int sliderValue = 100;

void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
controlP5.addButton("button",10,100,80,80,20);
controlP5.addButton("buttonValue",4,100,110,80,20);
controlP5.addSlider("sliderValue",0,255,128,100,200,10,100);
controlP5.addSlider("slider",100,200,128,100,160,100,10);
controlP5.controller("slider").moveTo("global");
controlP5.controller("sliderValue").moveTo("extra");
controlP5.tab("extra").setColorForeground(0xffff0000);
controlP5.tab("extra").setColorBackground(0xff330000);

controlP5.trigger();

// in case you want to receive a controlEvent when
// a tab is clicked, use activeEvent(true)
controlP5.tab("extra").activateEvent(true);
controlP5.tab("extra").setId(2);

controlP5.tab("default").activateEvent(true);
// to rename the label of a tab, use setLabe("..."),
// the name of the tab will remain as given when initialized.
controlP5.tab("default").setLabel("something");
controlP5.tab("default").setId(1);
}

void draw() {
background(myColorBackground);
fill(sliderValue);
rect(0,0,width,100);
}

void slider(int theColor) {
myColorBackground = color(theColor);
println("a slider event. setting background to "+theColor);
}

void controlEvent(ControlEvent theControlEvent) {
if(theControlEvent.isController()) {
println("controller : "+theControlEvent.controller().id());
} else if (theControlEvent.isTab()) {
println("tab : "+theControlEvent.tab().id()+" / "+theControlEvent.tab().name());
}
}



any help would be appreciated
Re: Bending Moment Diagrams
Reply #6 - Mar 30th, 2009, 10:30am
 
You could scan the sketch and attempt to recover the drawing from the measured pixel colors, but oh, what a drag.  With a scan of a physical drawing, you're going to have additional headaches of accounting for any rotation in the scan (i.e. the drawing not being perfectly lined up with the scanner bed), as well as detecting the region of the drawing inside the scan, et cetera.

I was thinking that the program itself would have a mode where the user draws the graph into the window.  That way, you can draw the coordinate axes and a reference grid for them, you can know exactly what the scale factors are and so forth, and rather than having to _detect_ their drawing, you can simply _record_ the pixel positions of their drawing while they draw it, and convert those in a very straightforward way to mathematical coordinates within the graph.

If you're implementing this on a touch-sensitive screen like a tablet PC or whatever, then you can still give the user a nice drawing experience (because really, who can draw anything with even vague accuracy using a mouse?  I sure can't.), while avoiding all the headaches of having to deal with a scanned image.

As for how tight the comparison needs to be, well, you'll have to experiment to see what works well.  Try it a bunch of times yourself, with drawings that you would judge to be correct as well as ones that you intentionally get wrong, and fiddle with the flexibility of the comparison until it does a decent job of classifying the right-drawings from the wrong-drawings.

Or, I suppose, if you want to get really fancy you could implement some sort of neural net to automatically learn the tuning parameters.  :)
Page Index Toggle Pages: 1