本文整理汇总了C++中ri函数的典型用法代码示例。如果您正苦于以下问题:C++ ri函数的具体用法?C++ ri怎么用?C++ ri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ri函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ci
void Polynomial::print() {
int n = ci.rows();
std::cout << "P(x) = ";
if (n == 0) {
std::cout << "?" << std::endl;
} else {
for (int i = n - 1; i >= 0; i--) {
if (i > 0) {
std::cout << ci(i) << " + ";
} else {
std::cout << ci(i);
}
if (i > 0) {
if (ri(i) == 0) {
std::cout << "x * ";
} else {
std::cout << "(x - " << ri(i) << ") * ";
}
if (i > 1) std::cout << "( ";
}
}
for (int i = n - 1; i > 1; i--) {
std::cout << " )";
}
std::cout << std::endl;
}
}
示例2: ri
//------------------------------------------------------------------------------
void
Canvas::DrawAnnulus(int x, int y,
unsigned inner_r, unsigned outer_r,
Angle start, Angle end)
{
QPainterPath p;
QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r);
QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r);
// Draw the inner radius of the annulus.
p.arcMoveTo(ri, start.Degrees());
p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees());
if (start != end)
{ // Only draw the end caps when needed.
// The currentPosition() will be at the end of the inner circle. Draw
// one side of the annulus.
// \todo This doesn't work because Angle(360) != Angle(0)!
double xx = (outer_r - inner_r) * cos(end.Radians()) +
p.currentPosition().rx();
double yy = (outer_r - inner_r) * -sin(end.Radians()) +
p.currentPosition().ry();
p.lineTo(xx, yy);
}
else
p.arcMoveTo(ro, end.Degrees()); // Set up for the outer circle.
// The currentPosition() will be at the 'end' of the outer circle. Draw the
// outer to the start.
p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees());
if (start != end)
{// And close it off to finish up.
p.closeSubpath();
}
this->pushObject(p, this->pen(), this->brush());
}
示例3: ri
float Animal_Wild_Flee::postCondition()
{
/*
* Fleeing from an approaching player has the following postconditions:
* - There is no character in flight range.
* - There is an character attacking us.
* - Our owner has come in range.
*
*/
if( m_npc->attackTarget() )
return 1.0f;
RegionIterator4Chars ri( m_npc->pos(), SrvParams->animalWildFleeRange() );
bool found = false;
for(ri.Begin(); !ri.atEnd(); ri++)
{
P_PLAYER pPlayer = dynamic_cast<P_PLAYER>(ri.GetData());
if( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
found = true;
if( pPlayer && m_npc->owner() == pPlayer )
return 1.0f;
}
if( found )
return 0.0f;
return 1.0f;
}
示例4: ri
U32 Mesh::Manager::Report()
{
U32 countT = 0, memT = 0;
NBinTree<MeshRoot>::Iterator ri(&rootTree);
while (MeshRoot * root = ri++)
{
if (!root->isChunk)
{
memT += root->GetMem();
countT++;
}
}
U32 countE = 0, memE = 0;
NList<MeshEnt>::Iterator ei(&entList);
while (MeshEnt * ent = ei++)
{
memE += ent->GetMem();
countE++;
}
U32 mem = memT + memE + endVar - startVar; // namespace
CON_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) );
LOG_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) );
CON_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) );
LOG_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) );
return mem;
}
示例5: qWarning
void RenderThread::run()
{
DEBUGOUT << "RenderThread for" << renderMe << "started";
QImage renderImage = RenderUtils::renderPagePart(m_page.page, renderMe.requestedPageSize(), renderMe.pagePart());
if ( renderImage.isNull() )
{
qWarning() << "RenderThread for" << renderMe << "failed";
QSharedPointer<RenderingIdentifier> ri( new RenderingIdentifier(renderMe) );
emit renderingFailed(ri);
return;
}
QList< AdjustedLink > links;
for( Poppler::Link* link: m_page.page->links() )
{
QSharedPointer<Poppler::Link> ptrLink(link);
try{
AdjustedLink al(renderMe, ptrLink);
links.append(al);
} catch( AdjustedLink::OutsidePage & e) {
// no-op
}
}
QSharedPointer<RenderedPage> renderResult(new RenderedPage( renderImage, links, renderMe ));
DEBUGOUT << "RenderThread for" << renderMe << "successful, image has size" << renderResult->getImage().size();
emit renderingFinished(renderResult);
}
示例6: alloc
void inductive_property::to_model(model_ref& md) const {
md = alloc(model, m);
vector<relation_info> const& rs = m_relation_info;
expr_ref_vector conjs(m);
for (unsigned i = 0; i < rs.size(); ++i) {
relation_info ri(rs[i]);
func_decl * pred = ri.m_pred;
expr_ref prop = fixup_clauses(ri.m_body);
func_decl_ref_vector const& sig = ri.m_vars;
expr_ref q(m);
expr_ref_vector sig_vars(m);
for (unsigned j = 0; j < sig.size(); ++j) {
sig_vars.push_back(m.mk_const(sig[sig.size()-j-1]));
}
expr_abstract(m, 0, sig_vars.size(), sig_vars.c_ptr(), prop, q);
if (sig.empty()) {
md->register_decl(pred, q);
}
else {
func_interp* fi = alloc(func_interp, m, sig.size());
fi->set_else(q);
md->register_decl(pred, fi);
}
}
TRACE("pdr", model_smt2_pp(tout, m, *md, 0););
示例7: ri
void TLevelWriterMov::save(const TImageP &img, int frameIndex) {
TRasterImageP ri(img);
if (!img) throw TImageException(getFilePath(), "Unsupported image type");
TRasterP ras(ri->getRaster());
int lx = ras->getLx(), ly = ras->getLy(), pixSize = ras->getPixelSize();
if (pixSize != 4)
throw TImageException(getFilePath(), "Unsupported pixel type");
int size = lx * ly * pixSize;
// Send messages
QLocalSocket socket;
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
t32bitsrv::srvCmdline());
tipc::Stream stream(&socket);
tipc::Message msg;
// Send the write message.
stream << (msg << QString("$LWMovImageWrite") << m_id << frameIndex << lx
<< ly);
// Send the data through a shared memory segment
{
t32bitsrv::RasterExchanger<TPixel32> exch(ras);
tipc::writeShMemBuffer(stream, msg << tipc::clr, size, &exch);
}
if (tipc::readMessage(stream, msg) != "ok")
throw TImageException(getFilePath(), "Couln't save image");
}
示例8: IVP_U_Float_Point
void CShadowController::AttachObject( void )
{
IVP_Real_Object *pivp = m_pObject->GetObject();
IVP_Core *pCore = pivp->get_core();
m_saveRot = pCore->rot_speed_damp_factor;
m_savedRI = *pCore->get_rot_inertia();
m_savedMass = pCore->get_mass();
m_savedMaterialIndex = m_pObject->GetMaterialIndexInternal();
m_pObject->SetMaterialIndex( MATERIAL_INDEX_SHADOW );
pCore->rot_speed_damp_factor = IVP_U_Float_Point( 100, 100, 100 );
if ( !m_allowPhysicsRotation )
{
IVP_U_Float_Point ri( 1e15f, 1e15f, 1e15f );
pCore->set_rotation_inertia( &ri );
}
if ( !m_allowPhysicsMovement )
{
m_pObject->SetMass( 1e6f );
//pCore->inv_rot_inertia.hesse_val = 0.0f;
m_pObject->EnableGravity( false );
}
pCore->calc_calc();
pivp->get_environment()->get_controller_manager()->add_controller_to_core( this, pCore );
m_shadow.lastPosition.set_to_zero();
}
示例9: ri
RationalNumber RationalNumber::operator/(const int i) const {
RationalNumber ri(i);
RationalNumber rr(*this);
rr /= ri;
rr.normalize();
return rr;
}
示例10: main
int
main (int argc, char **argv)
{
/* YOUR CODE HERE */
ssize_t raw_sklen = 32;
char* skfname = argv[1];
if (argc != 2) {
usage (argv[0]);
}
else {
setprogname (argv[0]);
/* first, let's create a new symmetric key */
ri ();
/* Note that since we'll need to do both AES-CTR and AES-CBC-MAC,
there are actuall *two* symmetric keys, which could, e.g., be
stored contiguosly in a buffer */
/* YOUR CODE HERE */
char* buffer = (char*)malloc(raw_sklen * sizeof(char));
prng_getbytes(buffer, raw_sklen);
/* now let's armor and dump to disk the symmetric key buffer */
/* YOUR CODE HERE */
write_skfile(skfname, buffer, raw_sklen);
bzero(buffer, raw_sklen);
free(buffer);
/* finally, let's scrub the buffer that held the random bits
by overwriting with a bunch of 0's */
}
return 0;
}
示例11: StartTrace
Application *Application::GetGlobalApplication(String &applicationName)
{
StartTrace(Application.GetGlobalApplication);
Application *application = 0;
if (!fgConfig.IsNull()) {
Anything applicationConf;
if (fgConfig.LookupPath(applicationConf, "Application") ) {
for (long i = 0, sz = applicationConf.GetSize() && !application; i < sz; ++i) {
// iterate over the applicationname list
applicationName = applicationConf[i].AsCharPtr(0);
if ( applicationName.Length() > 0 ) {
// return the first application object found by name
application = Application::FindApplication(applicationName);
break;
}
}
} else {
// if no application object is configured in the config any
// return the first in the list
RegistryIterator ri(MetaRegistry::instance().GetRegistry("Application"), false);
for ( ; ri.HasMore() && !application ; application = SafeCast(ri.Next(applicationName), Application));
}
}
return application;
}
示例12: response
int response(UOXSOCKET s, P_CHAR pPlayer, char* SpeechUpr)
{
char *comm=SpeechUpr;
if (strstr( comm, "#EMPTY") && online(currchar[s]) && !pPlayer->dead && pPlayer->isGM())
{ // restricted to GMs for now. It's too powerful (Duke, 5.6.2001)
target(s, 0, 1, 0, 71, "Select container to empty:");
return 1;
}
if (!online(DEREF_P_CHAR(pPlayer)) || pPlayer->dead)
return 0;
P_CHAR pc;
cRegion::RegionIterator4Chars ri(pPlayer->pos);
for (ri.Begin(); (pc=ri.GetData()) != ri.End(); ri++)
{
if (pc->isPlayer()) // only npcs will respond automagically, players still have to do that themselves ;)
continue;
if (pPlayer->dist(pc) > 16) // at least they should be on the screen
continue;
if (pPlayer->isSameAs(pc)) // not talking to ourselves
continue;
if (StableSpeech(pc, comm, pPlayer, s))
return 1;
if (UnStableSpeech(pc, comm, pPlayer, s))
return 1;
if (ShieldSpeech(pc, comm, pPlayer, s))
return 1;
if (QuestionSpeech(pc, comm, pPlayer, s))
return 1;
if (PackupSpeech(pc, comm, pPlayer, s))
return 1;
if (TriggerSpeech(pc, comm, pPlayer, s))
return 1;
if (EscortSpeech(pc, comm, pPlayer, s))
return 1;
if (BankerSpeech(pc, comm, pPlayer, s))
return 1;
if (TrainerSpeech(pc, comm, pPlayer, s))
return 1;
if (PetCommand(pc, comm, pPlayer, s))
return 1;
if (VendorSpeech(pc, comm, pPlayer, s))
return 1;
}
return 0;
}
示例13: data
DrawableTextureDataP texture_utils::getTextureData(
const TXshSimpleLevel *sl, const TFrameId &fid, int subsampling)
{
const std::string &texId = sl->getImageId(fid);
// Now, we must associate a texture
DrawableTextureDataP data(TTexturesStorage::instance()->getTextureData(texId));
if (data)
return data;
// There was no associated texture. We must bind the texture and repeat
// First, retrieve the image to be used as texture
TRasterImageP ri(::getTexture(sl, fid, subsampling));
if (!ri)
return DrawableTextureDataP();
TRaster32P ras(ri->getRaster());
assert(ras);
TRectD geom(0, 0, ras->getLx(), ras->getLy());
geom = TScale(ri->getSubsampling()) *
TTranslation(convert(ri->getOffset()) - ras->getCenterD()) *
geom;
return TTexturesStorage::instance()->loadTexture(texId, ras, geom);
}
示例14: findmulti
P_ITEM findmulti(Coord_cl pos) //Sortta like getboat() only more general... use this for other multi stuff!
{
int lastdist = 30;
P_ITEM multi = NULL;
int ret;
cRegion::RegionIterator4Items ri(pos);
for (ri.Begin(); !ri.atEnd(); ri++)
{
P_ITEM mapitem = ri.GetData();
if (mapitem != NULL)
{
if (mapitem->isMulti())
{
ret = pos.distance(mapitem->pos);
if (ret <= lastdist)
{
lastdist = ret;
if (inmulti(pos, mapitem))
multi = mapitem;
}
}
}
}
return multi;
}
示例15: getImage
void FullColorBrushTool::onEnter()
{
TImageP img = getImage(false);
TRasterImageP ri(img);
if (ri) {
m_minThick = m_thickness.getValue().first;
m_maxThick = m_thickness.getValue().second;
} else {
m_minThick = 0;
m_maxThick = 0;
}
Application *app = getApplication();
if (app->getCurrentObject()->isSpline()) {
m_currentColor = TPixel32::Red;
return;
}
TPalette *plt = app->getCurrentPalette()->getPalette();
if (!plt)
return;
int style = app->getCurrentLevelStyleIndex();
TColorStyle *colorStyle = plt->getStyle(style);
m_currentColor = colorStyle->getMainColor();
}