本文整理汇总了C++中qCos函数的典型用法代码示例。如果您正苦于以下问题:C++ qCos函数的具体用法?C++ qCos怎么用?C++ qCos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qCos函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:dcardenasnl,项目名称:Test,代码行数:73,代码来源:qwt_round_scale_draw.cpp
示例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));
}
}
开发者ID:svn2github,项目名称:vmpk,代码行数:17,代码来源:classicstyle.cpp
示例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)));
}
}
开发者ID:GergoBodi,项目名称:MiniThesis,代码行数:8,代码来源:voiceprocessor.cpp
示例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_);
}
开发者ID:asmolen,项目名称:simulator-1,代码行数:17,代码来源:camera.cpp
示例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);
}
开发者ID:claudeocquidant,项目名称:Embroidermodder,代码行数:8,代码来源:object-ellipse.cpp
示例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);
}
开发者ID:claudeocquidant,项目名称:Embroidermodder,代码行数:8,代码来源:object-ellipse.cpp
示例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);
}
}
开发者ID:KDE,项目名称:digikam,代码行数:58,代码来源:distortionfxfilter.cpp
示例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;
}
开发者ID:aitjcize,项目名称:QCamber,代码行数:45,代码来源:squarethermalopencornerssymbol.cpp
示例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();
}
开发者ID:NaviPolytechnique,项目名称:GUI,代码行数:45,代码来源:xyzwidget.cpp
示例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);
}
开发者ID:SidneyTTW,项目名称:Basketball,代码行数:9,代码来源:zcamera.cpp
示例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());
}
开发者ID:stefankram,项目名称:plants-vs-zombies,代码行数:9,代码来源:gameobject.cpp
示例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);
}
开发者ID:corona1,项目名称:roverSystem,代码行数:19,代码来源:armwindow.cpp
示例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 )) );
}
}
开发者ID:new5244,项目名称:qt,代码行数:9,代码来源:dataconverter.cpp
示例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()));
}
开发者ID:NeuroProc,项目名称:work-qt,代码行数:9,代码来源:extra.cpp
示例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;
}
开发者ID:minusc,项目名称:ScientificCalculator,代码行数:56,代码来源:mainwindow.cpp
示例16: QPointF
/*!
Convert and return values in Cartesian coordinates
\note Invalid or null points will be returned as QPointF(0.0, 0.0)
\sa isValid(), isNull()
*/
QPointF QwtPointPolar::toPoint() const
{
if ( d_radius <= 0.0 )
return QPointF( 0.0, 0.0 );
const double x = d_radius * qCos( d_azimuth );
const double y = d_radius * qSin( d_azimuth );
return QPointF( x, y );
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:16,代码来源:qwt_point_polar.cpp
示例17: offset
QTCOMMERCIALCHART_BEGIN_NAMESPACE
#define PI 3.14159265 // TODO: is this defined in some header?
QPointF offset(qreal angle, qreal length)
{
qreal dx = qSin(angle*(PI/180)) * length;
qreal dy = qCos(angle*(PI/180)) * length;
return QPointF(dx, -dy);
}
开发者ID:wangyun123,项目名称:Third,代码行数:10,代码来源:piesliceitem.cpp
示例18: atan
void GeoCoordinate::setLatitude(qreal l) {
if (l >= -90 && l <= 90) {
lat = l;
qreal pi_180 = 4 * atan(double(1)) / 180;
const int earthRadius = 6378137; /*m a l'equateur*/
qreal degAtEquator = pi_180 * earthRadius;
qreal degAtThisLat = pi_180 * earthRadius * qCos(pi_180 * lat);
mProjectionRatio = degAtEquator / degAtThisLat;
}
}
开发者ID:xaviermawet,项目名称:EcoManager2013Experimental,代码行数:10,代码来源:GeoCoordinate.cpp
示例19: Q_D
bool VerticalPerspectiveProjection::geoCoordinates( const int x, const int y,
const ViewportParams *viewport,
qreal& lon, qreal& lat,
GeoDataCoordinates::Unit unit ) const
{
Q_D(const VerticalPerspectiveProjection);
d->calculateConstants(viewport->radius());
const qreal P = d->m_P;
const qreal rx = ( - viewport->width() / 2 + x );
const qreal ry = ( viewport->height() / 2 - y );
const qreal p2 = rx*rx + ry*ry;
if (p2 == 0) {
lon = viewport->centerLongitude();
lat = viewport->centerLatitude();
return true;
}
const qreal pP = p2*d->m_pPfactor;
if ( pP > 1) return false;
const qreal p = qSqrt(p2);
const qreal fract = d->m_perspectiveRadius*(P-1)/p;
const qreal c = qAsin((P-qSqrt(1-pP))/(fract+1/fract));
const qreal sinc = qSin(c);
const qreal centerLon = viewport->centerLongitude();
const qreal centerLat = viewport->centerLatitude();
lon = centerLon + qAtan2(rx*sinc, (p*qCos(centerLat)*qCos(c) - ry*qSin(centerLat)*sinc));
while ( lon < -M_PI ) lon += 2 * M_PI;
while ( lon > M_PI ) lon -= 2 * M_PI;
lat = qAsin(qCos(c)*qSin(centerLat) + (ry*sinc*qCos(centerLat))/p);
if ( unit == GeoDataCoordinates::Degree ) {
lon *= RAD2DEG;
lat *= RAD2DEG;
}
return true;
}
开发者ID:KDE,项目名称:marble,代码行数:43,代码来源:VerticalPerspectiveProjection.cpp
示例20: qCos
UQuaternion* RotationHelper::EulToQuat2(UVector eu)
{
UQuaternion* quat = new UQuaternion;
double n = qCos(eu.y * 0.5);
double n2 = qSin(eu.y * 0.5);
double n3 = qCos(eu.x * 0.5);
double n4 = qSin(eu.x * 0.5);
double n5 = qCos(eu.z * 0.5);
double n6 = qSin(eu.z * 0.5);
double n7 = n * n3;
double n8 = n2 * n4;
quat->w = (float)((n7 * n5) - (n8 * n6));
quat->x = (float)((n7 * n6) + (n8 * n5));
quat->y = (float)(((n2 * n3) * n5) + ((n * n4) * n6));
quat->z = (float)(((n * n4) *n5) - ((n2 * n3) * n6));
return quat;
}
开发者ID:WapaMario63,项目名称:LoEWCT2,代码行数:19,代码来源:serialize.cpp
注:本文中的qCos函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论