colincaprani.com

Structural Engineering, Bridge Research, Programming, and more…

Entries Comments


The importance of units

21 October, 2011 (21:47) | General | No comments

There are some quite serious sites that point out the importance of units in engineering calculations, but a less serious result of an error is the guy who got the wrong slipper!

See the news report here.

Nonlinear beam behaviour example

3 October, 2011 (22:19) | General | No comments

This shows the deflection and bending moment history of a propped cantilever loaded with a point load at mid-span. The beam has a plastic moment capacity of 100 kNm and a shape factor of 1.12. A strain hardening modulus of 2% of the modulus of elasticity is used.

The model is based on that given in Advanced Analysis and Design of Steel Frames by Li and Li, Wiley 2007.

Getting properties from CMFCPropertyGridProperty

2 September, 2011 (02:15) | General | 1 comment

It’s been a while…but this is a good one – if it is what you need!

In Visual C++, the MFC Feature Pack gives the property grid control, but one of the questions regularly asked (see stackoverflow.com) is how to return properties once changes by the user. Part of the problem is the COLEVariant is the return type from the framework, but what if you want a double, or CString for example?

I bashed together a few different ideas and have a nice little functoid that essentially overloads the output type and so this can be used as an argument to your function. The references I used were

I defined the functoid in the header file for the CPropertiesWnd class (which contains the CMFCPropertyGridProperty control) as:

1
2
3
4
5
6
7
8
9
10
11
12
class getPropValue
{
public:
    getPropValue(CMFCPropertyGridProperty* pProp):m_pProp(pProp) {};
    operator CString()        {return (LPCTSTR)(_bstr_t)m_pProp->GetValue();}
    operator int()            {return m_pProp->GetValue().iVal;}
    operator unsigned int()   {return (unsigned int)m_pProp->GetValue().iVal;}
    operator double()         {return m_pProp->GetValue().dblVal;}
    operator bool()           {return m_pProp->GetValue().boolVal == VARIANT_TRUE;}
private:
    CMFCPropertyGridProperty* m_pProp;
};

An example call using this is then:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
LRESULT CPropertiesWnd::OnWindowPropertyChanged(WPARAM wparam, LPARAM lparam)
{
    CMFCPropertyGridProperty *pProp = (CMFCPropertyGridProperty*)lparam;
    if (!pProp) return 0;
    CMyView* pView = getActiveView();  // Helper function uses CMainframe
    const int id = (int)pProp->GetData();  // storing property id as a DWORD using SetData
    switch(id)
    {
    case idWindow_OverallScale:
        pView->setScale( getPropValue(pProp) );    // double as an argument to func
        break;
    case idWindow_PenWidth:
        pView->setPenWidth( getPropValue(pProp) ); // int as an argument to func
        break;
    case idWindow_Title:
        pView->setTitle( getPropValue(pProp) );    // CString as an argument to func
        break;
    }
}

There you have it – it could be exactly what you need, or maybe not!

TLCD Video Analysis using Matlab

19 February, 2011 (00:40) | Engineering, Programming, Research | No comments

To measure the liquid heights in a Tuned Liquid Column Damper, either very expensive wave bob metres are needed, or the researcher can go through video image frame by frame estimating the height of the liquid columns from a scale attached to the TLCD. To avoid this laborious task, and to increase the number of experiments we can do, I developed a video analysis toolkit that processes the image automatically for the liquid heights. Here’s a video of the analysis:

The output can be converted to time and length (in mm say) using the rulers to get a scale (mm per pixel say) and the frame rate of the video. The ‘redness’ of the liquid is the key here: the video is split into RGB and the red channel isolated and converted to black and white once a filter is applied. This image is then scrubbed to get rid of any objects smaller than a threshold size, leaving only the liquid of the column. The image is then split in two at the centre of the bounding box to analyze each column separately. Since a black and white image is represented by a matrix of 1 and 0s, summing the columns of the matrix (ie the vertical direction) gives the column height in pixels. A few other adjustments are needed, but that’s the basic idea.

Build a 15-storey Hotel in 6 days? No Problem!

8 February, 2011 (00:29) | General | No comments

Well worth a look for the prefabrication and impeccable logistical planning evident from the video. But it’s not that new…the Empire State Building took 18 months in total!

« Older entries

 Newer entries »