本文整理汇总了C++中q1函数的典型用法代码示例。如果您正苦于以下问题:C++ q1函数的具体用法?C++ q1怎么用?C++ q1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了q1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QLineF Util::rectSlice(QPointF p1, QPointF p2, QRectF r)
{
// https://gist.github.com/ChickenProp/3194723
qreal minX = r.x();
qreal minY = r.y();
qreal maxX = minX + r.width();
qreal maxY = minY + r.height();
qreal dx = p2.x() - p1.x();
qreal dy = p2.y() - p1.y();
qreal v[4] = { -dx, dx, -dy, dy };
qreal u[4] = { p1.x() - minX, maxX - p1.x(), p1.y() - minY, maxY - p1.y() };
qreal t[4];
qreal tMax = Inf, tMin = -Inf;
for (int i=0; i<4; ++i) {
if (v[i] != 0) {
t[i] = u[i]/v[i];
if (v[i] < 0 && tMin < t[i])
tMin = t[i];
if (v[i] > 0 && tMax > t[i])
tMax = t[i];
} else if (u[i] >= 0) {
return QLineF(p1, p2); // Inside rect
} else {
return QLineF(); // Outside rect
}
}
if (tMin >= tMax)
return QLineF();
if (tMax > 1) tMax = 1;
if (tMax < 0) tMax = 0;
if (tMin > 1) tMin = 1;
if (tMin < 0) tMin = 0;
QPointF q1(p1.x() + tMin*dx, p1.y() + tMin*dy);
QPointF q2(p1.x() + tMax*dx, p1.y() + tMax*dy);
return QLineF(q1, q2);
}
示例2: q0
void dSceneRender::DrawCylinder(int segments, dFloat radius, dFloat heigh)
{
dVector q0 ( heigh / 2.0f, radius, 0.0f, 0.0f);
dVector q1 (-heigh / 2.0f, radius, 0.0f, 0.0f);
dMatrix rotation (dPitchMatrix(2.0f * 3.1614f/segments));
dVector cap0[1024];
dVector cap1[1024];
dAssert (segments < sizeof (cap0)/sizeof (cap0[0]));
cap0[segments] = q0;
cap1[segments] = q1;
for (int i = 0; i < segments; i ++) {
cap0[i] = q0;
cap1[i] = q1;
q0 = rotation.RotateVector(q0);
q1 = rotation.RotateVector(q1);
}
dVector normal0 ( 1.0f, 0.0f, 0.0f, 0.0f);
dVector normal1 (-1.0f, 0.0f, 0.0f, 0.0f);
BeginTriangle();
for (int i = 2; i < segments; i ++) {
SubmitNormal(normal0);
DrawTriangle(cap0[0], cap0[i-1], cap0[i]);
SubmitNormal(normal1);
DrawTriangle(cap1[0], cap1[i], cap1[i - 1]);
}
for (int i = 0; i < segments; i ++) {
dVector p0 (cap0[i]);
dVector p1 (cap0[i + 1]);
dVector p2 (cap1[i + 1]);
dVector p3 (cap1[i]);
dVector normal ((p1 - p0) * (p2 - p0));
normal = normal.Scale (1.0f / dSqrt(normal % normal));
SubmitNormal(normal);
DrawTriangle(p0, p2, p1);
SubmitNormal(normal);
DrawTriangle(p0, p3, p2);
}
End();
}
示例3: TestJoinNode
void
TestJoinNode() {
tbb::flow::graph g;
TestSimpleSuccessorArc<tbb::flow::queueing>("queueing");
TestSimpleSuccessorArc<tbb::flow::reserving>("reserving");
TestSimpleSuccessorArc<tbb::flow::tag_matching>("tag_matching");
// queueing and tagging join nodes have input queues, so the input ports do not reverse.
REMARK(" reserving preds");
{
tbb::flow::join_node<tbb::flow::tuple<int,int>, tbb::flow::reserving> rj(g);
tbb::flow::queue_node<int> q0(g);
tbb::flow::queue_node<int> q1(g);
tbb::flow::make_edge(q0,tbb::flow::input_port<0>(rj));
tbb::flow::make_edge(q1,tbb::flow::input_port<1>(rj));
q0.try_put(1);
g.wait_for_all(); // quiesce
ASSERT(!(tbb::flow::input_port<0>(rj).my_predecessors.empty()),"reversed port missing predecessor");
ASSERT((tbb::flow::input_port<1>(rj).my_predecessors.empty()),"non-reversed port has pred");
g.reset();
ASSERT((tbb::flow::input_port<0>(rj).my_predecessors.empty()),"reversed port has pred after reset()");
ASSERT((tbb::flow::input_port<1>(rj).my_predecessors.empty()),"non-reversed port has pred after reset()");
q1.try_put(2);
g.wait_for_all(); // quiesce
ASSERT(!(tbb::flow::input_port<1>(rj).my_predecessors.empty()),"reversed port missing predecessor");
ASSERT((tbb::flow::input_port<0>(rj).my_predecessors.empty()),"non-reversed port has pred");
g.reset();
ASSERT((tbb::flow::input_port<1>(rj).my_predecessors.empty()),"reversed port has pred after reset()");
ASSERT((tbb::flow::input_port<0>(rj).my_predecessors.empty()),"non-reversed port has pred after reset()");
#if TBB_PREVIEW_FLOW_GRAPH_FEATURES
// should reset predecessors just as regular reset.
q1.try_put(3);
g.wait_for_all(); // quiesce
ASSERT(!(tbb::flow::input_port<1>(rj).my_predecessors.empty()),"reversed port missing predecessor");
ASSERT((tbb::flow::input_port<0>(rj).my_predecessors.empty()),"non-reversed port has pred");
g.reset(tbb::flow::rf_extract);
ASSERT((tbb::flow::input_port<1>(rj).my_predecessors.empty()),"reversed port has pred after reset()");
ASSERT((tbb::flow::input_port<0>(rj).my_predecessors.empty()),"non-reversed port has pred after reset()");
ASSERT(q0.my_successors.empty(), "edge not removed by reset(rf_extract)");
ASSERT(q1.my_successors.empty(), "edge not removed by reset(rf_extract)");
#endif
}
REMARK(" done\n");
}
示例4: q0
cv::Mat sg::padKernelFFT( cv::Mat const & input, cv::Size const & paddedSize )
{
cv::Mat result = cv::Mat::zeros( paddedSize, input.type() );
// Get the 4 quadrants of the input kernel
int hwx = input.cols / 2;
int hwy = input.rows / 2;
int px = hwx;
int py = hwy;
int fftW = paddedSize.width;
int fftH = paddedSize.height;
if( input.cols %2 != 0 )
++px;
if( input.rows % 2 != 0 )
++py;
cv::Mat q0( input, cv::Rect( 0, 0, px, py ) );
cv::Mat q02( result, cv::Rect( fftW - px, fftH - py, px, py ) );
cv::Mat q1( input, cv::Rect( px, 0, hwx, py ) );
cv::Mat q12( result, cv::Rect( 0, fftH - py, hwx, py ) );
cv::Mat q2( input, cv::Rect( 0, py, px, hwy ) );
cv::Mat q22( result, cv::Rect( fftW - px, 0, px, hwy ) );
cv::Mat q3( input, cv::Rect( px, py, hwx, hwy ) );
cv::Mat q32( result, cv::Rect( 0, 0, hwx, hwy ) );
q0.copyTo( q02 );
q1.copyTo( q12 );
q2.copyTo( q22 );
q3.copyTo( q32 );
// if our filter doesn't have real and complex components, make the complex part zeros
if( result.channels() < 2 )
{
cv::Mat planes[] = { result, cv::Mat::zeros( result.size(), CV_32F ) };
cv::merge( planes, 2, result );
}
return result;
}
示例5: getOptimalDFTSize
Mat THDUtil::computeOrientation(Mat frame)
{
Mat padded; //expanding input image to optimal size by making boarder
int m = getOptimalDFTSize(frame.rows);
int n = getOptimalDFTSize(frame.cols);
copyMakeBorder(frame, padded, m - frame.rows, 0, n - frame.cols, BORDER_CONSTANT, 0);
Mat planes[] = { Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F) };
Mat complexI;
merge(planes, 2, complexI);
dft(complexI, complexI);
split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
Mat magI = planes[0];
magI += Scalar::all(1); // switch to logarithmic scale
log(magI, magI);
// crop the spectrum, if it has an odd number of rows or columns
magI = magI(Rect(0, 0, magI.cols & -2, magI.rows & -2));
// rearrange the quadrants of Fourier image so that the origin is at the image center
int cx = magI.cols / 2;
int cy = magI.rows / 2;
Mat q0(magI, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
Mat q1(magI, Rect(cx, 0, cx, cy)); // Top-Right
Mat q2(magI, Rect(0, cy, cx, cy)); // Bottom-Left
Mat q3(magI, Rect(cx, cy, cx, cy)); // Bottom-Right
Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);
normalize(magI, magI, 0, 1, CV_MINMAX); // Transform the matrix with float values into a
// viewable image form (float between values 0 and 1).
return magI;
}
示例6: RemoveAttribute
void Database::_RemoveAlbum(QString album, int artist)
{
if(!artist)
RemoveAttribute(nAlbum, album);
else {
if(!open) return;
int id = _AddAlbum(album, artist);
if(id > 0) {
QSqlQuery q("", db);
q.prepare("select File from Song where Album = "+QString::number(id));
q.exec();
while(q.next()) {
_RemoveFile(q.value(0).toString());
}
QSqlQuery q1("delete from Album where ID = "+QString::number(id), db);
}
}
}
示例7: PlaneMeshCollisionRayHitCallback
static dFloat PlaneMeshCollisionRayHitCallback (NewtonUserMeshCollisionRayHitDesc* const rayDesc)
{
dVector q0 (rayDesc->m_p0[0], rayDesc->m_p0[1], rayDesc->m_p0[2]);
dVector q1 (rayDesc->m_p1[0], rayDesc->m_p1[1], rayDesc->m_p1[2]);
dVector dq (q1 - q0);
// calculate intersection between point lien a plane and return intersection parameter
dInfinitePlane* const me = (dInfinitePlane*) rayDesc->m_userData;
dFloat t = -(me->m_plane.DotProduct3(q0) + me->m_plane.m_w) / (me->m_plane.DotProduct3(dq));
if ((t > 0.0f) && (t < 1.0f)) {
rayDesc->m_normalOut[0] = me->m_plane[0];
rayDesc->m_normalOut[1] = me->m_plane[1];
rayDesc->m_normalOut[2] = me->m_plane[2];
} else {
t = 1.2f;
}
return t;
}
示例8: QFETCH
void tst_QQuaternion::dotProduct()
{
QFETCH(float, x1);
QFETCH(float, y1);
QFETCH(float, z1);
QFETCH(float, scalar1);
QFETCH(float, x2);
QFETCH(float, y2);
QFETCH(float, z2);
QFETCH(float, scalar2);
QFETCH(float, dot);
QQuaternion q1(scalar1, x1, y1, z1);
QQuaternion q2(scalar2, x2, y2, z2);
QCOMPARE(QQuaternion::dotProduct(q1, q2), dot);
QCOMPARE(QQuaternion::dotProduct(q2, q1), dot);
}
示例9: rotate_FromCenter
void rotate_FromCenter(Mat &magI) {
int cx = magI.cols/2;
int cy = magI.rows/2;
Mat q0(magI, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
Mat q1(magI, Rect(cx, 0, cx, cy)); // Top-Right
Mat q2(magI, Rect(0, cy, cx, cy)); // Bottom-Left
Mat q3(magI, Rect(cx, cy, cx, cy)); // Bottom-Right
Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);
}
示例10: QFETCH
void tst_QQuaternion::multiply()
{
QFETCH(qreal, x1);
QFETCH(qreal, y1);
QFETCH(qreal, z1);
QFETCH(qreal, w1);
QFETCH(qreal, x2);
QFETCH(qreal, y2);
QFETCH(qreal, z2);
QFETCH(qreal, w2);
QQuaternion q1(w1, x1, y1, z1);
QQuaternion q2(w2, x2, y2, z2);
QBENCHMARK {
QQuaternion q3 = q1 * q2;
}
}
示例11: CreateCylinder
int CreateCylinder (dVector* const points, dVector* const normals, int segments, dFloat radius, dFloat height, int maxPoints)
{
dMatrix rotation (dPitchMatrix((-360.0f / segments) * 3.141592f/180.0f));
dVector p0 (0.0, 0.0f, 0.0f, 0.0f);
dVector p1 (0.0, radius, 0.0f, 0.0f);
dVector q0 (height, 0.0f, 0.0f, 0.0f);
dVector q1 (height, radius, 0.0f, 0.0f);
dVector n (0, 1.0f, 0.0f, 0.0f);
int count = 0;
for (int i = 0; (i < segments) && (count < maxPoints); i ++) {
dVector p2 (rotation.RotateVector(p1));
normals[count] = dVector (-1.0f, 0.0f, 0.0f, 0.0f);
points[count * 3 + 0] = p0;
points[count * 3 + 1] = p1;
points[count * 3 + 2] = p2;
count ++;
dVector q2 (rotation.RotateVector(q1));
normals[count] = dVector (1.0f, 0.0f, 0.0f, 0.0f);
points[count * 3 + 0] = q0;
points[count * 3 + 1] = q2;
points[count * 3 + 2] = q1;
count ++;
normals[count] = n;
points[count * 3 + 0] = p1;
points[count * 3 + 1] = q1;
points[count * 3 + 2] = p2;
count ++;
normals[count] = n;
points[count * 3 + 0] = p2;
points[count * 3 + 1] = q1;
points[count * 3 + 2] = q2;
count ++;
n = rotation.RotateVector(n);
p1 = p2;
q1 = q2;
}
return count;
}
示例12: reswap4p
/*四角校正,opencv的fft输出的结果在四个角上,应当稍加处理。(swap)*/
void reswap4p(Mat &src)
{
int cx = src.cols / 2;
int cy = src.rows / 2;
Mat q0(src, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
Mat q1(src, Rect(cx, 0, cx, cy)); // Top-Right
Mat q2(src, Rect(0, cy, cx, cy)); // Bottom-Left
Mat q3(src, Rect(cx, cy, cx, cy)); // Bottom-Right
Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);
}
示例13: q1
void q1(char palavra[], int cont)
{
if(palavra[cont] == '\0')
{
qf(palavra, cont);
}
else if(palavra[cont] == '1')
{
q1(palavra, cont+1);
}
else if(palavra[cont] == '2')
{
qf(palavra, cont+1);
}
else
{
erro();
}
}
示例14: rearrange
void rearrange(cv::Mat &img)
{
// img = img(cv::Rect(0, 0, img.cols & -2, img.rows & -2));
int cx = img.cols / 2;
int cy = img.rows / 2;
cv::Mat q0(img, cv::Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
cv::Mat q1(img, cv::Rect(cx, 0, cx, cy)); // Top-Right
cv::Mat q2(img, cv::Rect(0, cy, cx, cy)); // Bottom-Left
cv::Mat q3(img, cv::Rect(cx, cy, cx, cy)); // Bottom-Right
cv::Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);
}
示例15: CalculateGlobalMatrix
void CustomHinge::SubmitConstrainst ()
{
dFloat angle;
dFloat sinAngle;
dFloat cosAngle;
dMatrix matrix0;
dMatrix matrix1;
// calculate the position of the pivot point and the jacobian direction vectors, in global space.
CalculateGlobalMatrix (m_localMatrix0, m_localMatrix1, matrix0, matrix1);
// Restrict the movemenet on the pivot point along all tree orthonormal direction
NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_front[0]);
NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_up[0]);
NewtonUserJointAddLinearRow (m_joint, &matrix0.m_posit[0], &matrix1.m_posit[0], &matrix0.m_right[0]);
// get a point along the pin axis at some resonable large distance from the pivot
dVector q0 (matrix0.m_posit + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH));
dVector q1 (matrix1.m_posit + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH));
// two contraints row perpendicular to the pin vector
NewtonUserJointAddLinearRow (m_joint, &q0[0], &q1[0], &matrix0.m_up[0]);
NewtonUserJointAddLinearRow (m_joint, &q0[0], &q1[0], &matrix0.m_right[0]);
// if limit are enable ...
if (m_limitsOn) {
// the joint angle can be determine by getting the angle between any two non parallel vectors
sinAngle = (matrix0.m_up * matrix1.m_up) % matrix0.m_front;
cosAngle = matrix0.m_up % matrix1.m_up;
angle = atan2f (sinAngle, cosAngle);
if (angle < m_minAngle) {
// get a point along the up vector and set a constraint
NewtonUserJointAddAngularRow (m_joint, 0.0f, &matrix0.m_front[0]);
NewtonUserJointSetRowMaximunFriction (m_joint, 0.0f);
} else if (angle > m_maxAngle) {
NewtonUserJointAddAngularRow (m_joint, 0.0f, &matrix0.m_front[0]);
NewtonUserJointSetRowMinimunFriction (m_joint, 0.0f);
}
}
}