//===================================== // XQuery run query... //------------------------------------- QString* XQuery::run (void) { QString optd ("-d"); QString dpy (DisplayString (x11Display())); if (mArg.isEmpty()) { if (! errorCheck) { *mResult = qx ( XQUERY,STDOUT,3,"%s %s %s", optd.ascii(),dpy.ascii(),mOpt.ascii() ); } else { *mResult = qx ( XQUERY,STDERR,3,"%s %s %s", optd.ascii(),dpy.ascii(),mOpt.ascii() ); } } else { if (! errorCheck) { *mResult = qx ( XQUERY,STDOUT,4,"%s %s %s %s", optd.ascii(),dpy.ascii(),mOpt.ascii(),mArg.ascii() ); } else { *mResult = qx ( XQUERY,STDERR,4,"%s %s %s %s", optd.ascii(),dpy.ascii(),mOpt.ascii(),mArg.ascii() ); } } return (mResult); }
void qx(op_CmB)(struct FermionX *r_x, struct eo_lattice *xy, const struct SUn *U, const struct FermionX *a_x, const struct FermionX *a_y, long long *flops, long long *sent, long long *received) { qx(boundary)(xy, qx(up_project_n), qx(down_project_n), U, a_y, flops); if (xy->h_valid) QMP_start(xy->handle); *flops += qx(do_CmB)(r_x, 0, xy->body_size, xy->neighbor, U, a_x, a_y, NULL); if (xy->h_valid) QMP_wait(xy->handle); *flops += qx(do_CmB)(r_x, xy->body_size, xy->face_size, xy->neighbor, U, a_x, a_y, xy->receive_buf); *sent += xy->total_send; *received += xy->total_receive; }
void qx(x_import)(struct eo_lattice *eo, double r[], struct Fermion *data, void (*reader)(double *val_re, double *val_im, const int pos[Q(DIM)+1], int color, int dirac, void *env), void *env) { int size = eo->full_size; int Ls = eo->Ls; int p, c, d; int x[Q(DIM)+1]; double *v; for (p = 0; p < size; p++) { q(l2v)(x, eo->local, eo->lx2v[p]); for (v = r, x[Q(DIM)] = 0; x[Q(DIM)] < Ls; x[Q(DIM)]++) { for (c = 0; c < Q(COLORS); c++) { for (d = 0; d < Q(FERMION_DIM); d++, v += 2) { reader(&v[0], &v[1], x, c, d, env); } } } qx(put_fermion)(data, p, Ls, r); } }
void EditorIkSolver::_checkPivotXZ(ArRef<Joint> joint, Vector3d /* requestedTranslation */, Quaterniond requestedRotation) { double prx, pry, prz; joint->getDeltaRotation().getEulerAngles(prx, pry, prz); requestedRotation = joint->getDeltaRotation() * requestedRotation; double rx, ry, rz; requestedRotation.getEulerAngles(rx, ry, rz); double* max[2]; double* min[2]; ar_down_cast<JointConstraint2DOF>(joint->getConstraint())->getLimitValues(min, max); double xmin = *min[0], xmax = *max[0], zmin = *min[1], zmax = *max[1]; rx = _clampWithPreviousValue(xmin, xmax, prx, rx); rz = _clampWithPreviousValue(zmin, zmax, prz, rz); Quaterniond qx(Vector3d(1.0, 0.0, 0.0), rx); Quaterniond qz(Vector3d(0.0, 0.0, 1.0), rz); joint->setDeltaRotation(qx * qz); }
static void MotionCallback(int x, int y) { int dx = gMouseX - x; int dy = gMouseY - y; gDir.normalize(); //カメラの視線ベクトルを正規化 gViewY.cross(gDir, NxVec3(0,1,0)); // if( gMouseButton[0] && gMouseButton[1] ) { //Zoom: Left + Center Buttons Drag gEye -= gDir * 0.5f * dy; } else { if( gMouseButton[0] ) { //Rotate: Left Button Drag NxQuat qx(NxPiF32 * dx * 10/ 180.0f, NxVec3(0,1,0)); qx.rotate(gDir); NxQuat qy(NxPiF32 * dy * 10/ 180.0f, gViewY); qy.rotate(gDir); } else if( gMouseButton[1] ) { //Move: Center Button Drag gEye += 0.1f * (gViewY * dx - NxVec3(0, 1, 0) * dy); } } gMouseX = x; gMouseY = y; glutPostRedisplay(); }
void EntityAdapter::setOrientation( Config::Real xAngle, Config::Real yAngle, Config::Real zAngle ) { Ogre::Quaternion qx(Ogre::Radian(xAngle), Ogre::Vector3(1.0,0.0,0.0)) ; Ogre::Quaternion qy(Ogre::Radian(yAngle), Ogre::Vector3(0.0,1.0,0.0)) ; Ogre::Quaternion qz(Ogre::Radian(zAngle), Ogre::Vector3(0.0,0.0,1.0)) ; m_entity->setOrientation(qx*qy*qz) ; }
void MotionCallback(int x, int y) { int dx = mx - x; int dy = my - y; if (gMouseSphere) // Move the mouse sphere { NxVec3 pos; ViewUnProject(x,y, gMouseDepth, pos); gMouseSphere->setGlobalPosition(pos); gHitActor->wakeUp(); } else if (gHitCloth) // Attach the cloth vertex { NxVec3 pos; ViewUnProject(x,y, gMouseDepth, pos); gHitCloth->attachVertexToGlobalPosition(gHitClothVertex, pos); } else if (bLeftMouseButtonPressed) // Set camera { gCameraForward.normalize(); gCameraRight.cross(gCameraForward,NxVec3(0,1,0)); NxQuat qx(NxPiF32 * dx * 20 / 180.0f, NxVec3(0,1,0)); qx.rotate(gCameraForward); NxQuat qy(NxPiF32 * dy * 20 / 180.0f, gCameraRight); qy.rotate(gCameraForward); } mx = x; my = y; }
inline PxQuat EulerAngleToQuat(const PxVec3 &rot) { PxQuat qx(degToRad(rot.x), PxVec3(1.0f, 0.0f, 0.0f)); PxQuat qy(degToRad(rot.y), PxVec3(0.0f, 1.0f, 0.0f)); PxQuat qz(degToRad(rot.z), PxVec3(0.0f, 0.0f, 1.0f)); return qz * qy * qx; }
//===================================== // XKeyboard::Layout/Model check //------------------------------------- void XKeyboard::validateLayout ( void ) { // log(L_INFO,"XKeyboard::validateLayout() called\n"); // ... // this function check if the currently used combination // of layout and model is valid according to the Keyboard.map // if not we will provide a warning // --- QString XkbModel; QString XkbLayout; QDictIterator<char> itModel (mModelHash); for (; itModel.current(); ++itModel) { if (QString::fromLocal8Bit(itModel.current()) == mType->currentText()) { XkbModel = itModel.currentKey(); } } // 2) primary XKB layout QDictIterator<char> itLayout (mLayoutHash); for (; itLayout.current(); ++itLayout) { if (QString::fromLocal8Bit(itLayout.current()) == mLayout->currentText()) { XkbLayout = itLayout.currentKey(); } } QString isValid = qx ( VALIDATELAYOUT,STDOUT,2,"%s %s", XkbModel.ascii(),XkbLayout.ascii() ); if (! isValid.toInt()) { setMessage ("noValidLayout"); } }
//===================================== // set cursor for root window... //------------------------------------- void setMouseCursor (const QString& cursorName) { QString optc ("-cursor_name"); QString optd ("-display"); QString display ( DisplayString ( QApplication::desktop()->x11Display() )); qx (XSETROOT,STDNONE,4,"%s %s %s %s", optc.ascii(),cursorName.ascii(),optd.ascii(),display.ascii() ); }
invariant_error_type get_invariant_error(const pp::vector_topology< vect_n<double> >&, const point_type& x, const input_type& u, const output_type& y, const time_type& t) const { vect<double,2> qy(y[2],y[3]); qy = unit(qy); vect<double,2> qx(x[2],x[3]); qx = unit(qx); return invariant_error_type(y[0] - x[0], y[1] - x[1], //qy[0] * qx[0] + qy[1] * qx[1], // c_y * c_x + s_y * s_x qy[1] * qx[0] - qy[0] * qx[1]); // s_y * c_x - c_y * s_x };
void SimObjBase::setQ(const dReal *q) { int i = 0; qw(q[i]); i++; qx(q[i]); i++; qy(q[i]); i++; qz(q[i]); i++; }
void euler2quaternion(Eigen::Quaternion<scalar> &res, const scalar& phi, const scalar& theta, const scalar& psi) { Eigen::Quaternion<scalar> qx(std::cos(phi/2), std::sin(phi/2), 0, 0), qy(std::cos(theta/2), 0, std::sin(theta/2), 0), qz(std::cos(psi/2), 0, 0, std::sin(psi/2)); res = qz * qy * qx; }
//====================================== // ScanServer: check for VESA BIOS //-------------------------------------- int ScanServer::haveVesaBIOS (void) { string status = "0"; status = qx ( VBIOS,STDOUT ); if (status == "1") { return (1); } return (0); }
void SimObjBase::setAxisAndAngle(double ax, double ay, double az, double degAngle) { Sgv::Quaternion q(degAngle*180/M_PI, ax, ay, az); qw(q.qw()); qx(q.qx()); qy(q.qy()); qz(q.qz()); }
void RotateCamera(int dx, int dy) { gDir = gDir.Normalize(); gN = gDir ^ Point(0,1,0); NxQuat qx(NxPiF32 * dx * 20/ 180.0f, Point(0,1,0)); qx.rotate(gDir); NxQuat qy(NxPiF32 * dy * 20/ 180.0f, gN); qy.rotate(gDir); }
void Quat :: setRotXYZ( const float a, const float b, const float c ) { Quat qx(ROT_X, a); Quat qy(ROT_Y, b); Quat qz(ROT_Z, c); *this = qx * qy * qz; } /* RotXIdent */
/*********************************************************** constructor from 3 angles ***********************************************************/ LbaQuaternion::LbaQuaternion(float anglex, float angley, float anglez) { LbaQuaternion qx(anglex, LbaVec3(1, 0, 0)); LbaQuaternion qy(angley, LbaVec3(0, 1, 0)); LbaQuaternion qz(anglez, LbaVec3(0, 0, 1)); LbaQuaternion res = (qy * qx * qz); X = res.X; Y = res.Y; Z = res.Z; W = res.W; }
void RotateCamera(int dx, int dy) { const Point Up(0.0f, 1.0f, 0.0f); gDir.Normalize(); gViewY = gDir^Up; // #### TODO: replicate this using Ice quats MyQuat qx(NxPiF32 * dx * 20.0f/ 180.0f, Up); qx.rotate(gDir); MyQuat qy(NxPiF32 * dy * 20.0f/ 180.0f, gViewY); qy.rotate(gDir); }
int operator_a(void) { struct QX(HalfFermion) *f_a; struct QX(HalfFermion) *f_b; struct QX(HalfFermion) *f_x; struct QX(Fermion) *t; long long flops = 0; long long sent = 0; long long received = 0; double x, y, norm; if (q(setup_comm)(state, sizeof (REAL))) { zprint("opetator_a(): setup_comm failed"); return 1; } if (QX(import_half_fermion)(&f_a, state, read_fermion_x, &seed_a)) { zprint("operator_a(): alloc failed on x"); return 1; } if (QX(import_half_fermion)(&f_b, state, read_fermion_x, &seed_b)) { zprint("operator_a(): alloc failed on b"); return 1; } if (QX(import_half_fermion)(&f_x, state, read_fermion_x, &seed_a)) { zprint("operator_a(): alloc failed on x"); return 1; } if (QX(allocate_fermion)(&t, state)) { zprint("operator_a(): alloc failed on t"); return 1; } qx(op_even_Mxn)(f_x->even, &norm, state, params, gauge->data, f_a->even, &flops, &sent, &received, t->even, t->odd); QX(dot_half_fermion)(&x, &y, f_b, f_x); QOP_MDWF_free_fermion(&t); QOP_MDWF_free_half_fermion(&f_x); QOP_MDWF_free_half_fermion(&f_a); QOP_MDWF_free_half_fermion(&f_b); show("native", x, y, norm); return 0; }
/*! * @brief It rotates for the specification of the relative angle. * @param[in] x-axis rotation weather(i of quaternion complex part) * @param[in] y-axis rotation weather(j of quaternion complex part) * @param[in] z-axis rotation weather(k of quaternion complex part) * @param[in] flag for ansolute / relational (1.0=absolute, else=relational) */ void SimObjBase::setAxisAndAngle(double ax, double ay, double az, double angle, double direct) { // The angle is used now at the relative angle specification. if (dynamics()) { return; } Rotation r; if (direct != 1.0) r.setQuaternion(qw(), qx(), qy(), qz()); // alculate relational angle r.setAxisAndAngle(ax, ay, az, angle, direct); const dReal *q = r.q(); setQ(q); }
//-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ if (button==0){ ofQuaternion qy((x-ofGetPreviousMouseX()), ofVec3f(0,1,0)); ofQuaternion qx((y-ofGetPreviousMouseY()), ofVec3f(1,0,0)); qrot *= qx*qy; } if (button==2){ ofQuaternion qz((x-ofGetPreviousMouseX()), ofVec3f(0,0,1)); qrot *= qz; scale += (float)(ofGetPreviousMouseY()-y)/(ofGetWindowHeight()/2); if (scale<0) scale = 0.0001; } }
void MotionCallback(int x, int y) { int dx = mx - x; int dy = my - y; gCameraForward.normalize(); gCameraRight.cross(gCameraForward,NxVec3(0,1,0)); NxQuat qx(NxPiF32 * dx * 20 / 180.0f, NxVec3(0,1,0)); qx.rotate(gCameraForward); NxQuat qy(NxPiF32 * dy * 20 / 180.0f, gCameraRight); qy.rotate(gCameraForward); mx = x; my = y; }
static void MotionCallback(int x, int y) { int dx = mx - x; int dy = my - y; Dir = Dir.normalize(); N = Dir.cross(btVector3(0,1,0)); NxQuat qx(NxPiF32 * dx * 20/ 180.0f, btVector3(0,1,0)); qx.rotate(Dir); NxQuat qy(NxPiF32 * dy * 20/ 180.0f, N); qy.rotate(Dir); mx = x; my = y; }
void Camera::HandleMotion(int x, int y) { int dx = m_mouse_x - x; int dy = m_mouse_y - y; PxVec3 viewY = m_dir.cross(PxVec3(0, 1, 0)).getNormalized(); PxQuat qx(PxPi * dx / 180.0f, PxVec3(0, 1, 0)); m_dir = qx.rotate(m_dir); PxQuat qy(PxPi * dy / 180.0f, viewY); m_dir = qy.rotate(m_dir); m_dir.normalize(); m_mouse_x = x; m_mouse_y = y; }
void MouseMotion(int x, int y ) { if(g_isButtonDown[0] || g_isButtonDown[2]) { int dx = g_last_x - x; int dy = g_last_y - y; g_CameraForward.normalize(); g_CameraRight.cross(g_CameraForward, NxVec3(0,1,0)); NxQuat qx(NxPiF32 * dx * 20/ 180.0f, NxVec3(0,1,0)); qx.rotate(g_CameraForward); NxQuat qy(NxPiF32 * dy * 20/ 180.0f, g_CameraRight); qy.rotate(g_CameraForward); g_last_x = x; g_last_y = y; } if (g_isButtonDown[1]) { float dt = 0.1f; if ((float) (x-g_last_x)>0) { g_CameraPos -= g_CameraRight*g_Speed*dt; } else if ((float) (x-g_last_x)<0) { g_CameraPos += g_CameraRight*g_Speed*dt; } if ((float) (y-g_last_y)>0) { g_CameraPos +=NxVec3(0.0f,1.0f,0.0f)*g_Speed*dt; } else if ((float) (y-g_last_y)<0) { g_CameraPos -=NxVec3(0.0f,1.0f,0.0f)*g_Speed*dt; } g_last_x = x; g_last_y = y; } glutPostRedisplay(); }
casa::ImageRegion* ImageRegionGenerator::_makeRegionPolygon( casa::ImageInterface<casa::Float> * image, Carta::Lib::Regions::Polygon* polygon ){ casa::ImageRegion* imageRegion = nullptr; if ( image && polygon ){ QPolygonF poly = polygon->qpolyf(); int cornerPointCount = poly.count(); casa::Vector<casa::Double> x( cornerPointCount ); casa::Vector<casa::Double> y( cornerPointCount ); const casa::CoordinateSystem &cs = image->coordinates( ); bool successful = true; for ( int i = 0; i < cornerPointCount; ++i ) { QPointF polyPt = poly.value( i ); casa::Vector<casa::Double> worldPt = _toWorld( cs, polyPt.x(), polyPt.y(), &successful ); if ( successful ){ x[i] = worldPt[0]; y[i] = worldPt[1]; } else { qDebug() << "i="<<i<<" could not convert x="<<polyPt.x()<<" y="<<polyPt.y()<<" to world."; break; } } if ( successful ){ casa::Vector<casa::Int> dispAxes(2); const casa::CoordinateSystem &cs = image->coordinates( ); int directionIndex = cs.findCoordinate( casa::Coordinate::DIRECTION ); if ( directionIndex >= 0 ){ casa::Vector<casa::Int> dirPixelAxis = cs.pixelAxes(directionIndex); dispAxes(0) = dirPixelAxis[0]; dispAxes(1) = dirPixelAxis[1]; const casa::String units( RAD_UNITS.toStdString().c_str() ); try { casa::Quantum<casa::Vector<casa::Double> > qx( x, units ); casa::Quantum<casa::Vector<casa::Double> > qy( y, units ); casa::WCPolygon poly(qx, qy, casa::IPosition(dispAxes), cs); imageRegion = new casa::ImageRegion(poly); } catch( casa::AipsError& error ) { qDebug() << "Error making image region: "<<error.getMesg().c_str(); } } } } return imageRegion; }
//===================================== // XKeyboard cancel pressed for mTop //------------------------------------- void XKeyboard::slotTopCancel ( void ) { // log (L_INFO,"XKeyboard::slotTopCancel() called\n"); // ... // this function is called if you click onto the Cancel // button in the setup toplevel window // --- mFrame -> enterEvent ( 0 ); // ... // reset the symbol rate/delay // using 'xset r' command // --- QString optr ("r"); QString rate ("rate"); QString delay; delay.sprintf ("%d",mCurrentDelay); QString krate; krate.sprintf ("%d",mCurrentKrate); qx ( XSET,STDNONE,4,"%s %s %s %s", optr.ascii(),rate.ascii(), delay.ascii(),krate.ascii() ); }
//===================================== // XOpenGL slotIntro... //------------------------------------- void XOpenGL::slotIntro (int index) { if (index == mIndex) { XWrapPointer< QDict<char> > mText (mTextPtr); XTextBrowser* info; QString message; QString idents; QDict<char> layout; info = mIntro -> getTextView(); message = mText["opengl_header"]; info -> setText (message); message += "<br><br><table border=1 bgcolor=lightgrey "; message += "cellspacing=1 width=90%>"; message += "<tr>"; if (global3DActive) { QTextOStream (&idents) << "<td>" << mText["on"] << "</td>"; } else { QString noscan ("noscan"); XStringList packageInfo ( qx (GET3D,STDOUT,1,"%s",noscan.ascii()) ); packageInfo.setSeperator (":"); QList<char> result = packageInfo.getList(); QString answer3D = result.at(5); if (answer3D == "yes") { QTextOStream (&idents) << "<td>" << mText["unavailable"] << "</td>"; } else { QTextOStream (&idents) << "<td>" << mText["notConfigured"] << "</td>"; } } message += idents; message += "</tr>"; message += "</table>"; info -> setText (message); } }
static void test_dot_vf(const char *name, int esize, int ls, struct vFermion *v, int v_w, int v_b, int v_l, struct vFermion *w, int w_w, int w_b, int w_l, struct Fermion *t0, struct Fermion *t1, int ldc) { int m_size = 2 * w_l * ldc; int i, j; double m_ab[m_size]; double n_f, n_t; double ff_r, ff_i; double delta; double m_e = 0; memset(m_ab, 0, m_size * sizeof (double)); qx(do_vfH_dot_vf)(esize, ls, m_ab, ldc, v, v_w, v_b, v_l, w, w_w, w_b, w_l); for (i = 0; i < v_l; i++) { n_f = 0; qx(vf_get)(esize, ls, t0, v, v_w, i + v_b); qx(f_norm)(&n_f, esize, ls, t0); for (j = 0; j < w_l; j++) { qx(vf_get)(esize, ls, t1, w, w_w, j + w_b); ff_r = ff_i = 0; qx(f_dot)(&ff_r, &ff_i, esize, ls, t0, t1); n_t = 0; qx(f_norm)(&n_t, esize, ls, t1); ff_r -= m_ab[0 + 2 * (i + ldc * j)]; ff_i -= m_ab[1 + 2 * (i + ldc * j)]; delta = (ff_r * ff_r + ff_i * ff_i) / sqrt(n_f * n_t); printf("%s %3d %3d %15.7e\n", name, i, j, delta); if (delta > m_e) m_e = delta; } } printf("Max error: %s %15.7e\n", name, m_e); }