/* check if (m_skin_filter != 0 && m_skin_filter->status() == 0) before call */ void HaarDetector::skin_filter(char** r, char** g, char** b, const vec2Di* search_mask) { float ivec[3] = {0.0f, 0.0f, 0.0f}; //0.0 ... 1.0f range float ovec = 0.0f; m_search_mask->set(0); unsigned int skin_pixels = 0; unsigned int total_pixels = 0; for (unsigned int y = dy(); y < m_search_mask->height() - dy(); y++) { for (unsigned int x = dx(); x < m_search_mask->width() - dx(); x++) { total_pixels++; if (search_mask != 0 && ((*search_mask)(y, x) == 0)) continue; ivec[0] = (float)((int)r[y][x] + 128) / 255.0f; ivec[1] = (float)((int)g[y][x] + 128) / 255.0f; ivec[2] = (float)((int)b[y][x] + 128) / 255.0f; if (m_skin_filter->classify(ivec, &ovec) >= 0) { (*m_search_mask)(y, x) = 1; skin_pixels++; } } } m_skin_amount = float(skin_pixels) / float(total_pixels); m_tmp_search_mask->dilate(*m_search_mask, 5, 5); m_search_mask->erode(*m_tmp_search_mask, 5, 5); }
STKUNIT_UNIT_TEST(function, stringFunction_derivative) { EXCEPTWATCH; for (unsigned ipts = 0; ipts < NPTS; ipts++) { double x = testpoints[ipts][0]; double y = testpoints[ipts][1]; double z = testpoints[ipts][2]; double t = testpoints[ipts][3]; // start_demo_stringFunction_derivative StringFunction sfxy(" x - y "); StringFunction dsfxy_y("-1"); MDArrayString dy(1,1); dy(0,0)="y"; std::string dy1[1][1] = {{"y"}}; std::cout << "dy1= " << dy1[0][0] << std::endl; //Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative(MDArrayString_from(dy1)); //Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative(dy); Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative_test(dy); double dvxy = eval(x, y, z, t, *dsfxy_y_1); double dvxy1 = eval(x, y, z, t, dsfxy_y); // the two different functions should give the same result STKUNIT_EXPECT_DOUBLE_EQ(dvxy, dvxy1); // and they should give the same result as C++ STKUNIT_EXPECT_DOUBLE_EQ(dvxy, -1.0); // end_demo } }
int main() { const int NN = 5; const int NNN = 5000; double C = 2.2; for (double k = -C; k < C; k += (0.1 * C)) { double x_0 = C; double y_0 = k; double x = x_0; double y = y_0; double c = 0.003; c *= fabs(alpha) / alpha; printf("draw (%1.4lf*u, %1.4lf*u)\n", x, y); for (int i = 0; i < NNN; i++) { double ddx = dx(x, y); double ddy = dy(x, y); double len = l(ddx, ddy); x += ddx * c; y += ddy * c; if (!(i % NN)) printf("--(%1.4lf*u, %1.4lf*u)\n", x, y); if (l2(x, y) > 300) { printf("unstable point! \n"); return -1; } } printf("withpen pencircle scaled 1pt;\n"); } for (double k = -C; k < C; k += (0.1 * C)) { double x_0 = k; double y_0 = -C; double x = x_0; double y = y_0; double c = 0.003; c *= fabs(alpha) / alpha; printf("draw (%1.4lf*u, %1.4lf*u)\n", x, y); for (int i = 0; i < NNN; i++) { double ddx = dx(x, y); double ddy = dy(x, y); double len = l(ddx, ddy); x += ddx * c; y += ddy * c; if (!(i % NN)) printf("--(%1.4lf*u, %1.4lf*u)\n", x, y); if (l2(x, y) > 300) { printf("unstable point! \n"); return -1; } } printf("withpen pencircle scaled 1pt;\n"); } return 0; }
double MQ_2::laplace(double x, double y) { double result = 0; for (int i = 0; i < _data.size() / 4; i++) { result += 2.0 * w(i) / core(i, x, y) \ - w(i) * (dx(i, x) * dx(i, x) + dy(i, y) * dy(i, y)) / pow(core(i, x, y), 3); } return result; }
void drawSlider(float y,float value,bool glow,const char *str) { float width = .18; float height = .05; float x5 = dx(.5); float x65 = dx(.5+width); float xlerp = dx(lerp(.5,.5+width,value)); float y05 = dy(y+height); al_draw_filled_triangle(x5,y05,x65,y05,x65,dy(y),COLOR_SCND); al_draw_filled_triangle(x5,y05,xlerp,y05,xlerp,dy(lerp(y+height,y,value)),glow?COLOR_HGHL:COLOR_TEXT); al_draw_text(data.font_Regular52,glow?COLOR_HGHL:COLOR_TEXT,px(.49),py(y),ALLEGRO_ALIGN_RIGHT,str); }
/** * Solve the following KKT system (2.10) of [AHO98]: * * [ 0 A^T I ] [ dsx ] = [ rd ] * [ A 0 0 ] [ dy ] = [ rp ] * [ E 0 F ] [ dsz ] = [ rc ] * \---- M ----/ * * where * * A = [ Asparse ] * [ Adense ] * dy = [ dysparse dydense ] * E = Z sym I * F = X sym I * */ static inline void SolveKKTSystem(const arma::sp_mat& Asparse, const arma::mat& Adense, const arma::mat& Z, const arma::mat& M, const arma::mat& F, const arma::vec& rp, const arma::vec& rd, const arma::vec& rc, arma::vec& dsx, arma::vec& dysparse, arma::vec& dydense, arma::vec& dsz) { arma::mat Frd_rc_Mat, Einv_Frd_rc_Mat, Einv_Frd_ATdy_rc_Mat, Frd_ATdy_rc_Mat; arma::vec Einv_Frd_rc, Einv_Frd_ATdy_rc, dy; // Note: Whenever a formula calls for E^(-1) v for some v, we solve Lyapunov // equations instead of forming an explicit inverse. // Compute the RHS of (2.12) math::Smat(F * rd - rc, Frd_rc_Mat); SolveLyapunov(Einv_Frd_rc_Mat, Z, 2. * Frd_rc_Mat); math::Svec(Einv_Frd_rc_Mat, Einv_Frd_rc); arma::vec rhs = rp; const size_t numConstraints = Asparse.n_rows + Adense.n_rows; if (Asparse.n_rows) rhs(arma::span(0, Asparse.n_rows - 1)) += Asparse * Einv_Frd_rc; if (Adense.n_rows) rhs(arma::span(Asparse.n_rows, numConstraints - 1)) += Adense * Einv_Frd_rc; // TODO(stephentu): use a more efficient method (e.g. LU decomposition) if (!arma::solve(dy, M, rhs)) Log::Fatal << "PrimalDualSolver::SolveKKTSystem(): Could not solve KKT " << "system." << std::endl; if (Asparse.n_rows) dysparse = dy(arma::span(0, Asparse.n_rows - 1)); if (Adense.n_rows) dydense = dy(arma::span(Asparse.n_rows, numConstraints - 1)); // Compute dx from (2.13) math::Smat(F * (rd - Asparse.t() * dysparse - Adense.t() * dydense) - rc, Frd_ATdy_rc_Mat); SolveLyapunov(Einv_Frd_ATdy_rc_Mat, Z, 2. * Frd_ATdy_rc_Mat); math::Svec(Einv_Frd_ATdy_rc_Mat, Einv_Frd_ATdy_rc); dsx = -Einv_Frd_ATdy_rc; // Compute dz from (2.14) dsz = rd - Asparse.t() * dysparse - Adense.t() * dydense; }
double GLGPU3DDataset::Flux(int face) const { // TODO: pre-compute the flux switch (face) { case 0: return -dx() * dy() * Bz(); case 1: return -dy() * dz() * Bx(); case 2: return -dz() * dx() * By(); case 3: return dx() * dy() * Bz(); case 4: return dy() * dz() * Bx(); case 5: return dz() * dx() * By(); default: assert(false); } return 0.0; }
int main() { float x0, y0, h; int j, m; //entrada de dados printf("Digite o valor de x inicial: \n"); scanf("%f", &x0); printf("Digite o valor de y inicial: \n"); scanf("%f", &y0); printf("Digite o valor do espacamente h: \n"); scanf("%f", &h); printf("Informe o numero de subintervalos : \n"); scanf("%d", &m); float x[m+1], y[m+1]; x[0] = x0; y[0] = y0; // Calculo pelo metodo de Euler for(j = 0; j < m; j++) { y[j+1] = y[j] + h*dy(x[j], y[j]); x[j+1] = x[j] + h; } // mostrando o resultado printf("Os valores de x e y sao: \n"); for(j = 0; j <= m; j++) { printf("%.4f, %.4f\n", x[j], y[j]); } return 0; }
void Graph::layoutKamadaKawai( int maxiter, qreal epsilon, bool initialize) { qDebug() << "Laying out KamadaKawai"; if( initialize ) layoutRandom( 100.0 ); //layoutNGon(); if(maxiter < 0) maxiter = 65536; for(int iteration = 0; iteration < maxiter; ++iteration) { uint id = 0; qreal maxdelta_m = 0.0; for(QMap<uint,Vertex*>::const_iterator i = m_vertices.constBegin(); i != m_vertices.constEnd(); ++i ) { qreal curdelta_m = qAbs(delta_m(*i)); //qDebug() << "curdelta_m,maxdelta_m"<< curdelta_m << "\t" << maxdelta_m; if( curdelta_m >= maxdelta_m ) { maxdelta_m = curdelta_m; id = (*i)->id(); } } Vertex *m = m_vertices.value(id); qreal curdx = dx(m); qreal curdy = dy(m); qDebug() << "Picked node with id=" << id <<", moving by" << QPointF(curdx,curdy) << " to "<< m->nodePos(); m->setNodePos( m->nodePos() + QPointF(curdx,curdy) ); if(qAbs(delta_m(m)) < epsilon ) { qDebug() << "Breaking early: iteration, delta_m, epsilon" << iteration << qAbs(delta_m(m)) << epsilon; break; } } }
void main() { IplImage* img; CvCapture* cap=cvCaptureFromCAM(0); cvNamedWindow("Line Counter", 1); CvFont* font1=new CvFont; CvFont* font2=new CvFont; cvInitFont(font1, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 3, 8); cvInitFont(font2, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 2, 8); int val=0, axx=0, bxx=0; char text[8]; for (;;) { img = cvQueryFrame(cap); if (!img) break; IplImage* gray1=cvCreateImage(cvSize(img->width, img->height), 8, 1); IplImage* edge1=cvCreateImage(cvSize(img->width, 16), 8, 1); cvCvtColor(img, gray1, 7); extract(gray1, edge1); dy(edge1, edge1); cvThreshold(edge1, edge1, 10, 255, CV_THRESH_BINARY_INV); val=count(edge1); if (val==0&&axx==0) { axx=1; } if (val==2&&axx==1) { axx=0; bxx++; } sprintf(text, "%i", bxx); comb(gray1, edge1); cvPutText(gray1, text, cvPoint(10, 160), font1, cvScalarAll(255)); cvPutText(gray1, text, cvPoint(10, 160), font2, cvScalarAll(0)); cvShowImage("Line Counter", gray1); if (cvWaitKey(5) > 0) break; cvReleaseImage(&gray1); cvReleaseImage(&edge1); } }
Point back() const { if (begin_ == end_) { BOOST_THROW_EXCEPTION(std::out_of_range("back() cannot be called on empty PointRange.")); } return Point(end_.x - dx(), end_.y - dy()); }
void SobelTest::testManual1() { m_operator->setParameter(Sobel::PARAMETER_DATA_FLOW, runtime::Enum(Sobel::MANUAL)); m_operator->initialize(); m_operator->activate(); runtime::DataContainer src(new cvsupport::Image("lenna.jpg", cvsupport::Image::GRAYSCALE)); runtime::DataContainer dst(new cvsupport::Image(1000000)); runtime::Enum ddepth(1); runtime::UInt32 dx(2); runtime::UInt32 dy(0); runtime::UInt32 ksize(3); runtime::Float64 scale(1); runtime::Float64 delta(0); m_operator->setInputData(Sobel::INPUT_SRC, src); m_operator->setInputData(Sobel::INPUT_DST, dst); m_operator->setParameter(Sobel::PARAMETER_DDEPTH, ddepth); m_operator->setParameter(Sobel::PARAMETER_DX, dx); m_operator->setParameter(Sobel::PARAMETER_DY, dy); m_operator->setParameter(Sobel::PARAMETER_KSIZE, ksize); m_operator->setParameter(Sobel::PARAMETER_SCALE, scale); m_operator->setParameter(Sobel::PARAMETER_DELTA, delta); runtime::DataContainer dstResult = m_operator->getOutputData(Sobel::OUTPUT_DST); runtime::ReadAccess dstAccess(dstResult); cvsupport::Image::save("SobelTest_testManual1_dst.png", dstAccess.get<runtime::Image>()); }
TextStream& SVGFEOffset::externalRepresentation(TextStream& ts) const { ts << "[type=OFFSET] "; SVGFilterEffect::externalRepresentation(ts) << " [dx=" << dx() << " dy=" << dy() << "]"; return ts; }
// // Process the Expose event: draw in the window // void MyWindow::onExpose(XEvent& event) { // Erase a window setForeground(getBackground()); fillRectangle(m_RWinRect); // Draw the coordinate axes drawAxes("black", true, "gray"); // Draw a graph of function setForeground("red"); drawGraphic(); // Draw a cross on mouse click if (clicked) { if (mouseButton == Button1) setForeground("blue"); // Left button else if (mouseButton == Button2) setForeground("SeaGreen"); // Middle button else if (mouseButton == Button3) setForeground("brown"); // Right mouse button R2Vector dx(0.2, 0.); R2Vector dy(0., 0.2); drawLine(lastClick-dx, lastClick+dx); drawLine(lastClick-dy, lastClick+dy); } }
void BaseApp::controls(){ // Compute directional vectors from euler angles float cosX = cosf(wx), sinX = sinf(wx), cosY = cosf(wy), sinY = sinf(wy); vec3 dx(cosY, 0, sinY); vec3 dy(-sinX * sinY, cosX, sinX * cosY); vec3 dz(-cosX * sinY, -sinX, cosX * cosY); vec3 dir(0, 0, 0); if (keys[leftKey]) dir -= dx; if (keys[rightKey]) dir += dx; if (keys[downKey]) dir -= dy; if (keys[upKey]) dir += dy; if (keys[backwardKey]) dir -= dz; if (keys[forwardKey]) dir += dz; float lenSq = dot(dir, dir); if (lenSq > 0){ moveCamera(dir * (1.0f / sqrtf(lenSq))); } dir = vec3(0, 0, 0); if (xStrafeAxis >= 0) dir += joystickAxes[xStrafeAxis] * (invertXStrafeAxis? -dx : dx); if (yStrafeAxis >= 0) dir += joystickAxes[yStrafeAxis] * (invertYStrafeAxis? -dy : dy); if (zStrafeAxis >= 0) dir += joystickAxes[zStrafeAxis] * (invertZStrafeAxis? -dz : dz); if (dot(dir, dir) > 0){ moveCamera(dir); } if (xTurnAxis >= 0) wx += (invertXTurnAxis? -2.0f : 2.0f) * joystickAxes[xTurnAxis] * frameTime; if (yTurnAxis >= 0) wy += (invertYTurnAxis? -2.0f : 2.0f) * joystickAxes[yTurnAxis] * frameTime; }
float ImgPatch::cornerValue() { cv::Mat dx, dy; cv::Sobel(cleanedPatch, dx, CV_32F, 1, 0, 1); cv::Sobel(cleanedPatch, dy, CV_32F, 0, 1, 1); cv::Mat removeBorderDx = dx(cv::Rect(1, 1, dx.cols-2, dx.rows-2)).clone(); cv::Mat removeBorderDy = dy(cv::Rect(1, 1, dy.cols-2, dy.rows-2)).clone(); cv::Mat IX2 = removeBorderDx.mul(removeBorderDx); cv::Mat IY2 = removeBorderDy.mul(removeBorderDy); cv::Mat IXY = removeBorderDx.mul(removeBorderDy); cv::Mat_<float> A = cv::Mat::zeros(2,2,CV_32F); A[0][0] = sum(IX2).val[0]; A[0][1] = sum(IXY).val[0]; A[1][0] = sum(IXY).val[0]; A[1][1] = sum(IY2).val[0]; cv::Mat eigenA; eigen(A, eigenA); //For half_patch_size = 4, we get the number "6" if ((eigenA.at<float>(1,0) >= 6)&&(eigenA.at<float>(1,0)/eigenA.at<float>(0,0)>0.5)) { return eigenA.at<float>(1,0); } else { return 0.0f; } }
double SpectrogramData::value( double x, double y ) const { size_t ix = dx( x ); size_t iy = dy( y ); return m_( ix, iy ); }
void StepperDopr853<D>::step(const Doub htry,D &derivs) { VecDoub dydxnew(n); Doub h=htry; for (;;) { dy(h,derivs); Doub err=error(h); if (con.success(err,h)) break; if (std::abs(h) <= std::abs(x)*EPS) { // <added> std::cerr << "\nh=" << h << "\tx=" << x << "\tstd::abs(h)=" << std::abs(h) << "\tstd::abs(x)=" << std::abs(x) << "\tEPS=" << EPS << std::endl; // </added> Throw1WithMessage("stepsize underflow in StepperDopr853"); } } derivs(x+h,yout,dydxnew); if (dense) prepare_dense(h,dydxnew,derivs); dydx=dydxnew; y=yout; xold=x; x += (hdid=h); hnext=con.hnext; }
Vector ADFun<Base>::ForOne(const Vector &x, size_t j) { size_t j1; size_t n = Domain(); size_t m = Range(); // check Vector is Simple Vector class with Base type elements CheckSimpleVector<Base, Vector>(); CPPAD_ASSERT_KNOWN( x.size() == n, "ForOne: Length of x not equal domain dimension for f" ); CPPAD_ASSERT_KNOWN( j < n, "ForOne: the index j is not less than domain dimension for f" ); // point at which we are evaluating the second partials Forward(0, x); // direction in which are are taking the derivative Vector dx(n); for(j1 = 0; j1 < n; j1++) dx[j1] = Base(0); dx[j] = Base(1); // dimension the return value Vector dy(m); // compute the return value dy = Forward(1, dx); return dy; }
int main(){ int t; scanf("%d",&t); while(t--) { int a,b,c; scanf("%d%d%d",&a,&b,&c); int x=dy(a,b,c); switch(x){ case 0:printf("Sunday\n"); break; case 1:printf("Monday\n"); break; case 2:printf("Tuesday\n"); break; case 3:printf("Wednesday\n"); break; case 4:printf("Thursday\n"); break; case 5:printf("Friday\n"); break; case 6:printf("Saturday\n"); break; } } return 0; }
void TestOdeSystemTwo() { Ode2 ode2; std::vector<double> dy(1); ode2.EvaluateYDerivatives(2.0, ode2.GetInitialConditions(), dy); TS_ASSERT_DELTA(dy[0], 8.0, tol); }
RcppExport SEXP rthkendall(SEXP x_, SEXP y_, SEXP nthreads) { Rcpp::NumericVector x(x_); Rcpp::NumericVector y(y_); Rcpp::NumericVector RET(1); const int n = LENGTH(x); #if RTH_OMP omp_set_num_threads(INT(nthreads)); #elif RTH_TBB tbb::task_scheduler_init init(INT(nthreads)); #endif thrust::counting_iterator<int> seqa(0); thrust::counting_iterator<int> seqb = seqa + n - 1; floublevec dx(x.begin(), x.end()); floublevec dy(y.begin(), y.end()); intvec tmp(n-1); thrust::transform(seqa,seqb,tmp.begin(),calcgti(dx,dy,n)); int totcount = thrust::reduce(tmp.begin(),tmp.end()); flouble npairs = n * (n-1) / 2; REAL(RET)[0] = (double) (totcount - (npairs-totcount)) / npairs; return RET; }
void ShapeDrawer::drawShape(const btCollisionShape* shape) { const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape); btVector3 halfExtent = boxShape->getHalfExtentsWithMargin(); btVector3 org(0,0,0); btVector3 dx(1,0,0); btVector3 dy(0,1,0); btVector3 dz(0,0,1); dx *= halfExtent[0]; dy *= halfExtent[1]; dz *= halfExtent[2]; glBegin(GL_LINE_LOOP); glDrawVector(org - dx - dy - dz); glDrawVector(org + dx - dy - dz); glDrawVector(org + dx + dy - dz); glDrawVector(org - dx + dy - dz); glDrawVector(org - dx + dy + dz); glDrawVector(org + dx + dy + dz); glDrawVector(org + dx - dy + dz); glDrawVector(org - dx - dy + dz); glEnd(); glBegin(GL_LINES); glDrawVector(org + dx - dy - dz); glDrawVector(org + dx - dy + dz); glDrawVector(org + dx + dy - dz); glDrawVector(org + dx + dy + dz); glDrawVector(org - dx - dy - dz); glDrawVector(org - dx + dy - dz); glDrawVector(org - dx - dy + dz); glDrawVector(org - dx + dy + dz); glEnd(); }
extern "C" SEXP rthpearson(SEXP x, SEXP y, SEXP nthreads) { SEXP cor; int n = LENGTH(x); doublevec dx(REAL(x), REAL(x)+n); doublevec dy(REAL(x), REAL(x)+n); double zero = (double) 0.0; RTH_GEN_NTHREADS(nthreads); double xy = thrust::inner_product(dx.begin(), dx.end(), dy.begin(), zero); double x2 = thrust::inner_product(dx.begin(), dx.end(), dx.begin(), zero); double y2 = thrust::inner_product(dy.begin(), dy.end(), dy.begin(), zero); double xt = thrust::reduce(dx.begin(), dx.end()); double yt = thrust::reduce(dy.begin(), dy.end()); double xm = xt/n, ym = yt/n; double xsd = sqrt(x2/n - xm*xm); double ysd = sqrt(y2/n - ym*ym); PROTECT(cor = allocVector(REALSXP, 1)); REAL(cor)[0] = (xy/n - xm*ym) / (xsd*ysd); UNPROTECT(1); return cor; }
void ConnectorLine::paint( QPainter* p, const QStyleOptionGraphicsItem* option, QWidget* widget ) { Q_UNUSED(option); Q_UNUSED(widget); //pen.setColor( Qt::darkGray); //p->setPen( pen ); //if( Simulator::self()->isAnimated() ) QColor color; if( isSelected() ) color = QColor( Qt::darkGray ); else color = QColor( 40, 40, 60 /*Qt::black*/ ); /*{ int volt = 50*int( m_pConnector->getVolt() ); if( volt > 250 )volt = 250; if( volt < 0 ) volt = 0; if( m_pConnector->endPin() && (m_pConnector->startPin()->changed() || m_pConnector->endPin()->changed()) ) { pen.setWidth(3); } color = QColor( volt, 50, 250-volt); }*/ QPen pen( color, 2.5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ); //p->setBrush( Qt::green ); //p->drawRect( boundingRect() ); p->setPen( pen ); p->drawLine( 0, 0, dx(), dy()); }
void ParticleLayer3D::CalcNonLong(Particle* current, Vector3& topLeft, Vector3& topRight, Vector3& botLeft, Vector3& botRight) { Vector3 dx(_left); Vector3 dy(_up); float32 sine; float32 cosine; SinCosFast(current->angle, sine, cosine); // Draw pivot point is Sprite center + layer pivot point. Vector2 drawPivotPoint = GetDrawPivotPoint(); float32 pivotRight = ((sprite->GetWidth()-drawPivotPoint.x)*current->size.x*current->sizeOverLife.x)/2.f; float32 pivotLeft = (drawPivotPoint.x*current->size.x*current->sizeOverLife.x)/2.f; float32 pivotUp = (drawPivotPoint.y*current->size.y*current->sizeOverLife.y)/2.f; float32 pivotDown = ((sprite->GetHeight()-drawPivotPoint.y)*current->size.y*current->sizeOverLife.y)/2.f; Vector3 dxc = dx*cosine; Vector3 dxs = dx*sine; Vector3 dyc = dy*cosine; Vector3 dys = dy*sine; // Apply offset to the current position according to the emitter position. UpdateCurrentParticlePosition(current); topLeft = currentParticlePosition+(dxs+dyc)*pivotLeft + (dxc-dys)*pivotDown; topRight = currentParticlePosition+(-dxc+dys)*pivotUp + (dxs+dyc)*pivotLeft; botLeft = currentParticlePosition+(dxc-dys)*pivotDown + (-dxs-dyc)*pivotRight; botRight = currentParticlePosition+(-dxs-dyc)*pivotRight + (-dxc+dys)*pivotUp; }
QRegion QMatrix::mapToRegion(const QRect &rect) const { QRegion result; if (isIdentity()) { result = rect; } else if (m12() == 0.0F && m21() == 0.0F) { int x = qRound(m11()*rect.x() + dx()); int y = qRound(m22()*rect.y() + dy()); int w = qRound(m11()*rect.width()); int h = qRound(m22()*rect.height()); if (w < 0) { w = -w; x -= w - 1; } if (h < 0) { h = -h; y -= h - 1; } result = QRect(x, y, w, h); } else { result = QRegion(mapToPolygon(rect)); } return result; }
Type dist(const Vec3& src) const { Type dx(x - src.x); Type dy(y - src.y); Type dz(z - src.z); return _sqrt(dx * dx + dy * dy + dz *dz); }
void getRecognizerPositionVelocity(vec2 *p, vec2 *v) { float max = recognizer->BBox.vSize.v[0] * rec_scale_factor; float rec_boundry = game2->rules.grid_size - max; p->v[0] = (max + (x() + 1.0f) * rec_boundry) / 2.0f; p->v[1] = (max + (y() + 1.0f) * rec_boundry) / 2.0f; v->v[0] = dx() * game2->rules.grid_size / 100.f; v->v[1] = dy() * game2->rules.grid_size / 100.f; }
void TestOdeSystemThree() { Ode3 ode3; std::vector<double> dy(2); ode3.EvaluateYDerivatives(2.0, ode3.GetInitialConditions(), dy); TS_ASSERT_DELTA(dy[0], 8.0, tol); TS_ASSERT_DELTA(dy[1], 16.0, tol); }