本文整理汇总了C++中q0函数的典型用法代码示例。如果您正苦于以下问题:C++ q0函数的具体用法?C++ q0怎么用?C++ q0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了q0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: max_dig_pell
//only for x^2 - 2y^2= -1;
void max_dig_pell(int num, vector<int>& vroot, vector<I64Pair>& results)
{
results.clear();
i64 p0(vroot[0]);
i64 q0(1);
i64 p1(vroot[0]*vroot[1]+1);
i64 q1(vroot[1]);
i64 p2(1);
i64 q2(1);
results.push_back(I64Pair(p0,q0));
vroot.erase(vroot.begin());
int vsize = vroot.size();
//int r = vsize - 1;
int start = 2;
for(int s = start; true; ++s){
int idx = (s-1)%vsize;
int value = vroot[idx];
p2 = p1*(value) + p0;
q2 = q1*(value) + q0;
p0 = p1; q0 = q1;
p1 = p2; q1 = q2;
if(p2 > 1e18) break;
if((s)%(2) == 0) {
assert(p1*p1-5*q1*q1==-1);
results.push_back(I64Pair(p1, q1));
}
}
}
示例2: p0
vector<double> CIEColor::SinglehueSequential(double t, double s, double b, double c, double h)
{
int N=10;
vector<double> Pseg;
vector<double> p0(3,0),p1(3,0), p2(3,0), q0(3,0), q1(3,0), q2(3,0);
p2[0]=100, p2[1]=0, p2[2]=h;
p1=dividingLCHuvforMSC_H(0,100,h);
p0[0]=0, p0[1]=0, p0[2]=h;
q0[0] = (1-s) * p0[0] + s *p1[0];
q0[1] = (1-s) * p0[1] + s *p1[1];
q0[2] = (1-s) * p0[2] + s *p1[2];
q2[0] = (1-s) * p2[0] + s *p1[0];
q2[1] = (1-s) * p2[1] + s *p1[1];
q2[2] = (1-s) * p2[2] + s *p1[2];
q1[0] = (q0[0] + q2[0])/2;
q1[1] = (q0[1] + q2[1])/2;
q1[2] = (q0[2] + q2[2])/2;
vector<double> T = getT(p0, p1, p2, q0, q1, q2, 125-125*pow(0.2,(1-c)*b+t*c));
Pseg = getCseg(p0, p1, p2, q0, q1, q2, T[0]);
Pseg[2]=h;
double r, g, k;
//LCHuvtoRGB(Pseg[0], Pseg[1], Pseg[2], r, g, k);
closestLCHuvtoRGB(Pseg[0], Pseg[1], Pseg[2], r, g, k);
Pseg[0]= r, Pseg[1]=g, Pseg[2]=k;
return Pseg;
}
示例3: bench_inter_Hor
void bench_inter_Hor()
{
for (INT k=0; k<5000 ; k++)
{
Pt2dr p0 = random_pt();
Pt2dr p1 = random_pt();
if (std::abs(p0.y-p1.y)<1e-2)
p1.y += 1;
SegComp aSp(p0,p1);
REAL anY = NRrandom3() *100;
Pt2dr q0 (0,anY);
Pt2dr q1 (1,anY);
SegComp aSq(q0,q1);
bool OkInter;
Pt2dr aInter0 = aSp.inter(aSq,OkInter);
Pt2dr aInter2(aSp.AbsiceInterDroiteHoriz(anY),anY);
REAL DH = euclid(aInter0,aInter2) ;
BENCH_ASSERT(DH<BIG_epsilon);
}
}
示例4: q2
void q2(const char *cad, int *p, int *c)
{
if(cad[*p] == '\0')
return;
if(cad[*p] == 'g' || cad[*p] == 'G')
{
(*p)++;
(*c)++;
q0(cad, p, c);
}
else
{
(*p)++;
q0(cad, p, c);
}
}
示例5: SetWorldMatrix
///////////////////////////////////////////////////////////////////////////////
//
// Quake::SetQuake
//
// shake it up baby now
//
Bool SetWorldMatrix( FamilyNode & node, const Matrix & matrix)
{
ASSERT( sysInit);
if (!*active)
{
// setup world position
//
node.SetWorldAll(matrix);
return FALSE;
}
Quaternion q0( matrix);
Quaternion q1( quakeAnim.Current().intensity * 0.2f, Vector( filterX.Current(), filterY.Current(), filterZ.Current()));
Matrix mat( q0 * q1);
mat.posit.x = matrix.posit.x + filterX.Current();
mat.posit.y = matrix.posit.y + filterY.Current();
mat.posit.z = matrix.posit.z + filterZ.Current();
// setup world position
//
node.SetWorldAll(mat);
return TRUE;
}
示例6: run_multiport_test
void run_multiport_test(int num_threads) {
typedef typename tbb::flow::multifunction_node<InputType, OutputTuple> mo_node_type;
typedef typename std::tuple_element<0,OutputTuple>::type EvenType;
typedef typename std::tuple_element<1,OutputTuple>::type OddType;
tbb::task_scheduler_init init(num_threads);
tbb::flow::graph g;
mo_node_type mo_node(g, tbb::flow::unlimited, oddEvenBody<InputType, OutputTuple>() );
tbb::flow::queue_node<EvenType> q0(g);
tbb::flow::queue_node<OddType> q1(g);
tbb::flow::make_edge(tbb::flow::output_port<0>(mo_node), q0);
tbb::flow::make_edge(tbb::flow::output_port<1>(mo_node), q1);
for(InputType i = 0; i < N; ++i) {
mo_node.try_put(i);
}
g.wait_for_all();
for(int i = 0; i < N/2; ++i) {
EvenType e;
OddType o;
ASSERT(q0.try_get(e) && (int)e % 2 == 0, NULL);
ASSERT(q1.try_get(o) && (int)o % 2 == 1, NULL);
}
}
示例7: q0
void Database::CreateDefaultSqlPlaylists()
{
QSqlQuery q0("", db);
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("The Best"));
q0.bindValue(":dat", "SongRating > 40");
q0.exec();
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("Good music"));
q0.bindValue(":dat", "SongRating > 20");
q0.exec();
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("Unrated"));
q0.bindValue(":dat", "SongRating = 0");
q0.exec();
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("Added today"));
q0.bindValue(":dat", "(julianday('now') - julianday(Date, 'utc')) < 1");
q0.exec();
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("Added this week"));
q0.bindValue(":dat", "(julianday('now') - julianday(Date, 'utc')) <= 7");
q0.exec();
q0.prepare("insert into SQLPlaylist (value, data) values (:val, :dat)");
q0.bindValue(":val", tr("Added this month"));
q0.bindValue(":dat", "(julianday('now') - julianday(Date, 'utc')) <= 30");
q0.exec();
CreateDefaultSqlPlaylists2();
}
示例8: initAutomata
void initAutomata(const char *cad, int *p, int *c)
{
*c = 0;
if(*p < strlen(cad))
q0(cad, p, c);
fprintf(stdout, "La cadena \"ing\" fue encontrada %d veces\n", *c);
inicializar();
colorearPantalla();
tituloVentana();
estadoCualquiera(120.0, 250.0, "q0");
estadoCualquiera(270.0, 250.0, "q1");
estadoCualquiera(420.0, 250.0, "q2");
estadoFinal(570.0, 250.0, "q3");
grafoDirigido(120.0+40.0, 250.0, 270.0-40.0, 250.0, 1, "i");
grafoDirigido(270.0+40.0, 250.0, 420.0-40.0, 250.0, 1, "n");
grafoDirigido(420.0+40.0, 250.0, 570.0-40.0, 250.0, 1, "g");
grafoDirigido(270.0, 250.0-40.0, 0.0, 0.0, 0, "i");
grafoDirigido(110.0+40.0, 250.0+30, 280.0-40.0, 250.0+30, -1, "E-n");
grafoDirigido(110.0+40.0, 190.0+30, 420.0-40.0, 190.0+30, -1, "E-n-g");
al_flip_display();
while(1)
{
al_wait_for_event(queue_evento, &evento);
if(evento.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
break;
}
about();
finalizar();
}
示例9: Test
void Test() {
std::string str('x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
std::wstring wstr(L'x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
std::string s0(0, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string s1(-4, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string s2(0x1000000, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
std::string q0("test", 0);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string q1(kText, -4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string q2("test", 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q3(kText, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q4(kText2, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q5(kText3, 0x1000000);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
}
示例10: q0
/// rearrange the quadrants of Fourier image so that the origin is at the image center
void frequency_domain::shift( cv::Mat& image )
{
if( image.rows == 1 && image.cols == 1)
{
return;
}
cv::vector< cv::Mat > planes;
cv::split( image, planes );
int xMid = image.cols >> 1;
int yMid = image.rows >> 1;
for( unsigned int i = 0; i < planes.size(); i++ )
{
cv::Mat tmp;
cv::Mat q0(planes[i], cv::Rect(0, 0, xMid, yMid));
cv::Mat q1(planes[i], cv::Rect(xMid, 0, xMid, yMid));
cv::Mat q2(planes[i], cv::Rect(0, yMid, xMid, yMid));
cv::Mat q3(planes[i], cv::Rect(xMid, yMid, xMid, yMid));
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp);
q2.copyTo(q1);
tmp.copyTo(q2);
}
cv::merge( planes, image );
}
示例11: q0
void MSNewton::Fixed::submit_constraints(const NewtonJoint* joint, dgFloat32 timestep, int thread_index) {
JointData* joint_data = (JointData*)NewtonJointGetUserData(joint);
// Calculate position of pivot points and Jacobian direction vectors in global space.
dMatrix matrix0, matrix1, matrix2;
MSNewton::Joint::c_calculate_global_matrix(joint_data, matrix0, matrix1, matrix2);
const dVector& p0 = matrix0.m_posit;
const dVector& p1 = matrix1.m_posit;
// Get a point along the pin axis at some reasonable large distance from the pivot.
dVector q0(p0 + matrix0.m_right.Scale(MIN_JOINT_PIN_LENGTH));
dVector q1(p1 + matrix1.m_right.Scale(MIN_JOINT_PIN_LENGTH));
// Get the ankle point.
dVector r0(p0 + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH));
dVector r1(p1 + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH));
// Restrict movement on the pivot point along all three orthonormal directions
NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_front[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_up[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
NewtonUserJointAddLinearRow(joint, &p0[0], &p1[0], &matrix0.m_right[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
// Restrict rotation along all three orthonormal directions
NewtonUserJointAddLinearRow(joint, &q0[0], &q1[0], &matrix0.m_front[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
NewtonUserJointAddLinearRow(joint, &q0[0], &q1[0], &matrix0.m_up[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
NewtonUserJointAddLinearRow(joint, &r0[0], &r1[0], &matrix0.m_up[0]);
if (joint_data->ctype == CT_FLEXIBLE)
NewtonUserJointSetRowSpringDamperAcceleration(joint, Joint::LINEAR_STIFF, Joint::LINEAR_DAMP);
else if (joint_data->ctype == CT_ROBUST)
NewtonUserJointSetRowAcceleration(joint, NewtonUserCalculateRowZeroAccelaration(joint));
NewtonUserJointSetRowStiffness(joint, joint_data->stiffness);
}
示例12: q0
dFloat dMeshNodeInfo::RayCast (const dVector& p0, const dVector& p1) const
{
dVector q0 (m_matrix.UntransformVector(p0));
dVector q1 (m_matrix.UntransformVector(p1));
// int vertexCount = NewtonMeshGetVertexCount(m_mesh);
int strideInBytes = NewtonMeshGetVertexStrideInByte(m_mesh);
float* const vertexList = NewtonMeshGetVertexArray(m_mesh);
dFloat t = 1.2f;
int xxx = 0;
int xxx2 = 0;
for (void* face = NewtonMeshGetFirstFace (m_mesh); face; face = NewtonMeshGetNextFace (m_mesh, face)) {
if (!NewtonMeshIsFaceOpen (m_mesh, face)) {
xxx ++;
int indices[1024];
int vertexCount = NewtonMeshGetFaceIndexCount (m_mesh, face);
NewtonMeshGetFaceIndices (m_mesh, face, indices);
dFloat t1 = dPolygonRayCast (q0, q1, vertexCount, vertexList, strideInBytes, indices);
if (t1 < t) {
xxx2 = xxx;
if (xxx2 == 40276)
xxx2 = xxx;
t = t1;
}
}
}
return t;
}
示例13: SubmitConstraints
void SubmitConstraints(dFloat timestep, int threadIndex)
{
CustomBallAndSocket::SubmitConstraints(timestep, threadIndex);
float invTimestep = 1.0f / timestep;
dMatrix matrix0;
dMatrix matrix1;
CalculateGlobalMatrix(matrix0, matrix1);
if (m_anim_speed != 0.0f) // some animation to illustrate purpose
{
m_anim_time += timestep * m_anim_speed;
float a0 = sin(m_anim_time);
float a1 = m_anim_offset * 3.14f;
dVector axis(sin(a1), 0.0f, cos(a1));
//dVector axis (1,0,0);
m_target = dQuaternion(axis, a0 * 0.5f);
}
// measure error
dQuaternion q0(matrix0);
dQuaternion q1(matrix1);
dQuaternion qt0 = m_target * q1;
dQuaternion qErr = ((q0.DotProduct(qt0) < 0.0f) ? dQuaternion(-q0.m_q0, q0.m_q1, q0.m_q2, q0.m_q3) : dQuaternion(q0.m_q0, -q0.m_q1, -q0.m_q2, -q0.m_q3)) * qt0;
float errorAngle = 2.0f * acos(dMax(-1.0f, dMin(1.0f, qErr.m_q0)));
dVector errorAngVel(0, 0, 0);
dMatrix basis;
if (errorAngle > 1.0e-10f) {
dVector errorAxis(qErr.m_q1, qErr.m_q2, qErr.m_q3, 0.0f);
errorAxis = errorAxis.Scale(1.0f / dSqrt(errorAxis % errorAxis));
errorAngVel = errorAxis.Scale(errorAngle * invTimestep);
basis = dGrammSchmidt(errorAxis);
} else {
basis = dMatrix(qt0, dVector(0.0f, 0.0f, 0.0f, 1.0f));
}
dVector angVel0, angVel1;
NewtonBodyGetOmega(m_body0, (float*)&angVel0);
NewtonBodyGetOmega(m_body1, (float*)&angVel1);
dVector angAcc = (errorAngVel.Scale(m_reduceError) - (angVel0 - angVel1)).Scale(invTimestep);
// motor
for (int n = 0; n < 3; n++) {
// calculate the desired acceleration
dVector &axis = basis[n];
float relAccel = angAcc % axis;
NewtonUserJointAddAngularRow(m_joint, 0.0f, &axis[0]);
NewtonUserJointSetRowAcceleration(m_joint, relAccel);
NewtonUserJointSetRowMinimumFriction(m_joint, -m_angularFriction);
NewtonUserJointSetRowMaximumFriction(m_joint, m_angularFriction);
NewtonUserJointSetRowStiffness(m_joint, m_stiffness);
}
}
示例14: angle
dgUnsigned32 dgHingeConstraint::JacobianDerivative (dgContraintDescritor& params)
{
dgMatrix matrix0;
dgMatrix matrix1;
dgVector angle (CalculateGlobalMatrixAndAngle (matrix0, matrix1));
m_angle = -angle.m_x;
dgAssert (dgAbsf (1.0f - (matrix0.m_front % matrix0.m_front)) < dgFloat32 (1.0e-5f));
dgAssert (dgAbsf (1.0f - (matrix0.m_up % matrix0.m_up)) < dgFloat32 (1.0e-5f));
dgAssert (dgAbsf (1.0f - (matrix0.m_right % matrix0.m_right)) < dgFloat32 (1.0e-5f));
const dgVector& dir0 = matrix0.m_front;
const dgVector& dir1 = matrix0.m_up;
const dgVector& dir2 = matrix0.m_right;
const dgVector& p0 = matrix0.m_posit;
const dgVector& p1 = matrix1.m_posit;
dgVector q0 (p0 + matrix0.m_front.Scale3(MIN_JOINT_PIN_LENGTH));
dgVector q1 (p1 + matrix1.m_front.Scale3(MIN_JOINT_PIN_LENGTH));
// dgAssert (((p1 - p0) % (p1 - p0)) < 1.0e-2f);
dgPointParam pointDataP;
dgPointParam pointDataQ;
InitPointParam (pointDataP, m_stiffness, p0, p1);
InitPointParam (pointDataQ, m_stiffness, q0, q1);
CalculatePointDerivative (0, params, dir0, pointDataP, &m_jointForce[0]);
CalculatePointDerivative (1, params, dir1, pointDataP, &m_jointForce[1]);
CalculatePointDerivative (2, params, dir2, pointDataP, &m_jointForce[2]);
CalculatePointDerivative (3, params, dir1, pointDataQ, &m_jointForce[3]);
CalculatePointDerivative (4, params, dir2, pointDataQ, &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;
}
CalculateAngularDerivative (5, params, dir0, m_stiffness, dgFloat32 (0.0f), &m_jointForce[5]);
// params.m_jointAccel[5] = axisParam.m_accel;
SetMotorAcceleration (5, axisParam.m_accel, params);
ret = 6;
}
}
return dgUnsigned32 (ret);
}
示例15: initAutomata
void initAutomata(char *cad, int *p)
{
if(*p < strlen(cad))
if(cad[0] == '0')
q0(cad, p);
else
fprintf(stderr, "Cadena no aceptada\n");
exit(1);
}