void AABB::transform(const Mat4& mat) { Vec3 corners[8]; // Near face, specified counter-clockwise // Left-top-front. corners[0].set(_min.x, _max.y, _max.z); // Left-bottom-front. corners[1].set(_min.x, _min.y, _max.z); // Right-bottom-front. corners[2].set(_max.x, _min.y, _max.z); // Right-top-front. corners[3].set(_max.x, _max.y, _max.z); // Far face, specified clockwise // Right-top-back. corners[4].set(_max.x, _max.y, _min.z); // Right-bottom-back. corners[5].set(_max.x, _min.y, _min.z); // Left-bottom-back. corners[6].set(_min.x, _min.y, _min.z); // Left-top-back. corners[7].set(_min.x, _max.y, _min.z); // Transform the corners, recalculate the min and max points along the way. for (int i = 0; i < 8; i++) mat.transformPoint(&corners[i]); reset(); updateMinMax(corners, 8); }
int projectPt(pt0 *pt, laserHDL32 *shot, calibTable *cal, surveyState *ss){ double xyDistance, distance; distance = ss->cal->distC + (double)shot->distance; /* cull points closer than blanking distance and out of range*/ /* if (shot->distance < BLANK_DIST || shot->distance == 0) */ if (shot->distance < BLANK_DIST || shot->distance > 2000 || shot->distance == 0) //XXXDEBUG return 0; xyDistance = distance * cal->cosVertC; pt->x = (int32_t)(ss->refPt.x + xyDistance * sin( ss->bearing DEG2RAD + cal->rotC) ); pt->y = (int32_t)(ss->refPt.y + xyDistance * cos( ss->bearing DEG2RAD + cal->rotC) ); pt->z = (int32_t)(ss->refPt.z + distance * cal->sinVertC); pt->intensity = shot->intensity * ISCALE_HDL32E; updateMinMax(pt, &ss->min, &ss->max); pt->returnNum = 1; pt->returnsTot = 1; return 1; }
/*! Initializes a DOF by giving it the owning robot \a myRobot, and the list of joints connected to this DOF, \a jList. Also sets the max and min vals of the DOF from the smallest range of the joint limits. */ void DOF::initDOF(Robot *myRobot,const std::vector<Joint *>& jList) { owner = myRobot; jointList = jList; // copy jList updateMinMax(); }
/*! getter for current the current max object space vertex. */ const SLVec3f& SLSkeleton::maxOS() { if (_minMaxOutOfDate) updateMinMax(); return _maxOS; }
void Dataset::setSamples(const vectord &y) { mY = y; for (size_t i=0; i<y.size(); ++i) { updateMinMax(i); } };
void Dataset::setSamples(const matrixd &x, const vectord &y) { // WARNING: It assumes mX is empty mY = y; for (size_t i=0; i<x.size1(); ++i) { mX.push_back(row(x,i)); updateMinMax(i); } };
void GenericSlider::setCurrentMinMax(double _min, double _max) { if((limited)&&(_max>max))_max=max; if((limited)&&(_min<min))_min=min; if(_max<_min)return; currentMax=_max; currentMin=_min; updateMinMax(currentMin,currentMax); }
/** * This function crosses a connected component * and calculates the number of black boxes. * * @param i Current y coordinate * @param j Current x coordinate * @param matrix Binary matrix * @param mark Matrix of marks * * @return Number of black boxes */ void crossCC(int y, int x, t_cc_elt *elt, t_matrix *matrix, char **mark) { int i, j, kmin, kmax, pmin, pmax, first; int pix_count; int xtmp, ytmp; t_coordinate *coord, *res; t_box_coordinate *minmax; t_queue **q; pix_count = 1; q = NULL; q = (t_queue **)wcalloc(1, sizeof(t_queue *)); xtmp = x; ytmp = y; minmax = wcalloc(1, sizeof(t_box_coordinate)); minmax->xmin = x; minmax->xmax = x; minmax->ymin = y; minmax->ymax = y; first = 1; do { if (!first) { res = qDequeue(q); if (res != NULL) { xtmp = res->x; ytmp = res->y; } } kmin = ytmp-1; if (kmin < 0) kmin = 0; kmax = ytmp+1; if (kmax >= matrix->nbrows) kmax = matrix->nbrows - 1; for (i=kmin; i <= kmax; i++) { pmin = xtmp-1; if (pmin < 0) pmin = 0; pmax = xtmp+1; if (pmax >= matrix->nbcols) pmax = matrix->nbcols - 1; for (j=pmin; j <= pmax; j++) { if ((matrix->data[i][j] == 1) && (mark[i][j] == 'o')) { coord = wmalloc(sizeof(t_coordinate)); coord->x = j; coord->y = i; qEnqueue(q, coord); mark[i][j] = 'x'; updateMinMax(minmax, j, i); pix_count++; } } } first = 0; } while (*q != NULL); elt->coord = *minmax; elt->nbpix = pix_count; qDelete(q); wfree(q); }
void BoundingVolume::transform(const Matrix& m) { // Transform the bounding sphere m.transformPoint(center, ¢er); Vector3 translate; m.decompose(&translate, NULL, NULL); float r = radius * translate.x; r = std::max(radius, radius * translate.y); r = std::max(radius, radius * translate.z); radius = r; // Transform the bounding box Vector3 corners[8]; corners[0].set(min.x, max.y, max.z); // Left-bottom-front. corners[1].set(min.x, min.y, max.z); // Right-bottom-front. corners[2].set(max.x, min.y, max.z); // Right-top-front. corners[3].set(max.x, max.y, max.z); // Right-top-back. corners[4].set(max.x, max.y, min.z); // Right-bottom-back. corners[5].set(max.x, min.y, min.z); // Left-bottom-back. corners[6].set(min.x, min.y, min.z); // Left-top-back. corners[7].set(min.x, max.y, min.z); // Transform the corners, recalculating the min and max points along the way. m.transformPoint(corners[0], &corners[0]); Vector3 newMin = corners[0]; Vector3 newMax = corners[0]; for (int i = 1; i < 8; i++) { m.transformPoint(corners[i], &corners[i]); updateMinMax(&corners[i], &newMin, &newMax); } min = newMin; max = newMax; }
void BoundingBox::transform(const Matrix& matrix) { // Calculate the corners. Vector3 corners[8]; getCorners(corners); // Transform the corners, recalculating the min and max points along the way. matrix.transformPoint(&corners[0]); Vector3 newMin = corners[0]; Vector3 newMax = corners[0]; for (int i = 1; i < 8; i++) { matrix.transformPoint(&corners[i]); updateMinMax(&corners[i], &newMin, &newMax); } this->min.x = newMin.x; this->min.y = newMin.y; this->min.z = newMin.z; this->max.x = newMax.x; this->max.y = newMax.y; this->max.z = newMax.z; }
void BoundingBox::transform(const kmMat4& matrix) { // Calculate the corners. kmVec3 corners[8]; getCorners(corners); // Transform the corners, recalculating the min and max points along the way. //matrix.transformPoint(&corners[0]); kmMat3Transform(&corners[0], &matrix, corners[0].x, corners[0].y, corners[0].z, 1.0f); kmVec3 newMin = corners[0]; kmVec3 newMax = corners[0]; for (int i = 1; i < 8; i++) { //matrix.transformPoint(&corners[i]); kmMat3Transform(&corners[i], &matrix, corners[i].x, corners[i].y, corners[i].z, 1.0f); updateMinMax(&corners[i], &newMin, &newMax); } this->min.x = newMin.x; this->min.y = newMin.y; this->min.z = newMin.z; this->max.x = newMax.x; this->max.y = newMax.y; this->max.z = newMax.z; }
/** * Process events comming to the slider * @param object :: pointer to the slider * @param e :: event */ bool XIntegrationScrollBar::eventFilter(QObject *object, QEvent *e) { QPushButton* slider = dynamic_cast<QPushButton*>(object); if (!slider) return false; if( e->type() == QEvent::Leave) { if (QApplication::overrideCursor()) { QApplication::restoreOverrideCursor(); } return true; } else if( e->type() == QEvent::MouseButtonPress) { QMouseEvent* me = static_cast<QMouseEvent*>(e); m_x = me->x(); m_width = m_slider->width(); if (m_x < m_resizeMargin) { m_resizingLeft = true; } else if (m_x > m_width - m_resizeMargin) { m_resizingRight = true; } else { m_moving = true; } } else if( e->type() == QEvent::MouseButtonRelease) { m_resizingLeft = false; m_resizingRight = false; m_moving = false; if (m_changed) { emit changed(m_minimum,m_maximum); } m_changed = false; } else if( e->type() == QEvent::MouseMove) { QMouseEvent* me = static_cast<QMouseEvent*>(e); int x = me->x(); int w = m_slider->width(); if (x < m_resizeMargin || x > w - m_resizeMargin) { if (!QApplication::overrideCursor()) { QApplication::setOverrideCursor(QCursor(Qt::SizeHorCursor)); } } else { QApplication::restoreOverrideCursor(); } if (m_moving) { int idx = x - m_x; int new_x = m_slider->x() + idx; if (new_x >= 0 && new_x + m_slider->width() <= this->width()) { int new_y = m_slider->y(); m_slider->move(new_x,new_y); m_changed = true; updateMinMax(); } } else if (m_resizingLeft) { int idx = x - m_x; int new_x = m_slider->x() + idx; int new_w = m_slider->width() - idx; if (new_x >=0 && new_w > 2*m_resizeMargin) { m_slider->move(new_x,m_slider->y()); m_slider->resize(new_w,m_slider->height()); m_changed = true; updateMinMax(); } } else if (m_resizingRight) { int dx = x - m_x; int new_w = m_width + dx; int xright = m_slider->x() + new_w; if (xright <= this->width() && new_w > 2*m_resizeMargin) { m_slider->resize(new_w,m_slider->height()); m_changed = true; updateMinMax(); } } return true; } return false; }
void BoundingBox::enlarge(const Vector3& point) { updateMinMax(&point, &min, &max); }
//================================================================== void Hider::Bust( const HiderBucket &bucket, ShadedGrid &shadGrid, const WorkGrid &workGrid, DVec<HiderPixel> &pixels, u_int screenWd, u_int screenHe ) const { const SlColor *pOi = (const SlColor *)workGrid.mSymbolIs.FindSymbolIData( "Oi" ); const SlColor *pCi = (const SlColor *)workGrid.mSymbolIs.FindSymbolIData( "Ci" ); //const Float3_ *pN = (const Float3_ *)workGrid.mSymbolIs.FindSymbolIData( "N" ); { static const Float_ one( 1 ); Float_ screenCx = Float_( screenWd * 0.5f ); Float_ screenCy = Float_( screenHe * 0.5f ); Float_ screenHWd = Float_( screenWd * 0.5f ); Float_ screenHHe = Float_( screenHe * 0.5f ); const Float3_ *pPointsCS = (const Float3_ *)workGrid.mpPointsCS; size_t blocksN = DMT_SIMD_BLOCKS( workGrid.mPointsN ); for (size_t blkIdx=0; blkIdx < blocksN; ++blkIdx) { Float4_ homoP = V4__V3W1_Mul_M44<Float_>( pPointsCS[ blkIdx ], mOptions.mMtxCamProj ); Float4_ projP = homoP / homoP.w(); shadGrid.mpPointsCS[ blkIdx ] = pPointsCS[ blkIdx ]; //shadGrid.mpPointsCloseCS[ blkIdx ] = 0; shadGrid.mpPosWin[ blkIdx ][0] = projP.x() * screenHWd + screenCx; shadGrid.mpPosWin[ blkIdx ][1] = -projP.y() * screenHHe + screenCy; shadGrid.mpCi[ blkIdx ] = pCi[ blkIdx ]; shadGrid.mpOi[ blkIdx ] = pOi[ blkIdx ]; } } DASSERT( workGrid.mXDim == DMT_SIMD_BLOCKS( workGrid.mXDim ) * DMT_SIMD_FLEN ); u_int xN = workGrid.mXDim - 1; u_int yN = workGrid.mYDim - 1; u_int buckWd = bucket.GetWd(); u_int buckHe = bucket.GetHe(); if ( mParams.mDbgRasterizeVerts ) { // scan the grid.. for every vertex size_t srcVertIdx = 0; for (u_int i=0; i < yN; ++i) { for (u_int j=0; j < xN; ++j, ++srcVertIdx) { u_int blk = (u_int)srcVertIdx / DMT_SIMD_FLEN; u_int sub = (u_int)srcVertIdx & (DMT_SIMD_FLEN-1); int pixX = (int)floor( shadGrid.mpPosWin[ blk ][0][ sub ] - (float)bucket.mX1 ); int pixY = (int)floor( shadGrid.mpPosWin[ blk ][1][ sub ] - (float)bucket.mY1 ); if ( pixX >= 0 && pixY >= 0 && pixX < (int)buckWd && pixY < (int)buckHe ) { HiderPixel &pixel = pixels[ pixY * buckWd + pixX ]; HiderSampleData &sampData = Dgrow( pixel.mpSampDataLists[0] ); sampData.mOi[0] = shadGrid.mpOi[ blk ][0][ sub ]; sampData.mOi[1] = shadGrid.mpOi[ blk ][1][ sub ]; sampData.mOi[2] = shadGrid.mpOi[ blk ][2][ sub ]; sampData.mCi[0] = shadGrid.mpCi[ blk ][0][ sub ]; sampData.mCi[1] = shadGrid.mpCi[ blk ][1][ sub ]; sampData.mCi[2] = shadGrid.mpCi[ blk ][2][ sub ]; sampData.mDepth = shadGrid.mpPointsCS[ blk ][2][ sub ]; } } srcVertIdx += 1; } } else { // scan the grid.. for every potential micro-polygon size_t srcVertIdx = 0; for (u_int i=0; i < yN; ++i) { for (u_int j=0; j < xN; ++j, ++srcVertIdx) { // vector coords of the micro-poly u_int vidx[4] = { (u_int)srcVertIdx + 0, (u_int)srcVertIdx + 1, (u_int)srcVertIdx + xN+1, (u_int)srcVertIdx + xN+2 }; Float3 minPos( FLT_MAX, FLT_MAX, FLT_MAX ); Float3 maxPos( -FLT_MAX, -FLT_MAX, -FLT_MAX ); // calculate the bounds in window space and orientation // -------- // | /\ | // |/ \ | // |\ /| // | \ / | // -------- size_t blk[4]; size_t sub[4]; Float3 buckPos[4]; for (size_t k=0; k < 4; ++k) { blk[k] = vidx[k] / DMT_SIMD_FLEN; sub[k] = vidx[k] & (DMT_SIMD_FLEN-1); buckPos[k][0] = shadGrid.mpPosWin[ blk[k] ][0][ sub[k] ] - (float)bucket.mX1; buckPos[k][1] = shadGrid.mpPosWin[ blk[k] ][1][ sub[k] ] - (float)bucket.mY1; buckPos[k][2] = shadGrid.mpPointsCS[ blk[k] ][2][ sub[k] ]; updateMinMax( minPos, maxPos, buckPos[k] ); } // sample only from the first vertex.. no bilinear // interpolation in the micro-poly ! float valOi[3] = { shadGrid.mpOi[ blk[0] ][0][ sub[0] ], shadGrid.mpOi[ blk[0] ][1][ sub[0] ], shadGrid.mpOi[ blk[0] ][2][ sub[0] ] }; float valCi[3] = { shadGrid.mpCi[ blk[0] ][0][ sub[0] ], shadGrid.mpCi[ blk[0] ][1][ sub[0] ], shadGrid.mpCi[ blk[0] ][2][ sub[0] ] }; addMPSamples( *bucket.mpSampCoordsBuff, &pixels[0], minPos, maxPos, (int)buckWd, (int)buckHe, buckPos, valOi, valCi ); } srcVertIdx += 1; } } }