本文整理汇总了C++中r1函数 的典型用法代码示例。如果您正苦于以下问题:C++ r1函数的具体用法?C++ r1怎么用?C++ r1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r1函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: testSkipListNode
void testSkipListNode()
{
SkipListNode head_bottom;
SkipListNode head_mid;
SkipListNode head_roof;
head_roof.down = &head_mid; head_mid.down = &head_bottom;
head_bottom.up = &head_mid; head_mid.up = &head_roof;
SkipListNode b1(1), b2(2), b3(3), b4(4);
SkipListNode m1(1), m2(2), m4(4);
SkipListNode r1(1), r4(4);
r1.down = &m1; m1.down = &b1;
b1.up = &m1; m1.up = &r1;
r4.down = &m4; m4.down = &b4;
b4.up = &m4; m4.up = &r4;
m2.down = &b2;
b2.up = &m2;
head_bottom.next = &b1; b1.next = &b2; b2.next = &b3; b3.next = &b4;
b4.prev = &b3; b3.prev = &b2; b2.prev = &b1; b1.prev = &head_bottom;
head_mid.next = &m1; m1.next = &m2; m2.next = &m4;
m4.prev = &m2; m2.prev = &m1; m1.prev = &head_mid;
head_roof.next = &r1; r1.next = &r4;
r4.prev = &r1; r1.prev = &head_roof;
std::cout<<head_roof;
std::cout<<head_mid;
std::cout<<head_bottom;
}
开发者ID:littlepretty, 项目名称:MySkipList, 代码行数:36, 代码来源:test.cpp
示例2: r1
void *show_yes_no(void *t, void *msg, void *y, void *n)
{
p_ref r1(t),r2(msg),r3(y),r4(n);
y=eval(y);
n=eval(n);
put_title(lstring_value(eval(t)));
int x1=0,y1=0,x2=79,y2=25;
bar(x1,y1+1,x2,y2,176,0x01);
center_tbox(eval(msg),0x1f);
int key;
char *yes=lstring_value(y);
char *no=lstring_value(n);
set_cursor(0,25);
do
{
key=getch();
set_cursor(0,0);
} while (toupper(key)!=toupper(yes[0]) && toupper(key)!=toupper(no[0]));
cls();
if (toupper(key)==toupper(yes[0]))
return true_symbol;
else return NULL;
}
开发者ID:spippolatore, 项目名称:abuse, 代码行数:24, 代码来源:text_gui.c
示例3: test_int_0
void test_int_0()
{
// function
{
std::function<int ()> r1(f_int_0);
assert(r1() == 3);
}
// function pointer
{
int (*fp)() = f_int_0;
std::function<int ()> r1(fp);
assert(r1() == 3);
}
// functor
{
A_int_0 a0;
std::function<int ()> r1(a0);
assert(r1() == 4);
}
}
开发者ID:32bitmicro, 项目名称:riscv-libcxx, 代码行数:20, 代码来源:invoke.pass.cpp
示例4: wxRound
void RoutePoint::DrawGL( ViewPort &vp, bool use_cached_screen_coords )
{
if( !m_bIsVisible )
return;
// Optimization, especially apparent on tracks in normal cases
if( m_IconName == _T("empty") && !m_bShowName && !m_bPtIsSelected ) return;
if(m_wpBBox.GetValid() &&
vp.view_scale_ppm == m_wpBBox_view_scale_ppm &&
vp.rotation == m_wpBBox_rotation) {
/* see if this waypoint can intersect with bounding box */
LLBBox vpBBox = vp.GetBBox();
if( vpBBox.IntersectOut( m_wpBBox ) ){
// Are Range Rings enabled?
if(m_bShowWaypointRangeRings && (m_iWaypointRangeRingsNumber > 0)){
double factor = 1.00;
if( m_iWaypointRangeRingsStepUnits == 1 ) // convert kilometers to NMi
factor = 1 / 1.852;
double radius = factor * m_iWaypointRangeRingsNumber * m_fWaypointRangeRingsStep / 60.;
LLBBox radar_box = m_wpBBox;
radar_box.EnLarge(radius * 2 );
if( vpBBox.IntersectOut( radar_box ) ){
return;
}
}
else
return;
}
}
wxPoint r;
wxRect hilitebox;
unsigned char transparency = 150;
double platform_pen_width = wxRound(wxMax(1.0, g_Platform->GetDisplayDPmm() / 2)); // 0.5 mm nominal, but not less than 1 pixel
if(use_cached_screen_coords && m_pos_on_screen)
r.x = m_screen_pos.m_x, r.y = m_screen_pos.m_y;
else
cc1->GetCanvasPointPix( m_lat, m_lon, &r );
if(r.x == INVALID_COORD)
return;
// Substitute icon?
wxBitmap *pbm;
if( ( m_bIsActive ) && ( m_IconName != _T("mob") ) )
pbm = pWayPointMan->GetIconBitmap( _T ( "activepoint" ) );
else
pbm = m_pbmIcon;
// If icon is corrupt, there is really nothing else to do...
if(!pbm->IsOk())
return;
int sx2 = pbm->GetWidth() / 2;
int sy2 = pbm->GetHeight() / 2;
// Calculate the mark drawing extents
wxRect r1( r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2 ); // the bitmap extents
wxRect r3 = r1;
if( m_bShowName ) {
if( !m_pMarkFont ) {
m_pMarkFont = FontMgr::Get().GetFont( _( "Marks" ) );
m_FontColor = FontMgr::Get().GetFontColor( _( "Marks" ) );
CalculateNameExtents();
}
if( m_pMarkFont ) {
wxRect r2( r.x + m_NameLocationOffsetX, r.y + m_NameLocationOffsetY,
m_NameExtents.x, m_NameExtents.y );
r3.Union( r2 );
}
}
hilitebox = r3;
hilitebox.x -= r.x;
hilitebox.y -= r.y;
hilitebox.x *= g_ChartScaleFactorExp;
hilitebox.y *= g_ChartScaleFactorExp;
hilitebox.width *= g_ChartScaleFactorExp;
hilitebox.height *= g_ChartScaleFactorExp;
float radius;
if( g_btouch ){
hilitebox.Inflate( 20 );
radius = 20.0f;
}
else{
hilitebox.Inflate( 4 );
radius = 4.0f;
}
/* update bounding box */
if(!m_wpBBox.GetValid() || vp.view_scale_ppm != m_wpBBox_view_scale_ppm || vp.rotation != m_wpBBox_rotation) {
//.........这里部分代码省略.........
开发者ID:NicolasJourden, 项目名称:OpenCPN, 代码行数:101, 代码来源:RoutePoint.cpp
示例5: test01
void test01()
{
{
String on1;
on1 = "//atp:77/root/cimv25:"
"TennisPlayer.last=\"Rafter\",first=\"Patrick\"";
String on2;
on2 = "//atp:77/root/cimv25:"
"TennisPlayer.first=\"Patrick\",last=\"Rafter\"";
CIMObjectPath r = on1;
PEGASUS_TEST_ASSERT(r.toString() != on1);
PEGASUS_TEST_ASSERT(r.toString() == on2);
CIMObjectPath r2 = r;
CIMObjectPath r3 = CIMObjectPath
("//atp:77/root/cimv25:"
"TennisPlayer.first=\"Chris\",last=\"Evert\"");
if (verbose)
{
XmlWriter::printValueReferenceElement(r, false);
cout << r.toString() << endl;
}
Buffer mofOut;
MofWriter::appendValueReferenceElement(mofOut, r);
r.clear();
}
{
CIMObjectPath r1 = CIMObjectPath
("MyClass.z=true,y=1234,x=\"Hello World\"");
CIMObjectPath r2 = CIMObjectPath
("myclass.X=\"Hello World\",Z=true,Y=1234");
CIMObjectPath r3 = CIMObjectPath ("myclass.X=\"Hello\",Z=true,Y=1234");
// cout << r1.toString() << endl;
// cout << r2.toString() << endl;
PEGASUS_TEST_ASSERT(r1 == r2);
PEGASUS_TEST_ASSERT(r1 != r3);
}
// Test case independence and order independence of parameters.
{
CIMObjectPath r1 = CIMObjectPath ("X.a=123,b=true");
CIMObjectPath r2 = CIMObjectPath ("x.B=TRUE,A=123");
PEGASUS_TEST_ASSERT(r1 == r2);
PEGASUS_TEST_ASSERT(r1.makeHashCode() == r2.makeHashCode());
CIMObjectPath r3 = CIMObjectPath ("x.B=TRUE,A=123,c=FALSE");
PEGASUS_TEST_ASSERT(r1 != r3);
String keyValue;
Array<CIMKeyBinding> kbArray;
{
Boolean found = false;
kbArray = r3.getKeyBindings();
for (Uint32 i = 0; i < kbArray.size(); i++)
{
if (verbose)
{
cout << "keyName= " << kbArray[i].getName().getString()
<< " Value= " << kbArray[i].getValue() << endl;
}
if ( kbArray[i].getName() == CIMName ("B") )
{
keyValue = kbArray[i].getValue();
if(keyValue == "TRUE")
found = true;
}
}
if(!found)
{
cerr << "Key Binding Test error " << endl;
exit(1);
}
//ATTN: KS 12 May 2002 P3 DEFER - keybinding manipulation. too
// simplistic.
// This code demonstrates that it is not easy to manipulate and
// test keybindings. Needs better tool both in CIMObjectPath and
// separate.
}
}
// Test building from component parts of CIM Reference.
{
CIMObjectPath r1 ("atp:77", CIMNamespaceName ("root/cimv25"),
CIMName ("TennisPlayer"));
CIMObjectPath r2 ("//atp:77/root/cimv25:TennisPlayer.");
//cout << "r1 " << r1.toString() << endl;
//cout << "r2 " << r2.toString() << endl;
PEGASUS_TEST_ASSERT(r1 == r2);
PEGASUS_TEST_ASSERT(r1.toString() == r2.toString());
}
//.........这里部分代码省略.........
开发者ID:brunolauze, 项目名称:pegasus, 代码行数:101, 代码来源:Reference.cpp
示例6: GetSBody
void Planet::DrawAtmosphere(const vector3d &camPos)
{
Color col;
double density;
GetSBody()->GetAtmosphereFlavor(&col, &density);
const double rad1 = 0.999;
const double rad2 = 1.05;
glPushMatrix();
// face the camera dammit
vector3d zaxis = (-camPos).Normalized();
vector3d xaxis = vector3d(0,1,0).Cross(zaxis).Normalized();
vector3d yaxis = zaxis.Cross(xaxis);
matrix4x4d rot = matrix4x4d::MakeInvRotMatrix(xaxis, yaxis, zaxis);
glMultMatrixd(&rot[0]);
matrix4x4f invViewRot;
glGetFloatv(GL_MODELVIEW_MATRIX, &invViewRot[0]);
invViewRot.ClearToRotOnly();
invViewRot = invViewRot.InverseOf();
const int numLights = Pi::worldView->GetNumLights();
assert(numLights < 4);
vector3f lightDir[4];
float lightCol[4][4];
// only
for (int i=0; i<numLights; i++) {
float temp[4];
glGetLightfv(GL_LIGHT0 + i, GL_DIFFUSE, lightCol[i]);
glGetLightfv(GL_LIGHT0 + i, GL_POSITION, temp);
lightDir[i] = (invViewRot * vector3f(temp[0], temp[1], temp[2])).Normalized();
}
const double angStep = M_PI/32;
// find angle player -> centre -> tangent point
// tangent is from player to surface of sphere
float tanAng = float(acos(rad1 / camPos.Length()));
// then we can put the fucking atmosphere on the horizon
vector3d r1(0.0, 0.0, rad1);
vector3d r2(0.0, 0.0, rad2);
rot = matrix4x4d::RotateYMatrix(tanAng);
r1 = rot * r1;
r2 = rot * r2;
rot = matrix4x4d::RotateZMatrix(angStep);
glDisable(GL_LIGHTING);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glBegin(GL_TRIANGLE_STRIP);
for (float ang=0; ang<2*M_PI; ang+=float(angStep)) {
vector3d norm = r1.Normalized();
glNormal3dv(&norm.x);
float _col[4] = { 0,0,0,0 };
for (int lnum=0; lnum<numLights; lnum++) {
const float dot = norm.x*lightDir[lnum].x + norm.y*lightDir[lnum].y + norm.z*lightDir[lnum].z;
_col[0] += dot*lightCol[lnum][0];
_col[1] += dot*lightCol[lnum][1];
_col[2] += dot*lightCol[lnum][2];
}
for (int i=0; i<3; i++) _col[i] = _col[i] * col[i];
_col[3] = col[3];
glColor4fv(_col);
glVertex3dv(&r1.x);
glColor4f(0,0,0,0);
glVertex3dv(&r2.x);
r1 = rot * r1;
r2 = rot * r2;
}
glEnd();
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
glPopMatrix();
}
开发者ID:Sunsetjoy, 项目名称:pioneer, 代码行数:80, 代码来源:Planet.cpp
示例7: main
int main()
{
//char buf[80];
ifstream fin("cis.log");
int ln= 1, gotit= 0;
Assoc<int> tot("", 0);
Regexp reet("(..):(..):(..)"), remnth("^(..)/../..");
Regexp r1("^(../../..) (..:..).. (.*)");
PerlString s;
fin >> s; // eat first line
while(fin >> s){
ln++;
// cout << "line " << ln << ": <" << s << ">" << endl;
PerlStringList l;
//05/20/92 10:48PM CIS 2400 988-5366
//05/21/92 09:24PM OFFLINE 00:00:06
if(s.m(r1, l)){
if(l.scalar() < 4){
cerr << "Didn't match all expressions" << endl;
exit(1);
}
// cout << "Expressions matched: " << endl << l << endl;
PerlString a= l[3];
if(a.m("^CIS")) gotit= 1;
else if(a.m("^OFFLINE") && gotit){ // extract Elapsed time
PerlStringList et, mnth;
int hr, mn, sc, tm;
if(a.m(reet, et) != 4){
cerr << "Failed to extract Elapsed time" << endl;
exit(1);
}
hr= atoi(et[1]); mn= atoi(et[2]); sc= atoi(et[3]);
tm= (hr*60) + mn + ((sc >= 30) ? 1 : 0);
gotit= 0;
// extract month
if(l[1].m(remnth, mnth) != 2){
cerr << "Failed to extract Month" << endl;
exit(1);
}
// cout << "Month: " << mnth[1] << " Elapsed Time = " << tm << " mins" << endl;
tot(mnth[1]) += tm;
}else gotit= 0;
}else{
cerr << "Didn't match any expressions" << endl;
exit(1);
}
};
// cout << "tot = " << endl << tot << endl;
Assoc<PerlString> months;
months("01")= "January"; months("02")= "February"; months("03")= "March";
months("04")= "April"; months("05")= "May"; months("06")= "June";
months("07")= "July"; months("08")= "August"; months("09")= "September";
months("10")= "October"; months("11")= "November"; months("12")= "December";
for(int i=0;i<tot.scalar();i++)
cout << months(tot[i].key()) << ": " << tot[i].value() << " mins $"
<< tot[i].value() * (12.50/60.0) << endl;
exit(0);
}
开发者ID:ABratovic, 项目名称:open-watcom-v2, 代码行数:69, 代码来源:cislog.cpp
示例8: kbic_read_regr
static int kbic_read_regr( PIA *pi, int cont, int regr )
{ int a, b, s;
s = cont_map[cont];
switch (pi->mode) {
case 0:
w0(regr|0x18|s);
w2(4);
w2(6);
w2(4);
w2(1);
w0(8);
a = r1();
w0(0x28);
b = r1();
w2(4);
return j44(a,b);
case 1:
w0(regr|0x38|s);
w2(4);
w2(6);
w2(4);
w2(5);
w0(8);
a = r12w();
w2(4);
return j53(a);
case 2:
w0(regr|0x08|s);
w2(4);
w2(6);
w2(4);
w2(0xa5);
w2(0xa1);
a = r0();
w2(4);
return a;
case 3:
case 4:
case 5:
w0(0x20|s);
w2(4);
w2(6);
w2(4);
w3(regr);
a = r4();
b = r4();
w2(4);
w2(0);
w2(4);
return a;
}
return -1;
}
开发者ID:shattered, 项目名称:linux-m68k, 代码行数:61, 代码来源:kbic.c
示例9: CalculateGlobalMatrixAndAngle
dgUnsigned32 dgSlidingConstraint::JacobianDerivative (dgContraintDescritor& params)
{
dgMatrix matrix0;
dgMatrix matrix1;
//dgVector angle (CalculateGlobalMatrixAndAngle (matrix0, matrix1));
CalculateGlobalMatrixAndAngle (matrix0, matrix1);
m_posit = (matrix0.m_posit - matrix1.m_posit) % matrix0.m_front;
matrix1.m_posit += matrix1.m_front.Scale3 (m_posit);
dgAssert (dgAbsf (dgFloat32 (1.0f) - (matrix0.m_front % matrix0.m_front)) < dgFloat32 (1.0e-5f));
dgAssert (dgAbsf (dgFloat32 (1.0f) - (matrix0.m_up % matrix0.m_up)) < dgFloat32 (1.0e-5f));
dgAssert (dgAbsf (dgFloat32 (1.0f) - (matrix0.m_right % matrix0.m_right)) < dgFloat32 (1.0e-5f));
const dgVector& dir1 = matrix0.m_up;
const dgVector& dir2 = matrix0.m_right;
dgVector p0 (matrix0.m_posit);
dgVector p1 (matrix1.m_posit + matrix1.m_front.Scale3 ((p0 - matrix1.m_posit) % matrix1.m_front));
dgVector q0 (p0 + matrix0.m_front.Scale3(MIN_JOINT_PIN_LENGTH));
dgVector q1 (p1 + matrix1.m_front.Scale3(MIN_JOINT_PIN_LENGTH));
dgVector r0 (p0 + matrix0.m_up.Scale3(MIN_JOINT_PIN_LENGTH));
dgVector r1 (p1 + matrix1.m_up.Scale3(MIN_JOINT_PIN_LENGTH));
dgPointParam pointDataP;
dgPointParam pointDataQ;
dgPointParam pointDataR;
InitPointParam (pointDataP, m_stiffness, p0, p1);
InitPointParam (pointDataQ, m_stiffness, q0, q1);
InitPointParam (pointDataR, m_stiffness, r0, r1);
CalculatePointDerivative (0, params, dir1, pointDataP, &m_jointForce[0]);
CalculatePointDerivative (1, params, dir2, pointDataP, &m_jointForce[1]);
CalculatePointDerivative (2, params, dir1, pointDataQ, &m_jointForce[2]);
CalculatePointDerivative (3, params, dir2, pointDataQ, &m_jointForce[3]);
CalculatePointDerivative (4, params, dir2, pointDataR, &m_jointForce[4]);
dgInt32 ret = 5;
if (m_jointAccelFnt) {
dgJointCallbackParam axisParam;
axisParam.m_accel = dgFloat32 (0.0f);
axisParam.m_timestep = params.m_timestep;
axisParam.m_minFriction = DG_MIN_BOUND;
axisParam.m_maxFriction = DG_MAX_BOUND;
if (m_jointAccelFnt (*this, &axisParam)) {
if ((axisParam.m_minFriction > DG_MIN_BOUND) || (axisParam.m_maxFriction < DG_MAX_BOUND)) {
params.m_forceBounds[5].m_low = axisParam.m_minFriction;
params.m_forceBounds[5].m_upper = axisParam.m_maxFriction;
params.m_forceBounds[5].m_normalIndex = DG_BILATERAL_FRICTION_CONSTRAINT;
}
CalculatePointDerivative (5, params, matrix0.m_front, pointDataP, &m_jointForce[5]);
//params.m_jointAccel[5] = axisParam.m_accel;
SetMotorAcceleration (5, axisParam.m_accel, params);
ret = 6;
}
}
return dgUnsigned32 (ret);
}
开发者ID:Hurleyworks, 项目名称:MiniNewton, 代码行数:63, 代码来源:dgSlidingConstraint.cpp
示例10: main
//.........这里部分代码省略.........
const double baseline = T_rl.translation().norm();
std::cout << "Baseline: " << baseline << std::endl;
cudaMemGetInfo( &cu_mem_end, &cu_mem_total );
std::cout << "CuTotal: " << cu_mem_total/(1024*1024) << ", Available: " << cu_mem_end/(1024*1024) << ", Used: " << (cu_mem_start-cu_mem_end)/(1024*1024) << std::endl;
pangolin::Var<bool> step("ui.step", false, false);
pangolin::Var<bool> run("ui.run", false, true);
pangolin::Var<bool> lockToCam("ui.Lock to cam", false, true);
pangolin::Var<int> show_slice("ui.show slice",MAXD/2, 0, MAXD-1);
pangolin::Var<int> maxdisp("ui.maxdisp",MAXD, 0, MAXD);
pangolin::Var<bool> subpix("ui.subpix", true, true);
pangolin::Var<bool> use_census("ui.use census", true, true);
pangolin::Var<int> avg_rad("ui.avg_rad",0, 0, 100);
pangolin::Var<bool> do_dtam("ui.do dtam", false, true);
pangolin::Var<bool> dtam_reset("ui.reset", false, false);
pangolin::Var<float> g_alpha("ui.g alpha", 14, 0,4);
pangolin::Var<float> g_beta("ui.g beta", 2.5, 0,2);
pangolin::Var<float> theta("ui.theta", 100, 0,100);
pangolin::Var<float> lambda("ui.lambda", 20, 0,20);
pangolin::Var<float> sigma_q("ui.sigma q", 0.7, 0, 1);
pangolin::Var<float> sigma_d("ui.sigma d", 0.7, 0, 1);
pangolin::Var<float> huber_alpha("ui.huber alpha", 0.002, 0, 0.01);
pangolin::Var<float> beta("ui.beta", 0.00001, 0, 0.01);
pangolin::Var<float> alpha("ui.alpha", 0.9, 0,1);
pangolin::Var<float> r1("ui.r1", 100, 0,0.01);
pangolin::Var<float> r2("ui.r2", 100, 0,0.01);
pangolin::Var<bool> filter("ui.filter", false, true);
pangolin::Var<float> eps("ui.eps",0.01*0.01, 0, 0.01);
pangolin::Var<int> rad("ui.radius",9, 1, 20);
pangolin::Var<bool> leftrightcheck("ui.left-right check", false, true);
pangolin::Var<float> maxdispdiff("ui.maxdispdiff",1, 0, 5);
pangolin::Var<int> domedits("ui.median its",1, 1, 10);
pangolin::Var<bool> domed9x9("ui.median 9x9", false, true);
pangolin::Var<bool> domed7x7("ui.median 7x7", false, true);
pangolin::Var<bool> domed5x5("ui.median 5x5", false, true);
pangolin::Var<int> medi("ui.medi",12, 0, 24);
pangolin::Var<float> filtgradthresh("ui.filt grad thresh", 0, 0, 20);
pangolin::Var<bool> save_depthmaps("ui.save_depthmaps", false, true);
int jump_frames = 0;
pangolin::RegisterKeyPressCallback(' ', [&run](){run = !run;} );
pangolin::RegisterKeyPressCallback('l', [&lockToCam](){lockToCam = !lockToCam;} );
pangolin::RegisterKeyPressCallback(pangolin::PANGO_SPECIAL + GLUT_KEY_RIGHT, [&step](){step=true;} );
pangolin::RegisterKeyPressCallback(']', [&jump_frames](){jump_frames=100;} );
pangolin::RegisterKeyPressCallback('}', [&jump_frames](){jump_frames=1000;} );
pangolin::Handler2dImageSelect handler2d(lw,lh,level);
// ActivateDrawPyramid<unsigned char,max_levels> adleft(img_pyr[0],GL_LUMINANCE8, false, true);
// ActivateDrawPyramid<unsigned char,max_levels> adright(img_pyr[1],GL_LUMINANCE8, false, true);
pangolin::ActivateDrawImage<float> adleft(img[0],GL_LUMINANCE32F_ARB, false, true);
pangolin::ActivateDrawImage<float> adright(img[1],GL_LUMINANCE32F_ARB, false, true);
开发者ID:jzienkiewicz, 项目名称:Kangaroo, 代码行数:67, 代码来源:main.cpp
示例11: FatalErrorIn
Foam::cylindricalCS Foam::arcEdge::calcAngle()
{
vector a = p2_ - p1_;
vector b = p3_ - p1_;
// find centre of arcEdge
scalar asqr = a & a;
scalar bsqr = b & b;
scalar adotb = a & b;
scalar denom = asqr*bsqr - adotb*adotb;
if (mag(denom) < VSMALL)
{
FatalErrorIn("cylindricalCS arcEdge::calcAngle()")
<< "Invalid arc definition - are the points co-linear? Denom ="
<< denom
<< abort(FatalError);
}
scalar fact = 0.5*(bsqr - adotb)/denom;
point centre = 0.5*a + fact*((a ^ b) ^ a);
centre += p1_;
// find position vectors w.r.t. the arcEdge centre
vector r1(p1_ - centre);
vector r2(p2_ - centre);
vector r3(p3_ - centre);
// find angles
angle_ = radToDeg(acos((r3 & r1)/(mag(r3) * mag(r1))));
// check if the vectors define an exterior or an interior arcEdge
if (((r1 ^ r2) & (r1 ^ r3)) < 0.0)
{
angle_ = 360.0 - angle_;
}
vector tempAxis;
if (angle_ <= 180.0)
{
tempAxis = r1 ^ r3;
if (mag(tempAxis)/(mag(r1)*mag(r3)) < 0.001)
{
tempAxis = r1 ^ r2;
}
}
else
{
tempAxis = r3 ^ r1;
}
radius_ = mag(r3);
// set up and return the local coordinate system
return cylindricalCS("arcEdgeCS", centre, tempAxis, r1);
}
开发者ID:0184561, 项目名称:OpenFOAM-2.1.x, 代码行数:61, 代码来源:arcEdge.C
示例12: printf
//.........这里部分代码省略.........
//---------------------------------------------------------------------
// All parameters have now been set.
//---------------------------------------------------------------------
double time = CoinCpuTime();
//bool useChol = (LSmethod == 1);
//bool useQR = (LSmethod == 2);
bool direct = (LSmethod <= 2 && ifexplicit);
char solver[7];
strncpy(solver, " LSQR", 7);
//---------------------------------------------------------------------
// Categorize bounds and allow for fixed variables by modifying b.
//---------------------------------------------------------------------
int nlow, nupp, nfix;
int *bptrs[3] = {0};
getBoundTypes(&nlow, &nupp, &nfix, bptrs );
int *low = bptrs[0];
int *upp = bptrs[1];
int *fix = bptrs[2];
int nU = n;
if (nupp == 0) nU = 1; //Make dummy vectors if no Upper bounds
//---------------------------------------------------------------------
// Get pointers to local copy of model bounds
//---------------------------------------------------------------------
CoinDenseVector<double> bl(n, columnLower_);
double *bl_elts = bl.getElements();
CoinDenseVector<double> bu(nU, columnUpper_); // this is dummy if no UB
double *bu_elts = bu.getElements();
CoinDenseVector<double> r1(m, 0.0);
double *r1_elts = r1.getElements();
CoinDenseVector<double> x1(n, 0.0);
double *x1_elts = x1.getElements();
if (nfix > 0) {
for (int k = 0; k < nfix; k++)
x1_elts[fix[k]] = bl[fix[k]];
matVecMult(1, r1, x1);
b = b - r1;
// At some stage, might want to look at normfix = norm(r1,inf);
}
//---------------------------------------------------------------------
// Scale the input data.
// The scaled variables are
// xbar = x/beta,
// ybar = y/zeta,
// zbar = z/zeta.
// Define
// theta = beta*zeta;
// The scaled function is
// phibar = ( 1 /theta) fbar(beta*xbar),
// gradient = (beta /theta) grad,
// Hessian = (beta2/theta) hess.
//---------------------------------------------------------------------
double beta = xsize_;
if (beta == 0) beta = 1; // beta scales b, x.
double zeta = zsize_;
if (zeta == 0) zeta = 1; // zeta scales y, z.
double theta = beta * zeta; // theta scales obj.
// (theta could be anything, but theta = beta*zeta makes
// scaled grad = grad/zeta = 1 approximately if zeta is chosen right.)
开发者ID:ebshimizu, 项目名称:Lumiverse, 代码行数:67, 代码来源:ClpPdco.cpp
示例13: main
int main(int argc, char **argv)
{
char c, *infn;
ifstream ini("\\win3\\win.ini");
ofstream fout("t.sty");
int ln= 0;
SPString w;
SPStringList l;
SPStringList ttfonts;
Assoc<SPString> repfnts("", ""); // saves font replacement names
if(argc < 2) infn= "test.sty";
else infn= argv[1];
ifstream fin(infn);
if(!ini){
cerr << "Can't open \\win3\\win.ini" << endl;
exit(1);
}
if(!fin){
cerr << "Can't open " << infn << endl;
exit(1);
}
if(!fout){
cerr << "Can't open t.sty for write" << endl;
exit(1);
}
cout << "Reading in truetype fonts" << endl;
while(ini >> w){ // find the [fonts] section
if(w.m("\\[fonts\\]")) break;
}
// cout << buf << endl;
if(!ini.good()){ // checks all file state
cerr << "Couldn't find [fonts] section in win.ini" << endl;
exit(1);
}
// make a list of truetype fonts
Regexp r1("^([a-zA-Z ]+) \\(([a-zA-Z ]+)\\)=");
Regexp r2("^TrueType$");
Regexp r3("\\[.*\\]");
while(ini >> w){
if(w.m(r3)) break; // found the start of another section
if(w.m(r1, l) != 3) continue; // ignore this line
// cout << "Font match:" << l[1] << ", " << l[2] << endl;
if(l[2].m(r2)){
ttfonts.push(l[1]);
}
}
cout << "ttfonts: " << endl << ttfonts << endl;
ini.close();
cout << "Looking for non-truetype fonts" << endl;
SPString s, fnt, newfnt;
SPStringList sl;
while(fin >> s){
ln++;
// cout << "line " << ln << ": <" << s << ">" << endl;
if(s.m("\\[fnt\\]")){
fout << s << endl; // write out [fnt] line
// read next line which should have font in it
if(!(fin >> s)){
cerr << "Error reading font line " << ln << endl;
exit(1);
}
ln++;
fnt= s.split("' '").join(" "); // This trims whitespace
// cout << "font name: <" << fnt << ">" << endl;
if(!ttfonts.grep("^" + fnt + "$", "i")){ // not a truetype font
int pos= s.index(fnt); // get position in string of font
if(pos < 0){
cerr << "Couldn't find <" << fnt << "> in string <" << s << "> line " << ln << endl;
exit(1);
}
// See if we already know what to exchange it with
if(repfnts.isin(fnt)) // just replace it
s.substr(pos, strlen(fnt)) = repfnts(fnt);
else{ // need to ask what the new font name will be
do{
cout << "Replace font <" << fnt << "> with:"; cout.flush();
cin >> newfnt;
if(!(sl=ttfonts.grep("^" + newfnt + "$", "i"))){
cerr << "<" << newfnt << "> is not a valid font" << endl;
continue;
}
break;
}while(1);
s.substr(pos, strlen(fnt)) = sl[0]; // replace it
repfnts(fnt) = sl[0]; // remember for next time
//.........这里部分代码省略.........
开发者ID:ABratovic, 项目名称:open-watcom-v2, 代码行数:101, 代码来源:chgfnt.c
示例14: splitTris
// SPLIT toSPLIT LIST OF PHANTOMTRIANGLE'S ON PLANE.
// Uses a variant of the Sutherland-Hodgman algorithm.
void splitTris( Plane plane, list<PhantomTriangle*> & toSplit, list<PhantomTriangle*> & newTris )
{
// We create 9 pointers, but only 3 will be used.
// Each of the 3 points a,b,c of each tri needs
// to be classified as negative-side, +-side, or
// ON the splitting plane.
Vector *nS[3] ;
Vector *pS[3] ; // ptr to the vert on the _other_ side,
Vector *on[3] ;
int origTris = toSplit.size() ;
for( list<PhantomTriangle*>::iterator iter = toSplit.begin() ; iter != toSplit.end() ; )
{
// these are counters for how many
// vertices so far were on what side of the plane.
int pSide=0, nSide=0, onPlane=0 ;
PhantomTriangle* pTri = *iter ;
Vector* triVectors = &pTri->a ; // start here
// test 3 vertices
for( int i = 0 ; i < 3 ; i++ )
{
int v = plane.iSide( triVectors[i] ) ;
//triVectors[i].print() ;
//printf( " v=%f\n", v ) ;
if( v == 0 ) on[onPlane++]= &triVectors[i];
else if( v < 0 ) nS[nSide++]= &triVectors[i];
else pS[pSide++]= &triVectors[i] ;
}
///info( "pSide=%d, nSide=%d, onPlane=%d", pSide, nSide, onPlane ) ;
if( nSide>=1 && pSide>=1 ) // split.
{
// NOT keeping the winding order. it doesn't matter anyway because
// these are intersectable, not renderable.
// the first ray finds the intersection between the negative side and the ps,
Intersection i1 ;
//---|+++
// o |
// |\|--->N
// | |\
// o-X-o
// Make a ray FROM a point on the negative side,
// to a point on the +side of the plane
Ray r1( *(nS[0]), *(pS[0]) ) ;
// use the plane to get the intersection point
plane.intersectsPlane( r1, &i1 ) ;
///pTri->tri->intersects( r1, &mi1 ) ; // use the original tri to get the 3d space intersection point
// A vertex is on or very near the plane, so
// we'll split AT the vertex (cut only one edge)
if( onPlane==1 )
{
// split using the VERTEX on the plane as the splitter.
// gen 2 tris.
// 1) nS, D, ONPLANE,
// 2) pS, ONPLANE, D.
PhantomTriangle *pt1 = new PhantomTriangle( *(nS[0]), i1.point, *(on[0]), pTri->tri ) ;
PhantomTriangle *pt2 = new PhantomTriangle( *(pS[0]), *(on[0]), i1.point, pTri->tri ) ;
if( pt1->isDegenerate() || pt2->isDegenerate() )
{
// This is a very important error to catch, because it happens
// when something is terribly screwed up.
window->addSolidDebugTri( pTri, Vector(1,0,0) ) ;
error( "split fail." ) ;
delete pt1 ; delete pt2 ;
++iter ;
continue ;
}
newTris.push_back( pt1 ) ;
newTris.push_back( pt2 ) ;
}
else
{
// 2 points on nSide
// We cut 2 edges.
// if there are 2 nsides, use nS[1] and pS[0]. If 2 psides, nS[0],ps[1].
// get the side with 2 verts on it
Vector** sideWith2 = (pSide>nSide)?pS:nS;
Vector** sideWith1 = (pSide<nSide)?pS:nS;
// Get the second intersection point, from sideWith2[1] to sidewith1[0]
Ray r2( *(sideWith2[1]), *(sideWith1[0]) ) ;
Intersection i2 ;
plane.intersectsPlane( r2, &i2 ) ;
// 3 tris.
// *
// / \
//.........这里部分代码省略.........
开发者ID:sdp0et, 项目名称:gtp, 代码行数:101, 代码来源:Octree.cpp
示例15: main
int main(int argc, char *argv[])
{
Pooma::initialize(argc, argv);
Pooma::Tester tester(argc, argv);
Interval<1> n1(1,5);
Interval<1> n2(4,8);
Interval<1> n3(10,20);
Interval<2> a(n1,n2);
Interval<3> b(n1,n2,n3);
Range<1> r1(1,5);
Range<1> r2(4,8,2);
Range<1> r3(5,9,2);
Range<1> r4(10,20,5);
Range<2> ra(r1,r2);
Range<2> rb(r1,r3);
Range<3> rc(r1,r2,r3);
tester.out() << "1: touches(" << a[0] << "," << a[1] << ") ? ";
tester.out() << touches(a[0], a[1]) << std::endl;
tester.check( touches(a[0], a[1]) );
tester.out() << "0: touches(" << a[0] << "," << b[2] << ") ? ";
tester.out() << touches(a[0], b[2]) << std::endl;
tester.check( touches(a[0], b[2])==0);
tester.out() << "1: touches(" << a[0] << "," << ra[0] << ") ? ";
tester.out() << touches(a[0], ra[0]) << std::endl;
tester.check(touches(a[0], ra[0]));
tester.out() << "1: touches(" << ra[0] << "," << ra[1] << ") ? ";
tester.out() << touches(ra[0], ra[1]) << std::endl;
tester.check( touches(ra[0], ra[1]));
tester.out() << "0: touches(" << r2 << "," << r3 << ") ? ";
tester.out() << touches(r2, r3) << std::endl;
tester.check( touches(r2, r3)==0);
tester.out() << "0: touches(" << ra << "," << rb << ") ? ";
tester.out() << touches(ra, rb) << std::endl;
tester.check( touches(ra, rb) ==0);
tester.out() << "1: touches(" << rc << "," << rc << ") ? ";
tester.out() << touches(rc, rc) << std::endl;
tester.check( touches(rc, rc) );
tester.out() << "------------------------------------" << std::endl;
tester.check(" touches ", true);
Interval<1> c1(1,10);
Interval<1> c2(3,8);
Interval<1> c3(5,15);
Interval<2> ca(c1, c1);
Interval<2> cb(c1, c2);
Range<1> cr1(2,20,2);
Range<1> cr2(4,16,4);
Range<1> cr3(3,15,2);
Range<1> cr4(5,15,5);
tester.out() << "1: contains(" << c1 << "," << c2 << ") ? ";
tester.out() << contains(c1,c2) << std::endl;
tester.check(contains(c1,c2));
tester.out() << "0: contains(" << c2 << "," << c1 << ") ? ";
tester.out() << contains(c2,c1) << std::endl;
tester.check(contains(c2,c1)==0);
tester.out() << "0: contains(" << c1 << "," << c3 << ") ? ";
tester.out() << contains(c1,c3) << std::endl;
tester.check(contains(c1,c3)==0);
tester.out() << "1: contains(" << ca << "," << cb << ") ? ";
tester.out() << contains(ca,cb) << std::endl;
tester.check(contains(ca,cb));
tester.out() << "0: contains(" << cb << "," << ca << ") ? ";
tester.out() << contains(cb,ca) << std::endl;
tester.check(contains(cb,ca)==0);
tester.out() << "1: contains(" << cr1 << "," << cr2 << ") ? ";
tester.out() << contains(cr1,cr2) << std::endl;
tester.check( contains(cr1,cr2));
tester.out() << "0: contains(" << cr1 << "," << cr3 << ") ? ";
tester.out() << contains(cr1,cr3) << std::endl;
tester.check(contains(cr1,cr3)==0);
tester.out() << "1: contains(" << c3 << "," << cr4 << ") ? ";
tester.out() << contains(c3,cr4) << std::endl;
tester.check(contains(c3,cr4));
tester.out() << "0: contains(" << cr4 << "," << c3 << ") ? ";
tester.out() << contains(cr4,c3) << std::endl;
tester.check(contains(cr4,c3)==0);
tester.out() << "------------------------------------" << std::endl;
Interval<2> s1, s2;
Range<2> sr1, sr2;
split(cb, s1, s2);
tester.out() << "split(" << cb << ") = " << s1 << " and " << s2 << std::endl;
tester.check(s1==Interval<2>(Interval<1>(1,5),Interval<1>(3,5)));
tester.check(s2==Interval<2>(Interval<1>(6,10),Interval<1>(6,8)));
split(rb, sr1, sr2);
tester.out() << "split(" << rb << ") = " << sr1 << " and " << sr2 << std::endl;
tester.check(sr1==Range<2>(Range<1>(1,2),Range<1>(5,5,2)));
tester.check(sr2==Range<2>(Range<1>(3,5),Range<1>(7,9,2)));
tester.out() << "------------------------------------" << std::endl;
//.........这里部分代码省略.........
开发者ID:pathscale, 项目名称:freepooma-testsuite, 代码行数:101, 代码来源:domaincalc.C
示例16: run_main
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_LIB_TEXT ("Refcounted_Auto_Ptr_Test"));
// =========================================================================
// The following test uses the ACE_Refcounted_Auto_Ptr in a single
// thread of control, hence we use the ACE_Null_Mutex
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT ("(%t) performing synchronous test...\n")));
Printer *printer1;
ACE_NEW_RETURN (printer1,
Printer ("I am printer 1"),
-1);
{
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r(printer1);
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r1(r);
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r2(r);
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r3(r);
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r4(r);
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r5 = r2;
ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r6 = r1;
}
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
Printer::instance_count_));
ACE_ASSERT (Printer::instance_count_ == 0);
#if defined (ACE_HAS_THREADS)
// =========================================================================
// The following test uses the ACE_Refcounted_Auto_Ptr in multiple
// threads of control.
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT ("(%t) performing asynchronous test...\n")));
Scheduler *scheduler_ptr;
// Create active objects..
ACE_NEW_RETURN (scheduler_ptr,
Scheduler (),
-1);
auto_ptr<Scheduler> scheduler(scheduler_ptr);
ACE_ASSERT (scheduler->open () != -1);
{
ACE_NEW_RETURN (printer1,
Printer ("I am printer 2"),
-1);
Printer_var r (printer1);
for (int i = 0; i < n_loops; i++)
// Spawn off the methods, which run in a separate thread as
// active object invocations.
scheduler->print (r);
}
// Close things down.
scheduler->end ();
scheduler->wait ();
ACE_DEBUG ((LM_DEBUG,
ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
Printer::instance_count_));
ACE_ASSERT (Printer::instance_count_ == 0);
#endif /* ACE_HAS_THREADS */
ACE_END_TEST;
return 0;
}
开发者ID:BackupTheBerlios, 项目名称:pyasynchio-svn, 代码行数:79, 代码来源:Refcounted_Auto_Ptr_Test.cpp
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19190| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9988| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8326| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8696| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8639| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9657| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8624| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7998| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8656| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7535| 2022-11-06
请发表评论