/// creates translation and rotation matrix according to euler angles and transition vector void CMat44::createTRMatrix(float alpha, float beta, float gamma, float trans_x, float trans_y, float trans_z){ setEye(); CMat44 rotX,rotY,rotZ; rotX.setEye(); rotY.setEye(); rotZ.setEye(); rotX.setElement(cos(alpha),2,2); rotX.setElement(-sin(alpha),2,3); rotX.setElement(sin(alpha),3,2); rotX.setElement(cos(alpha),3,3); rotY.setElement(cos(beta),1,1); rotY.setElement(sin(beta),1,3); rotY.setElement(-sin(beta),3,1); rotY.setElement(cos(beta),3,3); rotZ.setElement(cos(gamma),1,1); rotZ.setElement(-sin(gamma),1,2); rotZ.setElement(sin(gamma),2,1); rotZ.setElement(cos(gamma),2,2); *this=rotX*rotY*rotZ; setElement(trans_x,1,4); setElement(trans_y,2,4); setElement(trans_z,3,4); orientation[0]=alpha; orientation[1]=beta; orientation[2]=gamma; }
void Interface::random(float range) { switch (bufferType) { case BT_BYTE: unsigned charRange; if (range >= 128) { charRange = 127; } else { charRange = (unsigned) range; } for (unsigned i = 0; i < size; i++) { setElement(i, 128 + (unsigned char) Random::integer(charRange)); } break; case BT_FLOAT: case BT_FLOAT_SMALL: for (unsigned i = 0; i < size; i++) { setElement(i, Random::floatNum(range)); } break; case BT_BIT: case BT_SIGN: for (unsigned i = 0; i < size; i++) { setElement(i, Random::positiveInteger(2)); } break; } }
mat4& mat4::setScalingMatrix(const vec3& scaling) { setIdentityMatrix(); setElement(0, 0, scaling.x); setElement(1, 1, scaling.y); setElement(2, 2, scaling.z); return *this; }
mat4& mat4::setTranslationMatrix(const vec3& translation) { setIdentityMatrix(); setElement(3, 0, translation.x); setElement(3, 1, translation.y); setElement(3, 2, translation.z); return *this; }
void Matrix::swap( int row1, int column1, int row2, int column2 ){ assert( row1 > -1 && row1 < m_nrows && column1 > -1 && column1 < m_ncols && row2 > -1 && row2 < m_nrows && column2 > -1 && column2 < m_ncols); float element1 = getElement(row1, column1); float element2 = getElement( row2, column2 ); setElement( row1, column1, element2 ); setElement( row2, column2, element1 ); }
void DataArray::init() { UINT i; reset(); BYTE *ep = (BYTE*)getData(); const size_t n = size(); const UINT elemSize = getElementSize(); UINT maxValue; switch(elemSize) { case 1 : maxValue = min((UINT)n, 0xff ); break; case 2 : maxValue = min((UINT)n, 0xffff); break; default: maxValue = (UINT)n; break; } switch(m_param.m_initMethod) { case IDC_RADIO_RANDOM: { switch(m_param.m_randomizationMethod) { case FIXED_SEED : m_param.m_random.setSeed(m_param.m_seed); break; case SAME_RANDOM_SEED : m_param.m_random.setSeed(m_param.m_randomSeed); break; case RANDOM_SEED : m_param.m_random.randomize(); break; } for(i = 0; i < n; i++, ep += elemSize) { setElement(ep, m_param.m_random.nextInt(maxValue)); } } break; case IDC_RADIO_SORTED: for(i = 0; i < n; i++, ep += elemSize) { setElement(ep, (UINT)((i*maxValue)/n)); } break; case IDC_RADIO_INVERSESORTED: for(i = 0; i < n; i++, ep += elemSize) { setElement(ep, (UINT)((n-i)*maxValue/n)); } break; case IDC_RADIO_SINUS: for(i = 0; i < n; i++, ep += elemSize) { setElement(ep, (unsigned int)(maxValue * (0.5*(1.0+sin(M_PI*2*i / (n-1)*m_param.m_periodCount))))); } break; case IDC_RADIO_FILEDATA: for(i = 0; i < n; i++, ep += elemSize) { setElement(ep, m_param.m_fileData[i]); } break; default: throwException(_T("DataArray::init:Unknown initmethod (=%d)"), m_param.m_initMethod); break; } }
void SetZSetMember(const Data& v) { if (type == KEY_ZSET_SCORE) { setElement(v, 0); } else { setElement(v, 1); } }
mat4& mat4::setLookAtMatrix(const vec3& forward, const vec3& up, const vec3& right) { setIdentityMatrix(); setElement(0, 0, right.x); setElement(1, 0, right.y); setElement(2, 0, right.z); setElement(0, 1, up.x); setElement(1, 1, up.y); setElement(2, 1, up.z); setElement(0, 2, forward.x); setElement(1, 2, forward.y); setElement(2, 2, forward.z); return *this; }
//zero out all entries in a matrix of any size void zero(struct matrix * m){ for (int i=0; i < m->height; i++){ for(int j=0; j < m->width; j++){ setElement(m,i,j, 0.0); } } }
//given two matrices A & B and a blank answer matrix, fills the 3rd one with the //product of AB. Returns 0 if not compatible; 1 otherwise. int matrixMultiply(const struct matrix * const A, const struct matrix * const B, struct matrix * const answer){ //ensure matrices are compatible & so is answer matrix, if latter is not, fix it if(A->width != B-> height){ printf("\nMatrices are not multiplication-compatible; A has width %d, B has height %d.\n", A->width, B->height); return 0; } if(answer->width != B-> width || answer->height != A->height){ destroy(answer); init(answer,A->height, B->width); answer->width = B->width; answer->height = A->height; } double temp = 0.0; for(int i=0; i < answer->height; i++){ for(int j=0; j < answer->width; j++){ for(int k = 0; k < A->width; k++){ temp += getElement(A,i,k) * getElement(B,k,j); } setElement(answer,i,j,temp); temp=0.0; } } return 1; }
/** * Update DOM tree element */ void GEdge::updateElement() { #if 0 QDomElement e = elem(); int i = 0; QDomElement new_e = graph()->createElement( "edge"); QDomNode e2 = graph()->documentElement().removeChild( e); assert( !e2.isNull()); graph()->documentElement().appendChild( new_e); setElement( new_e); e = new_e; #endif /* Base class method call to print generic edge properties */ AuxEdge::updateElement(); QDomElement e = elem(); /** Save style that describes this edge only along with edge */ if ( isNotNullP( style())) { if ( 1 == style()->numItems()) { e.removeAttribute("style"); style()->writeElement( e, false); } else { e.setAttribute("style", style()->name()); } } }
mat4& mat4::setPerspectiveMatrix(float fov, float aspectRatio, float far, float near) { *this = mat4(); float ar = aspectRatio; float thf = tan(deg_to_rad(fov / 2.0f)); float range = near - far; setElement(0, 0, 1.0f / (ar * thf)); setElement(1, 1, 1.0f / thf); setElement(2, 2, (-near - far) / range); setElement(3, 2, (2.0f * near * far) / range); setElement(2, 3, 1.0f); return *this; }
void Scope::loadStored( bool ignoreNotConnected ){ if ( _localDBName.size() == 0 ){ if ( ignoreNotConnected ) return; uassert( "need to have locallyConnected already" , _localDBName.size() ); } if ( _loadedVersion == _lastVersion ) return; _loadedVersion = _lastVersion; static DBClientBase * db = createDirectClient(); auto_ptr<DBClientCursor> c = db->query( _localDBName + ".system.js" , Query() ); while ( c->more() ){ BSONObj o = c->next(); BSONElement n = o["_id"]; BSONElement v = o["value"]; uassert( "name has to be a string" , n.type() == String ); uassert( "value has to be set" , v.type() != EOO ); setElement( n.valuestr() , v ); } }
void BlockPhysicsComponent::rasterize(Polygon2 const &polygon) { Polygon2 localPolygon; for (int i = 0; i < polygon.getSize(); ++i) { b2Vec2 worldPoint(polygon.vertices[i].x, polygon.vertices[i].y); b2Vec2 localPoint = body_->GetLocalPoint(worldPoint); localPolygon.vertices.push_back(Vector2(localPoint.x, localPoint.y)); } Box2 bounds = localPolygon.getBoundingBox(); int minX = int(10.0f * bounds.p1.x + 0.05f); int minY = int(10.0f * bounds.p1.y + 0.05f); int maxX = int(10.0f * bounds.p2.x + 0.05f); int maxY = int(10.0f * bounds.p2.y + 0.05f); for (int y = minY; y <= maxY; ++y) { for (int x = minX; x <= maxX; ++x) { Vector2 localPoint(0.1f * float(x), 0.1f * float(y)); if (localPolygon.containsPoint(localPoint)) { for (int dy = -1; dy <= 1; ++dy) { for (int dx = -1; dx <= 1; ++dx) { if (dx == 0 || dy == 0) { setElement(x + dx, y + dy, 1); } } } } } } }
bool vesUniform::set(const vesVector4f &vector) { if (this->m_numberElements == 0) this->m_numberElements = 1; return isScalar() ? setElement(0, vector) : false; }
// set the identity matrix of dimension n void Matrix::setIdentityMatrix( int n ) { assert( n > 0 ); setDimensions( n, n ); setZero(); for ( int i = 0; i < n; i++ ) setElement( i, i, 1.0 ); }
// Matrix: set row void Matrix::setRow( int row, const vector< double >& v ) { assert( row >= 0 && row < data->size1 ); for ( int j = 0; j < data->size2; j++ ) setElement( row, j, v[ j ] ); }
bool vesUniform::set(const vesMatrix4x4f &matrix) { if (this->m_numberElements == 0) this->m_numberElements = 1; return isScalar() ? setElement(0, matrix) : false; }
void SoXipDicomExaminer::GLRender( SoGLRenderAction* action ) { if (mViewAll) { SoXipDataImage* xipImage = ((SoXipSFDataImage *)mImage->getField(SbName("image")))->getValue(); if( !xipImage ) return ; SbXipImage* image = xipImage->get(); if( image ) adjustCamera( action, image->getModelMatrix() ); // Store the information of the current displayed image mImageModelMatrix = image->getModelMatrix(); mViewAll = FALSE; } if( mViewBoundingBox ) { adjustCamera( action, boundingBox.getValue() ); mViewBoundingBox = false; } // Set the Dicom Element setElement( action ); mImageSwitch->enableNotify( FALSE ); ((SoSFInt32 *)mImageSwitch->getField(SbName("whichChild")))->setValue( drawImage.getValue() ? 0 : -1 ); mImageSwitch->enableNotify( TRUE ); SoXipKit::GLRender( action ); }
void BlockPhysicsComponent::setElementAtPosition(float x, float y, int type) { b2Vec2 localPosition = body_->GetLocalPoint(b2Vec2(x, y)); int xIndex = int(std::floor(10.0f * localPosition.x + 0.5f)); int yIndex = int(std::floor(10.0f * localPosition.y + 0.5f)); setElement(xIndex, yIndex, type); }
// set the diagonal matrix void Matrix::setDiagonalMatrix( const vector< double >& diag ) { int n = diag.size(); setDimensions( n, n ); setZero(); for ( int i = 0; i < n; i++ ) setElement( i, i, diag[ i ] ); }
// Matrix: set column void Matrix::setCol( int col, const vector< double >& v ) { assert( col >= 0 && col < data->size2 ); for ( int i = 0; i < data->size1; i++ ) setElement( i, col, v[ i ] ); }
mat4::mat4(float diagonal) { for(unsigned int x = 0; x < 4; x++) { for(unsigned int y = 0; y < 4; y++) { if(x == y) { setElement(x, y, diagonal); } else { setElement(x, y, 0.0f); } } } }
void Ms::InspectorAmbitus::updateRange() { Ambitus* range = static_cast<Ambitus*>(inspector->element()); range->updateRange(); range->layout(); // redo layout setElement(); // set Inspector values to range properties valueChanged(AmbitusControl::TOPTPC); // force score to notice new range properties }
void FormMetallisation::reset() { FormElementBase::reset(); this->metal=new metallisation(); setElement(this->metal); init(); }
SGMFastScanParameters& SGMFastScanParameters::operator =(const SGMFastScanParameters &other){ if(this != &other){ AMDbObject::operator=(other); setElement(other.element()); setScanInfo(other.scanInfo()); setFastScanSettings(other.fastScanSettings()); } return *this; }
SGMFastScanParameters::SGMFastScanParameters(const QString &name, const QString &element, const SGMScanInfo &scanInfo, const SGMFastScanSettings &fastScanSettings, QObject *parent) : AMDbObject(parent) { setName(name); setElement(element); setScanInfo(scanInfo); setFastScanSettings(fastScanSettings); }
void InspectorAmbitus::valueChanged(int idx) { InspectorBase::valueChanged(idx); // if either tpc or octave is changed, notes can have been swapped // (to keep top above bottom): reload data if (idx >= AmbitusControl::TOPTPC && idx <= AmbitusControl::BOTTOMOCTAVE) { setElement(); } }
//========================================== void histogram(int sid) //========================================== { int i,j,k=0,temp,height = g_rows - 1; int color=0,div,rscale = 0,rn1,rn2; char sstr[40]; float fx = readLatestSidValue(sid,g_mid); // Get max and min value g_fmax = 0.; g_fmin = 999999.; for(i=1;i<=g_cols-5;i++) { g_fbuff[i] = g_fbuff[i+1]; if(g_fmin > g_fbuff[i])g_fmin = g_fbuff[i]; if(g_fmax < g_fbuff[i])g_fmax = g_fbuff[i]; } g_fmax = g_fmax*1.1; g_fbuff[g_cols-5] = fx; div = getDivision(g_fmax); k=1; int kindex = div; for(j=1;j<=g_rows;j++) { if(j == getRowNumber(g_fmax,kindex)) { writeInt(kindex,1, j, C_BLUE); writeInt(kindex,g_cols-4, j, C_BLUE); k++; kindex = k*div; } } rn1 = getRowNumber(g_fmax,3000.); rn2 = getRowNumber(g_fmax,1000.); //writeFloat(g_fmax,7,g_rows-1, 0); sprintf(sstr,"%d Watt",(int)fx); //writeFloat(fx,g_cols/2,g_rows-1, C_RED); writeString(sstr,g_cols/2,g_rows-1, C_RED); g_fmin = 0.0; for(i=1;i<=g_cols-5;i++) { if(g_fmax > 0)temp = (int)(height*(g_fbuff[i]-g_fmin)/(g_fmax - g_fmin)); for(j=1;j<=temp;j++) { if (j >= rn1)color = C_YELLOW; else if (j >= rn2)color = C_RED; if (j < rn2)color = C_GREEN; setElement('*',i,j,color); } } }
void MainWindow::setupUi() { this->setObjectName(QString::fromUtf8("MainWindow")); this->resize(QSize(770, 620).expandedTo(this->minimumSizeHint())); actionOpen = new QAction(this); actionOpen->setObjectName(QString::fromUtf8("actionOpen")); centralwidget = new QWidget(this); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); pBMove = new QPushButton(centralwidget); pBMove->setObjectName(QString::fromUtf8("pBMove")); pBMove->setGeometry(QRect(10, 70, 71, 21)); sBMove = new QSpinBox(centralwidget); sBMove->setObjectName(QString::fromUtf8("sBMove")); sBMove->setGeometry(QRect(90, 100, 42, 22)); sBMove->setWrapping(false); sBMove->setMinimum(-99); sBMove->setValue(1); lESet = new QLineEdit(centralwidget); lESet->setObjectName(QString::fromUtf8("lESet")); lESet->setGeometry(QRect(90, 10, 631, 25)); cBSet = new QCheckBox(centralwidget); cBSet->setObjectName(QString::fromUtf8("cBSet")); cBSet->setGeometry(QRect(90, 40, 141, 22)); pBSet = new QPushButton(centralwidget); pBSet->setObjectName(QString::fromUtf8("pBSet")); pBSet->setGeometry(QRect(10, 10, 71, 21)); pBDelete = new QPushButton(centralwidget); pBDelete->setObjectName(QString::fromUtf8("pBDelete")); pBDelete->setGeometry(QRect(370, 70, 71, 21)); lEMove = new QLineEdit(centralwidget); lEMove->setObjectName(QString::fromUtf8("lEMove")); lEMove->setGeometry(QRect(90, 70, 251, 25)); lEDelete = new QLineEdit(centralwidget); lEDelete->setObjectName(QString::fromUtf8("lEDelete")); lEDelete->setGeometry(QRect(450, 70, 271, 25)); this->setCentralWidget(centralwidget); menubar = new QMenuBar(this); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 776, 29)); menuFile = new QMenu(menubar); menuFile->setObjectName(QString::fromUtf8("menuFile")); this->setMenuBar(menubar); statusbar = new QStatusBar(this); statusbar->setObjectName(QString::fromUtf8("statusbar")); statusbar->setGeometry(QRect(0, 595, 776, 22)); this->setStatusBar(statusbar); sSView = new SvgStreamWidget(this); sSView->setObjectName(QString::fromUtf8("sAView")); sSView->setGeometry(QRect(10, 160, 750, 450)); menubar->addAction(menuFile->menuAction()); menuFile->addAction(actionOpen); retranslateUi(); QObject::connect(actionOpen, SIGNAL(triggered()), this, SLOT(openFile())); QObject::connect(pBSet, SIGNAL(clicked()), this, SLOT(setElement())); QObject::connect(pBMove, SIGNAL(clicked()), this, SLOT(moveElement())); QObject::connect(pBDelete, SIGNAL(clicked()), this, SLOT(removeElement())); } // setupUi