static void convertLTMs(Frame* frame) { frame->LTM._13 *= -1; frame->LTM._23 *= -1; frame->LTM._33 *= -1; frame->LTM._43 *= -1; Vector at; D3DXVec3Cross( &at, &dxRight( &frame->LTM ), &dxUp( &frame->LTM ) ); frame->LTM._31 = at.x, frame->LTM._32 = at.y, frame->LTM._33 = at.z; if( frame->pFrameSibling ) convertLTMs( static_cast<Frame*>( frame->pFrameSibling ) ); if( frame->pFrameFirstChild ) convertLTMs( static_cast<Frame*>( frame->pFrameFirstChild ) ); }
HRESULT CMayaManager::PerspectiveCamera_Synchronize() { MDagPath MayaCamera; M3dView panel; for(UINT iView= 0; iView < M3dView::numberOf3dViews(); iView++) { D3DXMATRIX mCamera; M3dView::get3dView(iView, panel); panel.getCamera(MayaCamera); MayaCamera.pop(); MString perspNameStr( "persp" ); MString cameraNameStr = MayaCamera.partialPathName(); cameraNameStr = cameraNameStr.substring(0, perspNameStr.length()-1 ); const char* cameraName= cameraNameStr.asChar(); if(cameraNameStr == perspNameStr ) { MayaCamera.extendToShape(); MFloatMatrix fView(MayaCamera.inclusiveMatrix().matrix ); ConvertWorldMatrix(mCamera, fView); panel.getCamera(MayaCamera); MFnCamera fnMayaCamera(MayaCamera.node()); MVector mUp= fnMayaCamera.upDirection(); MVector mAt= fnMayaCamera.viewDirection(); MPoint mEye= fnMayaCamera.eyePoint(MSpace::kWorld); D3DXVECTOR3 dxEye( (float)mEye.x, (float)mEye.y, (float)-mEye.z ); D3DXVECTOR3 dxAt( (float)mAt.x, (float)mAt.y, (float)-mAt.z ); D3DXVECTOR3 dxUp( (float)mUp.x, (float)mUp.y, (float)-mUp.z ); D3DXVECTOR4 fEye; D3DXVECTOR4 fAt; D3DXVECTOR3 fUp; D3DXVec3Transform(&fEye, &dxEye,(D3DXMATRIX*)&mCamera); D3DXVec3Transform(&fAt, &dxAt,(D3DXMATRIX*)&mCamera); D3DXVec3TransformNormal(&fUp, &dxUp,(D3DXMATRIX*)&mCamera); D3DXMatrixLookAtLH(&PerspectiveCamera_View, (D3DXVECTOR3*)&fEye, (D3DXVECTOR3*)&fAt, &fUp); // Projection matrix float zNear = (float)fnMayaCamera.nearClippingPlane(); float zFar = (float)fnMayaCamera.farClippingPlane(); float hFOV = (float)fnMayaCamera.horizontalFieldOfView(); float f = (float) (1.0f / (float) tan( hFOV / 2.0f )); ZeroMemory( &PerspectiveCamera_Projection, sizeof(PerspectiveCamera_Projection) ); PerspectiveCamera_Projection._11 = f; PerspectiveCamera_Projection._22 = f; PerspectiveCamera_Projection._33 = (zFar+zNear) / (zFar-zNear); PerspectiveCamera_Projection._34 = 1.0f; PerspectiveCamera_Projection._43 = -2 * (zFar*zNear)/(zFar-zNear); break; } } return S_OK; }
Vector3f Frame::getUp(void) { if( isDirty() ) synchronizeSafe(); return wrap( dxUp( <M ) ); }
TGraphAsymmErrors* getEfficiency(const TH1* histogram_numerator, const TH1* histogram_denominator) { Int_t error = 0; if ( !(histogram_numerator->GetNbinsX() == histogram_denominator->GetNbinsX()) ) error = 1; if ( !(histogram_numerator->GetXaxis()->GetXmin() == histogram_denominator->GetXaxis()->GetXmin()) ) error = 1; if ( !(histogram_numerator->GetXaxis()->GetXmax() == histogram_denominator->GetXaxis()->GetXmax()) ) error = 1; if ( error ){ std::cerr << "Error in <getEfficiency>: Dimensionality of histograms does not match !!" << std::endl; return 0; } TAxis* xAxis = histogram_numerator->GetXaxis(); Int_t nBins = xAxis->GetNbins(); TArrayF x(nBins); TArrayF dxUp(nBins); TArrayF dxDown(nBins); TArrayF y(nBins); TArrayF dyUp(nBins); TArrayF dyDown(nBins); for ( Int_t ibin = 1; ibin <= nBins; ibin++ ){ Int_t nObs = TMath::Nint(histogram_denominator->GetBinContent(ibin)); Int_t rObs = TMath::Nint(histogram_numerator->GetBinContent(ibin)); Float_t xCenter = histogram_denominator->GetBinCenter(ibin); Float_t xWidth = histogram_denominator->GetBinWidth(ibin); x[ibin - 1] = xCenter; dxUp[ibin - 1] = 0.5*xWidth; dxDown[ibin - 1] = 0.5*xWidth; if ( nObs > 0 ){ Float_t rMin = 0.; Float_t rMax = 0.; getBinomialBounds(nObs, rObs, rMin, rMax); y[ibin - 1] = rObs/((Float_t)nObs); dyUp[ibin - 1] = (rMax - rObs)/((Float_t)nObs); dyDown[ibin - 1] = (rObs - rMin)/((Float_t)nObs); } else{ y[ibin - 1] = 0.; dyUp[ibin - 1] = 0.; dyDown[ibin - 1] = 0.; } } TString name = TString(histogram_numerator->GetName()).Append("Graph"); TString title = histogram_numerator->GetTitle(); TGraphAsymmErrors* graph = new TGraphAsymmErrors(nBins, x.GetArray(), y.GetArray(), dxDown.GetArray(), dxUp.GetArray(), dyDown.GetArray(), dyUp.GetArray()); graph->SetName(name); graph->SetTitle(title); return graph; }