void BlenderTexture3D::GetDuv(const SpectrumWavelengths &sw, const DifferentialGeometry &dg, float delta, float *du, float *dv) const { // Calculate values at intersection point (copy of Evaluate) Vector dpdu, dpdv; const Point P(mapping->MapDuv(dg, &dpdu, &dpdv)); const float a = GetF(P); const float e = tex2->Evaluate(sw, dg) - tex1->Evaluate(sw, dg); float du1, dv1, du2, dv2; tex1->GetDuv(sw, dg, delta, &du1, &dv1); tex2->GetDuv(sw, dg, delta, &du2, &dv2); // Compute offset positions and evaluate displacement texture // Shift _P_ _du_ in the $u$ direction and calculate value const float uu = delta / dg.dpdu.Length(); const Point Pu(P + dg.dpdu * uu); const float dau = (GetF(Pu) - a) / uu; // Shift _dgTemp_ _dv_ in the $v$ direction and calculate value const float vv = delta / dg.dpdv.Length(); const Point Pv(P + dg.dpdv * vv); const float dav = (GetF(Pv) - a) / vv; *du = Lerp(a, du1, du2) + dau * e; *dv = Lerp(a, dv1, dv2) + dav * e; }
void LowessParamFrame::UpdateParamsFromFields() { wxLogMessage("Entering LowessParamFrame::UpdateParamsFromFields"); Lowess temp_l(GetF(), GetIter(), GetDeltaFactor()); { wxString s = f_text->GetValue(); double v; if (s.ToDouble(&v)) temp_l.SetF(v); f = temp_l.GetF(); wxString sf = wxString::Format("%f", GetF()); f_text->ChangeValue(sf); } { wxString s = iter_text->GetValue(); long v; if (s.ToLong(&v)) temp_l.SetIter((long) v); iter = temp_l.GetIter(); wxString sf = wxString::Format("%d", GetIter()); iter_text->ChangeValue(sf); } { wxString s = delta_factor_text->GetValue(); double v; if (s.ToDouble(&v)) temp_l.SetDeltaFactor(v); delta_factor = temp_l.GetDeltaFactor(); wxString sf = wxString::Format("%.4f", GetDeltaFactor()); delta_factor_text->ChangeValue(sf); } wxLogMessage("Exiting LowessParamFrame::UpdateParamsFromFields"); }
wxSVGMatrix wxSVGMatrix::Inverse() const { wxSVGMatrix res; double d = 1.0 / (GetA() * GetD() - GetB() * GetC()); res.SetA(GetD() * d); res.SetB(-GetB() * d); res.SetC(-GetC() * d); res.SetD(GetA() * d); res.SetE(-GetE() * res.GetA() - GetF() * res.GetC()); res.SetF(-GetE() * res.GetB() - GetF() * res.GetD()); return res; }
int compare(const char* filename){ classWithComplex cref(1,2,3,4); classWithComplex ccref(11,22,33,44); auto f = TFile::Open(filename); auto c = (classWithComplex*)f->Get("classWithComplex1"); auto cc = (classWithComplex*)f->Get("classWithComplex2"); if (*c != cref && *cc != ccref){ cout << "ERROR The objects on file differ from the references!\n" << cref.GetF() << ", " << cref.GetD() << " vs onfile " << c->GetF() << ", " << c->GetD() << endl << ccref.GetF() << ", " << ccref.GetD() << " vs onfile " << cc->GetF() << ", " << cc->GetD() << endl; return 1; } return 0; }
wxSVGMatrix wxSVGMatrix::Multiply(const wxSVGMatrix& secondMatrix) const { wxSVGMatrix res; res.SetA(GetA() * secondMatrix.GetA() + GetC() * secondMatrix.GetB()); res.SetB(GetB() * secondMatrix.GetA() + GetD() * secondMatrix.GetB()); res.SetC(GetA() * secondMatrix.GetC() + GetC() * secondMatrix.GetD()); res.SetD(GetB() * secondMatrix.GetC() + GetD() * secondMatrix.GetD()); res.SetE(GetA() * secondMatrix.GetE() + GetC() * secondMatrix.GetF() + GetE()); res.SetF(GetB() * secondMatrix.GetE() + GetD() * secondMatrix.GetF() + GetF()); return res; }
void LowessParamFrame::OnResetDefaultsBtn(wxCommandEvent& ev) { wxLogMessage("In LowessParamFrame::OnResetDefaultsBtn"); f = Lowess::default_f; iter = Lowess::default_iter; delta_factor = Lowess::default_delta_factor; f_text->ChangeValue(wxString::Format("%f", GetF())); iter_text->ChangeValue(wxString::Format("%d", GetIter())); delta_factor_text->ChangeValue(wxString::Format("%f", GetDeltaFactor())); OnApplyBtn(ev); }
void PIDController::InitTable(std::shared_ptr<ITable> table) { if (m_table != nullptr) m_table->RemoveTableListener(this); m_table = table; if (m_table != nullptr) { m_table->PutNumber(kP, GetP()); m_table->PutNumber(kI, GetI()); m_table->PutNumber(kD, GetD()); m_table->PutNumber(kF, GetF()); m_table->PutNumber(kSetpoint, GetSetpoint()); m_table->PutBoolean(kEnabled, IsEnabled()); m_table->AddTableListener(this, false); } }
LowessParamFrame::LowessParamFrame(double f, int iter, double delta_factor, Project* project_) : wxFrame((wxWindow*) 0, wxID_ANY, _("LOWESS Smoother Parameters"), wxDefaultPosition, wxSize(400, -1), wxDEFAULT_FRAME_STYLE), LowessParamObservable(f, iter, delta_factor), project(project_) { wxLogMessage("Entering LowessParamFrame::LowessParamFrame"); wxPanel* panel = new wxPanel(this); panel->SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE); wxButton* help_btn = new wxButton(panel, XRCID("ID_HELP_BTN"), _("Help"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxButton* apply_btn = new wxButton(panel, XRCID("ID_APPLY_BTN"), _("Apply"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxButton* reset_defaults_btn = new wxButton(panel, XRCID("ID_RESET_DEFAULTS_BTN"), _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxStaticText* f_stat_t = new wxStaticText(panel, wxID_ANY, _("Bandwidth:")); f_text = new wxTextCtrl(panel, XRCID("ID_F_TEXT"), wxString::Format("%f", GetF()), wxDefaultPosition, wxSize(100, -1), wxTE_PROCESS_ENTER); f_text->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); Connect(XRCID("ID_F_TEXT"), wxEVT_TEXT, wxCommandEventHandler(LowessParamFrame::OnFTextChange)); Connect(XRCID("ID_F_TEXT"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(LowessParamFrame::OnApplyBtn)); wxStaticText* iter_stat_t = new wxStaticText(panel, wxID_ANY, _("Iterations:")); iter_text = new wxTextCtrl(panel, XRCID("ID_ITER_TEXT"), wxString::Format("%d", GetIter()), wxDefaultPosition, wxSize(100, -1), wxTE_PROCESS_ENTER); iter_text->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); Connect(XRCID("ID_ITER_TEXT"), wxEVT_TEXT, wxCommandEventHandler(LowessParamFrame::OnIterTextChange)); Connect(XRCID("ID_ITER_TEXT"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(LowessParamFrame::OnApplyBtn)); wxStaticText* delta_factor_stat_t = new wxStaticText(panel, wxID_ANY, _("Delta Factor:")); delta_factor_text = new wxTextCtrl(panel, XRCID("ID_DELTA_FACTOR_TEXT"), wxString::Format("%.4f", GetDeltaFactor()), wxDefaultPosition, wxSize(100, -1), wxTE_PROCESS_ENTER); delta_factor_text->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); Connect(XRCID("ID_DELTA_FACTOR_TEXT"), wxEVT_TEXT, wxCommandEventHandler(LowessParamFrame::OnDeltaFactorTextChange)); Connect(XRCID("ID_DELTA_FACTOR_TEXT"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(LowessParamFrame::OnApplyBtn)); Connect(XRCID("ID_HELP_BTN"), wxEVT_BUTTON, wxCommandEventHandler(LowessParamFrame::OnHelpBtn)); Connect(XRCID("ID_APPLY_BTN"), wxEVT_BUTTON, wxCommandEventHandler(LowessParamFrame::OnApplyBtn)); Connect(XRCID("ID_RESET_DEFAULTS_BTN"), wxEVT_BUTTON, wxCommandEventHandler(LowessParamFrame::OnResetDefaultsBtn)); // Arrange above widgets in panel using sizers. // Top level panel sizer will be panel_h_szr // Below that will be panel_v_szr // panel_v_szr will directly receive widgets wxFlexGridSizer* fg_sizer = new wxFlexGridSizer(3, 2, 3, 3); fg_sizer->Add(f_stat_t, 0, wxALIGN_CENTRE_VERTICAL | wxALIGN_RIGHT); fg_sizer->Add(f_text, 0, wxALIGN_CENTRE_VERTICAL); fg_sizer->Add(iter_stat_t, 0, wxALIGN_CENTRE_VERTICAL | wxALIGN_RIGHT); fg_sizer->Add(iter_text, 0, wxALIGN_CENTRE_VERTICAL); fg_sizer->Add(delta_factor_stat_t, 0, wxALIGN_CENTRE_VERTICAL|wxALIGN_RIGHT); fg_sizer->Add(delta_factor_text, 0, wxALIGN_CENTRE_VERTICAL); wxBoxSizer* btns_row1_h_szr = new wxBoxSizer(wxHORIZONTAL); btns_row1_h_szr->Add(help_btn, 0, wxALIGN_CENTER_VERTICAL); btns_row1_h_szr->AddSpacer(8); btns_row1_h_szr->Add(reset_defaults_btn, 0, wxALIGN_CENTER_VERTICAL); btns_row1_h_szr->AddSpacer(8); btns_row1_h_szr->Add(apply_btn, 0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* panel_v_szr = new wxBoxSizer(wxVERTICAL); panel_v_szr->Add(fg_sizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(2); panel_v_szr->Add(btns_row1_h_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* panel_h_szr = new wxBoxSizer(wxHORIZONTAL); panel_h_szr->Add(panel_v_szr, 1, wxEXPAND); panel->SetSizer(panel_h_szr); // Top Sizer for Frame wxBoxSizer* top_h_sizer = new wxBoxSizer(wxHORIZONTAL); top_h_sizer->Add(panel, 1, wxEXPAND|wxALL, 8); SetSizerAndFit(top_h_sizer); Show(true); wxLogMessage("Exiting LowessParamFrame::LowessParamFrame"); }