void Movable::collision( Map &map, vector<Movable *> &movables ) { if( !alive()) return; if( x() < 0 || y() < 0 || x() >= map.Width() || y() >= map.Height() || map( x(), y() ).block & BLOCKED || map( rx(), ry() ).block & block_dir[ direction() ] || map( x(), y() ).block & block_rdir[ direction() ] ) { x( rx()); y( ry()); moving( false ); return; } for( IDX i = 0; i < movables.size(); ++i ) { if( this != movables[i] && movables[i]->alive()) { if( x() == movables[i]->x() && y() == movables[i]->y() && movables[i]->alive()) { x( rx()); y( ry()); moving( false ); hit( movables[i], map, movables ); } } } }
static Pos2 random_robot_pos2(const FieldGeometry *f) { std::uniform_real_distribution<Float> rx( -f->field_length / 2 + ROBOT_DIAM / 2, f->field_length / 2 + ROBOT_DIAM / 2); std::uniform_real_distribution<Float> ry(-f->field_width / 2 + ROBOT_DIAM / 2, f->field_width / 2 + ROBOT_DIAM / 2); std::uniform_real_distribution<Float> rw(-RAD(180), RAD(180)); // return std::forward(rx(gen), ry(gen), rw(gen)); return {rx(gen), ry(gen), rw(gen)}; }
RelTest rtest_eq_dom_check(View x, View y) { ViewRanges<View> rx(x), ry(y); while (rx() && ry()) { if (rx.max() < ry.min()) { ++rx; } else if (ry.max() < rx.min()) { ++ry; } else return RT_MAYBE; } return RT_FALSE; }
Path SVGRectElement::toPathData() const { FloatRect rect(x().value(this), y().value(this), width().value(this), height().value(this)); bool hasRx = hasAttribute(SVGNames::rxAttr); bool hasRy = hasAttribute(SVGNames::ryAttr); if (hasRx || hasRy) { float _rx = hasRx ? rx().value(this) : ry().value(this); float _ry = hasRy ? ry().value(this) : rx().value(this); return Path::createRoundedRectangle(rect, FloatSize(_rx, _ry)); } return Path::createRectangle(rect); }
KCanvasPath* SVGRectElement::toPathData() const { float _x = x()->baseVal()->value(), _y = y()->baseVal()->value(); float _width = width()->baseVal()->value(), _height = height()->baseVal()->value(); bool hasRx = hasAttribute(String("rx").impl()); bool hasRy = hasAttribute(String("ry").impl()); if(hasRx || hasRy) { float _rx = hasRx ? rx()->baseVal()->value() : ry()->baseVal()->value(); float _ry = hasRy ? ry()->baseVal()->value() : rx()->baseVal()->value(); return KCanvasCreator::self()->createRoundedRectangle(_x, _y, _width, _height, _rx, _ry); } return KCanvasCreator::self()->createRectangle(_x, _y, _width, _height); }
////////////////////////////////////////////////////////////////////// /// @brief Add the circle and assign the position and radius with yellow /// @param pos /// @param vel ////////////////////////////////////////////////////////////////////// void Physicsworld::addYellowObject(Vec4 pos,Vec4 vel) { Rigidbody ry(pos, 1.0f, colour.yellow().r,colour.yellow().g,colour.yellow().b); ry.setVelocity(vel); Objectslist.push_back(ry); }
U32 Movable::back( Movable &m ) { I32 dx = m.rx() - rx(); I32 dy = m.ry() - ry(); if( dx == 0 ) { if( dy < 0 ) { direction( South ); } else { direction( North ); } } else if( dy == 0 ) { if( dx > 0 ) { direction( West ); } else { direction( East ); } } else { if( abs( dx ) < abs( dy )) { if( dx > 0 ) { direction( West ); } else { direction( East ); } } else { if( dy < 0 ) { direction( South ); } else { direction( North ); } } } return direction(); }
void Movable::trymove( Map &map, vector<Movable *> &movables, bool test ) { if( !alive() || moving()) { return; } rx( x()); ry( y()); switch( direction()) { case North: y()--; break; case East: x()++; break; case South: y()++; break; case West: x()--; break; default: enforce( false, "Bad Direction!" ); } moving( 1 ); if( test ) { collision( map, movables ); } }
void XYView::request(Requisition& req) const { TransformSetter::request(req); Requirement rx(xsize_orig_); Requirement ry(ysize_orig_); req.require_x(rx); req.require_y(ry); }
void VStrut::request(Requisition& requisition) const { Coord height = ascent_ + descent_; Requirement rx(natural_, stretch_, shrink_, 0); Requirement ry(height, 0, 0, (height == 0) ? 0 : descent_ / height); requisition.require(Dimension_X, rx); requisition.require(Dimension_Y, ry); }
void HStrut::request(Requisition& requisition) const { Coord width = left_bearing_ + right_bearing_; Requirement rx(width, 0, 0, (width == 0) ? 0 : left_bearing_ / width); Requirement ry(natural_, stretch_, shrink_, 0); requisition.require(Dimension_X, rx); requisition.require(Dimension_Y, ry); }
LineSegment RectangleShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const { const FloatRect& bounds = shapeMarginBounds(); if (bounds.isEmpty()) return LineSegment(); float y1 = logicalTop.toFloat(); float y2 = (logicalTop + logicalHeight).toFloat(); if (y2 < bounds.y() || y1 >= bounds.maxY()) return LineSegment(); float x1 = bounds.x(); float x2 = bounds.maxX(); float marginRadiusX = rx() + shapeMargin(); float marginRadiusY = ry() + shapeMargin(); if (marginRadiusY > 0) { if (y2 < bounds.y() + marginRadiusY) { float yi = y2 - bounds.y() - marginRadiusY; float xi = ellipseXIntercept(yi, marginRadiusX, marginRadiusY); x1 = bounds.x() + marginRadiusX - xi; x2 = bounds.maxX() - marginRadiusX + xi; } else if (y1 > bounds.maxY() - marginRadiusY) { float yi = y1 - (bounds.maxY() - marginRadiusY); float xi = ellipseXIntercept(yi, marginRadiusX, marginRadiusY); x1 = bounds.x() + marginRadiusX - xi; x2 = bounds.maxX() - marginRadiusX + xi; } } return LineSegment(x1, x2); }
KCanvasPath* SVGEllipseElement::toPathData() const { float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value(); float _rx = rx()->baseVal()->value(), _ry = ry()->baseVal()->value(); return KCanvasCreator::self()->createEllipse(_cx, _cy, _rx, _ry); }
I32 Movable::dist( Movable &m ) { register I32 dx = abs( m.rx() - rx() ); register I32 dy = abs( m.ry() - ry() ); register I32 d = sqrt( dx * dx + dy * dy ); return d; }
void TextLine::request(Requisition& requisition) const { FontBoundingBox fbb; font_->font_bbox(fbb); Text::request(requisition); Requirement ry(fbb.ascent() + fbb.descent(), 0, 0, 0); requisition.require(Dimension_Y, ry); }
forceinline ExecStatus post_false(Home home, ViewArray<VX>& x, const IntSet& y) { for (int i = x.size(); i--; ) { IntSetRanges ry(y); GECODE_ME_CHECK(x[i].minus_r(home,ry,false)); } return ES_OK; }
//--------------------------------------------------------------------------- void __fastcall TForm1::updateedits(TObject *Sender) { CSpinNr->MaxValue = Ilosc-1; EditX->Text = rx(L[Nr].x); EditY->Text = ry(L[Nr].y); EditQ->Text = L[Nr].q; EditR->Text = L[Nr].r; }
void drawpiece (WINDOW *w, int y, int x, int rot, int piece, int color) { int c, d; wattrset (w, COLOR_PAIR (color)); for (d = 0; d < 4; d++) for (c = 0; c < 4; c++) if (blocks[rx(rot % rots[piece], d, c)][piece][ry(rot % rots[piece], d, c)] != '.') mvwaddstr (w, d + y, (c + x - 1) * 2 - 1, " "); /* 2 spaces */ }
QPointF VideoRendererItem::mapToVideo(const QPointF &pos) { auto hratio = d->mposd->targetSize().width()/d->vtx.width(); auto vratio = d->mposd->targetSize().height()/d->vtx.height(); auto p = pos - d->vtx.topLeft(); p.rx() *= hratio; p.ry() *= vratio; return p; }
Point& Point::operator/=(const int divisor) { if (divisor == 0) throw DivideByZeroException(); rx() /= divisor; ry() /= divisor; return *this; }
bool SVGRectElement::selfHasRelativeLengths() const { return x().isRelative() || y().isRelative() || width().isRelative() || height().isRelative() || rx().isRelative() || ry().isRelative(); }
void Text::request(Requisition& requisition) const { FontBoundingBox fbb; font_->font_bbox(fbb); Requirement rx(width(' ') * initialColumns_, fil, width(' ') * (initialColumns_ - 1), 0); Requirement ry((fbb.ascent() + fbb.descent()) * initialLines_, fil, (fbb.ascent() + fbb.descent()) * (initialLines_ - 1), 0); requisition.require(Dimension_X, rx); requisition.require(Dimension_Y, ry); }
int clip (BRICKTYPE *b) { /*collision detection */ int c, d; for (d = 0; d < 4; d++) for (c = 0; c < 4; c++) if (blocks[rx(b->rot % rots[b->piece], d, c)][b->piece][ry(b->rot % rots[b->piece], d, c)] != '.') { if ((d + b->y < 0) && ((c + b->x - 1 < 1) || (c + b->x - 1 > col_width))) return 1; /* Edge collisions */ else if ((d + b->y >= 0) && (buf[d + b->y][c + b->x - 1])) return 1; } return 0; }
void ModelView::rotate_by(int steps_x, int steps_y) { /* x -> rotate about y axis */ Eigen::Transform3f rx( Eigen::AngleAxis<float>(steps_x * ROTATION_ANGLE_, Eigen::Vector3f(0, 1, 0))); /* y -> rotate about x axis */ Eigen::Transform3f ry( Eigen::AngleAxis<float>(steps_y * ROTATION_ANGLE_, Eigen::Vector3f(1, 0, 0))); user_rotation_ = rx * ry * user_rotation_; }
bool Camera::calcViewRay( Line &line, Int32 x, Int32 y, const Viewport &port, Real32 *t ) { if(port.getPixelWidth() <= 0 || port.getPixelHeight() <= 0) { return false; } Matrix proj, projtrans, view; getProjection(proj, port.getPixelWidth(), port.getPixelHeight()); getProjectionTranslation(projtrans, port.getPixelWidth(), port.getPixelHeight()); getViewing(view, port.getPixelWidth(), port.getPixelHeight()); Matrix wctocc = proj; wctocc.mult(projtrans); wctocc.mult(view); Matrix cctowc; cctowc.invertFrom(wctocc); Real32 rx(0.f), ry(0.f); port.getNormalizedCoordinates(rx, ry, x, y); Pnt3f from, at; cctowc.multFull(Pnt3f(rx, ry, -1), from); cctowc.multFull(Pnt3f(rx, ry, 1), at ); Vec3f dir = at - from; if(t != NULL) { *t = dir.length(); } line.setValue(from, dir); return true; }
void ImageS::mousePressEvent(QMouseEvent *e) { if(e->button()==Qt::LeftButton){ auto cursor = e->pos(); int x = cursor.rx(); int y = cursor.ry()-45; int temp = x/60 + (y/60)*5; if(temp>=0 && temp< imageS.size()) select = temp; } this->update(); }
void Player::changemap( PuzzleNode &puzzle ) { if( puzzle.solved ) { map_id( puzzle.map_id ); rx( x( puzzle.x )); ry( y( puzzle.y )); moving( 0 ); direction( puzzle.direction ); } else { engine.push( new StatePuzzle( engine, puzzle )); } }
inline Vector3 & Vector3::move( const qreal distance, const Angle & angle ) { qreal dc_sin, dc_cos; angle.sincos( &dc_sin, &dc_cos ); rx() += dc_sin * distance; ry() += dc_cos * distance; return *this; }
const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledElement *context) { // All attribute's contexts are equal (so just take the one from 'cx'). const SVGStyledElement *restore = cx()->baseVal()->context(); cx()->baseVal()->setContext(context); cy()->baseVal()->setContext(context); rx()->baseVal()->setContext(context); ry()->baseVal()->setContext(context); SVGStyledElement::pushAttributeContext(context); return restore; }
bool Player::trypull( Direction dir, Map &map, vector<Movable*> &movables ) { Movable *box; if( engine.input.keys[ Key::Space ].down && direction() != dir ) { if(( box = infront( map, movables )) != NULL && (( CHAIR_TYPE <= box->type() && box->type() <= DESK_TYPE && level() > ( box->type() - CHAIR_TYPE )) || ( ZOMBIE_MALE_TYPE <= box->type() && box->type() <= ZOMBIE_FEMALE_TYPE))){ rdir = direction(); restore = true; direction( dir ); trymove( map, movables ); if( moving()) { box->direction( direction()); box->trymove( map, movables ); // test if there is a wall or block between future position if( !box->moving()) { x( rx()); y( ry()); moving( 0 ); } else { if( map( x(), y()).block & block_dir[ rdir ] || map( box->x(), box->y()).block & block_rdir[ rdir ] ) { x( rx()); y( ry()); moving( 0 ); box->moving( 0 ); box->x( box->rx()); box->y( box->ry()); } } } return true; } } return false; }