本文整理汇总了C++中setElement函数的典型用法代码示例。如果您正苦于以下问题:C++ setElement函数的具体用法?C++ setElement怎么用?C++ setElement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setElement函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEye
/// 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;
}
示例2: switch
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;
}
}
示例3: setIdentityMatrix
mat4& mat4::setScalingMatrix(const vec3& scaling)
{
setIdentityMatrix();
setElement(0, 0, scaling.x);
setElement(1, 1, scaling.y);
setElement(2, 2, scaling.z);
return *this;
}
示例4: assert
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 );
}
示例5: reset
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;
}
}
示例6: SetZSetMember
void SetZSetMember(const Data& v)
{
if (type == KEY_ZSET_SCORE)
{
setElement(v, 0);
}
else
{
setElement(v, 1);
}
}
示例7: zero
//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);
}
}
}
示例8: matrixMultiply
//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;
}
示例9: elem
/**
* 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());
}
}
}
示例10: tan
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;
}
示例11: uassert
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 );
}
}
示例12: worldPoint
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);
}
}
}
}
}
}
}
示例13: isScalar
bool vesUniform::set(const vesVector4f &vector)
{
if (this->m_numberElements == 0)
this->m_numberElements = 1;
return isScalar() ? setElement(0, vector) : false;
}
示例14: assert
// 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 );
}
示例15: adjustCamera
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 );
}