MFC检查透镜质量程序
生活随笔
收集整理的這篇文章主要介紹了
MFC检查透镜质量程序
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
題目:
某光學(xué)儀器廠生產(chǎn)一種系列透鏡,這種透鏡系列包括凸透鏡、凹透鏡及平面透鏡。該廠檢驗科采用的檢驗方法是:通過該透鏡的體積、密度,算出質(zhì)量,再用天平稱量透鏡的實際質(zhì)量,根據(jù)質(zhì)量差評估該透鏡是否合格。因此需要設(shè)計一個小軟件工具,來計算透鏡質(zhì)量。
可測量的數(shù)據(jù)包括:鏡柱的高H、鏡柱的半徑R、凸透球缺或凹透球缺的球半徑r以及透鏡的密度ρ,而球卻的底面半徑等于鏡柱的半徑。
void CCheckLensDlg::OnBUTTON1Count() {// TODO: Add your control notification handler code herechar c_BallRadius[255], c_CylinderRadius[255], c_CylinderHeight[255], c_LensDensity[255], c_Result[255];double BallRadius=0, CylinderRadius=0, CylinderHeight=0, LensDensity=0,Result=0;double BallRadius1=0, CylinderRadius1=0, CylinderHeight1=0, LensDensity1=0,Result1=0;m_BallRadius.GetWindowText(c_BallRadius,10)/10;m_CylinderRadius.GetWindowText(c_CylinderRadius,10)/10;m_CylinderHeight.GetWindowText(c_CylinderHeight,10)/10;m_LensDensity.GetWindowText(c_LensDensity,10);BallRadius = atof((LPCTSTR)c_BallRadius);CylinderRadius = atof((LPCTSTR)c_CylinderRadius);CylinderHeight = atof((LPCTSTR)c_CylinderHeight);LensDensity = atof((LPCTSTR)c_LensDensity);const double PI=3.14;//計算球冠的高度double BallHeight = 0;BallHeight = BallRadius - sqrt(BallRadius * BallRadius - CylinderRadius * CylinderRadius);//計算圓柱的質(zhì)量double CylinderMassTemp = 0;CylinderMassTemp = PI * CylinderRadius * CylinderRadius * CylinderHeight * LensDensity;//計算球冠的質(zhì)量double BallMassTemp = 0;BallMassTemp = PI / 3 * (3*BallRadius - BallHeight) * BallHeight * BallHeight * LensDensity;switch(m_Control){case 0:if(BallRadius !=0 ){if(MessageBox("數(shù)據(jù)不合法,球冠半徑r應(yīng)為0,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp;break;case 1:if(BallRadius < CylinderRadius){if(MessageBox("球冠半徑r < R圓柱體半徑,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp + BallMassTemp;break;case 2:if(BallRadius < CylinderRadius){if(MessageBox("球冠半徑r < R圓柱體半徑,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp - BallMassTemp;break;case 3:if(BallRadius < CylinderRadius){if(MessageBox("球冠半徑r < R圓柱體半徑,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp + 2*BallMassTemp;break;case 4:if(BallRadius < CylinderRadius){if(MessageBox("球冠半徑r < R圓柱體半徑,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp - 2*BallMassTemp;break;case 5:if(BallRadius < CylinderRadius){if(MessageBox("球冠半徑r < R圓柱體半徑,請重新輸入!","消息提示",MB_ICONWARNING|MB_OK)==IDOK)OnBUTTON2Clean();}elseResult = CylinderMassTemp;break;}_gcvt(Result,20,c_Result);m_Result=(LPCTSTR)c_Result;UpdateData(FALSE);}
轉(zhuǎn)載于:https://blog.51cto.com/fjwind/1204414
總結(jié)
以上是生活随笔為你收集整理的MFC检查透镜质量程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hibernate 统计记录总数方法汇总
- 下一篇: 一次项目管理交流会总结