本文整理汇总了C++中qCos函数的典型用法代码示例。如果您正苦于以下问题:C++ qCos函数的具体用法?C++ qCos怎么用?C++ qCos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qCos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: radius
/*!
Calculate the extent of the scale
The extent is the distance between the baseline to the outermost
pixel of the scale draw. radius() + extent() is an upper limit
for the radius of the bounding circle.
\param font Font used for painting the labels
\sa setMinimumExtent(), minimumExtent()
\warning The implemented algo is not too smart and
calculates only an upper limit, that might be a
few pixels too large
*/
double QwtRoundScaleDraw::extent( const QFont &font ) const
{
double d = 0.0;
if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
{
const QwtScaleDiv &sd = scaleDiv();
const QList<double> &ticks = sd.ticks( QwtScaleDiv::MajorTick );
for ( int i = 0; i < ticks.count(); i++ )
{
const double value = ticks[i];
if ( !sd.contains( value ) )
continue;
const QwtText label = tickLabel( font, value );
if ( label.isEmpty() )
continue;
const double tval = scaleMap().transform( value );
if ( ( tval < d_data->startAngle + 360 * 16 )
&& ( tval > d_data->startAngle - 360 * 16 ) )
{
const double arc = tval / 16.0 / 360.0 * 2 * M_PI;
const QSizeF sz = label.textSize( font );
const double off = qMax( sz.width(), sz.height() );
double x = off * qSin( arc );
double y = off * qCos( arc );
const double dist = qSqrt( x * x + y * y );
if ( dist > d )
d = dist;
}
}
}
if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
{
d += maxTickLength();
}
if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
{
const double pw = qMax( 1, penWidth() ); // penwidth can be zero
d += pw;
}
if ( hasComponent( QwtAbstractScaleDraw::Labels ) &&
( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
hasComponent( QwtAbstractScaleDraw::Backbone ) ) )
{
d += spacing();
}
d = qMax( d, minimumExtent() );
return d;
}
示例2: drawTick
static void drawTick(QPainter *p, float angle, int size, bool internal)
{
float hyp = float(size) / 2.0;
float x0 = hyp - (hyp - 1) * qSin(angle);
float y0 = hyp + (hyp - 1) * qCos(angle);
if (internal) {
float len = hyp / 4;
float x1 = hyp - (hyp - len) * qSin(angle);
float y1 = hyp + (hyp - len) * qCos(angle);
p->drawLine(int(x0), int(y0), int(x1), int(y1));
} else {
float len = hyp / 4;
float x1 = hyp - (hyp + len) * qSin(angle);
float y1 = hyp + (hyp + len) * qCos(angle);
p->drawLine(int(x0), int(y0), int(x1), int(y1));
}
}
示例3: QObject
VoiceProcessor::VoiceProcessor(QObject *parent) : QObject(parent)
{
m_recordedLength = RECORD_SAMPLE_SIZE;
for(int i=0; i < WINDOW_SIZE;i++){
window[i]=0.5*(1-qCos((2*M_PI*i)/(WINDOW_SIZE-1)));
}
}
示例4: qCos
void Camera::rotate(QPoint p)
{
angleXY_ += p.rx() * 0.002f;
angleZ_ += p.ry() * 0.002f;
if (angleZ_ < -M_PI_2*0.99f)
angleZ_ = -M_PI_2*0.99f;
if (angleZ_ > M_PI_2*0.99f)
angleZ_ = M_PI_2*0.99f;
if (angleXY_ < 0.0f)
angleXY_ += 2*M_PI;
if (angleXY_ > 2*M_PI)
angleXY_ -= 2*M_PI;
step_[0] = qCos(angleZ_)*qCos(angleXY_);
step_[1] = qCos(angleZ_)*qSin(angleXY_);
step_[2] = qSin(angleZ_);
}
示例5: objectWidth
QPointF EllipseObject::objectQuadrant180() const
{
qreal halfW = objectWidth()/2.0;
qreal rot = radians(rotation()+180.0);
qreal x = halfW*qCos(rot);
qreal y = halfW*qSin(rot);
return objectCenter() + QPointF(x,y);
}
示例6: objectHeight
QPointF EllipseObject::objectQuadrant270() const
{
qreal halfH = objectHeight()/2.0;
qreal rot = radians(rotation()+270.0);
qreal x = halfH*qCos(rot);
qreal y = halfH*qSin(rot);
return objectCenter() + QPointF(x,y);
}
示例7: if
void DistortionFXFilter::polarCoordinatesMultithreaded(const Args& prm)
{
int Width = prm.orgImage->width();
int Height = prm.orgImage->height();
uchar* data = prm.orgImage->bits();
bool sixteenBit = prm.orgImage->sixteenBit();
int bytesDepth = prm.orgImage->bytesDepth();
uchar* pResBits = prm.destImage->bits();
int nHalfW = Width / 2;
int nHalfH = Height / 2;
double lfXScale = 1.0;
double lfYScale = 1.0;
double lfAngle, lfRadius, lfRadMax;
double nh, nw, tw;
if (Width > Height)
{
lfYScale = (double)Width / (double)Height;
}
else if (Height > Width)
{
lfXScale = (double)Height / (double)Width;
}
lfRadMax = (double)qMax(Height, Width) / 2.0;
double th = lfYScale * (double)(prm.h - nHalfH);
for (int w = prm.start; runningFlag() && (w < prm.stop); ++w)
{
tw = lfXScale * (double)(w - nHalfW);
if (prm.Type)
{
// now, we get the distance
lfRadius = qSqrt(th * th + tw * tw);
// we find the angle from the center
lfAngle = qAtan2(tw, th);
// now we find the exact position's x and y
nh = lfRadius * (double) Height / lfRadMax;
nw = lfAngle * (double) Width / (2 * M_PI);
nw = (double)nHalfW + nw;
}
else
{
lfRadius = (double)(prm.h) * lfRadMax / (double)Height;
lfAngle = (double)(w) * (2 * M_PI) / (double) Width;
nw = (double)nHalfW - (lfRadius / lfXScale) * qSin(lfAngle);
nh = (double)nHalfH - (lfRadius / lfYScale) * qCos(lfAngle);
}
setPixelFromOther(Width, Height, sixteenBit, bytesDepth, data, pResBits, w, prm.h, nw, nh, prm.AntiAlias);
}
}
示例8: qCos
QPainterPath SquareThermalOpenCornersSymbol::painterPath(void)
{
QPainterPath path;
qreal angle_div = 360.0 / m_num_spokes;
QPainterPath sub;
QMatrix mat;
// From what we seen in Genesis 2000, num_spokes can only be 1, 2, 4
// angle can only be multiple of 45
if ((m_num_spokes != 1 && m_num_spokes != 2 && m_num_spokes != 4) ||
((int)m_angle % 45 != 0)) {
return path;
}
path.addRect(-m_od / 2, -m_od / 2, m_od, m_od);
path.addRect(-m_id / 2, -m_id / 2, m_id, m_id);
if ((int)m_angle % 90 == 0) {
QPainterPath bar;
bar.addRect(0, -m_gap / 2, m_od, m_gap);
for (int i = 0; i < m_num_spokes; ++i) {
sub.addPath(mat.map(bar));
mat.rotate(-angle_div);
}
} else {
qreal side = m_gap * qCos(M_PI / 4) + (m_od - m_id) / 2;
qreal offset = (m_od - side) / 2;
QPainterPath box;
box.addRect(-side / 2, -side / 2, side, side);
for (int i = 0; i < m_num_spokes; ++i) {
QMatrix mat;
mat.translate(offset * sign(qCos((m_angle + angle_div * i) * D2R)),
-offset * sign(qSin((m_angle + angle_div * i) * D2R)));
sub.addPath(mat.map(box));
}
}
path = path.subtracted(sub);
return path;
}
示例9: QT_VERSION_CHECK
void XyzWidget::realtimeDataSlot3(double ax, double ay, double az)
{
// calculate two new data points:
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
double key = 0;
#else
double key = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;
#endif
static double lastPointKey = 0;
if (key-lastPointKey > 0.01) // at most add point every 10 ms
{
double value0 = qSin(key); //qSin(key*1.6+qCos(key*1.7)*2)*10 + qSin(key*1.2+0.56)*20 + 26;
double value1 = qCos(key); //qSin(key*1.3+qCos(key*1.2)*1.2)*7 + qSin(key*0.9+0.26)*24 + 26;
double value2 = qSin(key)-qCos(key);
// add data to lines for plot 3:
ui->customPlot3->graph(0)->addData(key, value0);
ui->customPlot3->graph(1)->addData(key, value1);
ui->customPlot3->graph(2)->addData(key, value2);
// set data of dots:
ui->customPlot3->graph(3)->clearData();
ui->customPlot3->graph(3)->addData(key, value0);
ui->customPlot3->graph(4)->clearData();
ui->customPlot3->graph(4)->addData(key, value1);
ui->customPlot3->graph(5)->clearData();
ui->customPlot3->graph(5)->addData(key, value2);
// remove data of lines that's outside visible range:
ui->customPlot3->graph(0)->removeDataBefore(key-8);
ui->customPlot3->graph(1)->removeDataBefore(key-8);
ui->customPlot3->graph(2)->removeDataBefore(key-8);
// rescale value (vertical) axis to fit the current data:
ui->customPlot3->graph(0)->rescaleValueAxis();
ui->customPlot3->graph(1)->rescaleValueAxis(true);
ui->customPlot3->graph(2)->rescaleValueAxis(true);
lastPointKey = key;
}
// make key axis range scroll with the data (at a constant range size of 8):
ui->customPlot3->xAxis->setRange(key+0.25, 8, Qt::AlignRight);
ui->customPlot3->replot();
}
示例10: qMax
void ZCamera::look() const
{
double cameraZ = qMax(ball->translate._z + distance, distance * 2);
double upX = qCos(t);
double upY = qSin(t);
gluLookAt(ball->translate._x, ball->translate._y, cameraZ,
ball->translate._x, ball->translate._y, ball->translate._z,
upX, upY, 0);
}
示例11: qCos
void GameObject::setBody(Body b) //Set body of the game object
{
body = b;
//Get the x and y distance traveled
xDistance = body.getVelocity() * qCos(body.getDirection() * (PI/180));
yDistance = body.getVelocity() * qSin(body.getDirection() * (PI/180));
//Set the position of the game object on the graphics view
this->setPos(body.x(),body.y());
}
示例12: repaint
//Repaints windows - Calculates arom lines
void armWindow::repaint()
{
//Convert Degrees to Radians
double angle1 = Dangle1*3.1415926535/180;
double angle2 = Dangle2*3.14159265353/180;
//X and Y location of first Joint
int P1x = x0 + arm1Length*qCos(angle1);
int P1y = y0 - arm1Length*qSin(angle1);
//X and Y location of second joint
int P2x = P1x + arm2Length*qCos(3.1415926535-angle1-angle2);
int P2y = P1y + arm2Length*qSin(3.1415926535-angle1-angle2);
//Redraw Lines
Arm1->setLine(x0,y0,P1x,P1y);
Arm2->setLine(P1x,P1y,P2x,P2y);
}
示例13: QPointF
void DataConverter::makeCirclePolygon(QPolygonF &points, qreal radius)
{
points.clear();
for (int i = 0; i < 1440; i++)
{
points.append( QPointF( radius * qSin( 2 *3.14145 * i / 1440.0), radius * qCos( 2 * 3.14159 * i / 1440.0 )) );
}
}
示例14: qCos
void Extra::initDefault()
{
for (int i = 0; i < mNum; i++)
{
points.push_back(QPoint(x() + static_cast<int>(def * qCos(2 * i * M_PI / mNum)),
y() + static_cast<int>(def * qSin(2 * i * M_PI/ mNum))));
}
points.push_back(QPoint(points.value(0).x(), points.value(0).y()));
}
示例15: equals
void MainWindow:: equals()
{
sNum = value.toDouble();
if (addBool){
total = QString::number(fNum+sNum);
label -> setText(total);
}
if (subtractBool){
total = QString::number(fNum-sNum);
label -> setText(total);
}
if (multiplyBool){
total = QString::number(fNum*sNum);
label -> setText(total);
}
if(divideBool){
total = QString::number(fNum/sNum);
label -> setText(total);
}
if(sinBool){
total = QString::number(qSin(fNum));
label -> setText(total);
}
if(cosBool){
total = QString::number(qCos(fNum));
label -> setText(total);
}
if(tanBool){
total = QString::number(qTan(fNum));
label -> setText(total);
}
if(sqrtBool){
total = QString::number(qSqrt(fNum));
label -> setText(total);
}
if(powBool){
total = QString::number(qPow(fNum,2));
label -> setText(total);
}
if(cubicBool){
total = QString::number(qPow(fNum,3));
label -> setText(total);
}
if(expBool){
total = QString::number(qExp(fNum));
label -> setText(total);
}
if(lnBool){
total = QString::number(qLn(fNum));
label -> setText(total);
}
fNum = 0;
sNum = 0;
}