本文整理汇总了C++中qSin函数的典型用法代码示例。如果您正苦于以下问题:C++ qSin函数的具体用法?C++ qSin怎么用?C++ qSin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qSin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qSin
void BlurPicker::setIndex(qreal index)
{
m_index = index;
qreal baseline = 0;
for (int i = 0; i < m_icons.count(); ++i) {
ImageItem *icon = m_icons[i];
qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count();
qreal xs = 380 * qSin(a);
qreal ys = 230 * qCos(a);
QPointF pos(xs, ys);
// pos = QTransform::scale(0,0.2).map(pos);
// pos = QTransform().rotate(-20).map(pos);
pos = QTransform().rotate(-5).map(pos);
pos -= QPointF(40, 40);
// pos -= QPoint(10,10);
icon->setPos(pos);
baseline = qMax(baseline, ys);
static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline);
}
scene()->update();
}
示例2: qwtDrawStyle1Needle
static void qwtDrawStyle1Needle( QPainter *painter,
const QPalette &palette, QPalette::ColorGroup colorGroup,
double length )
{
const double r[] = { 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4 };
const double a[] = { -45, -20, -15, 0, 15, 20, 45 };
QPainterPath path;
for ( int i = 0; i < 7; i++ )
{
const double angle = a[i] / 180.0 * M_PI;
const double radius = r[i] * length;
const double x = radius * qCos( angle );
const double y = radius * qSin( angle );
path.lineTo( x, -y );
}
painter->setPen( Qt::NoPen );
painter->setBrush( palette.brush( colorGroup, QPalette::Light ) );
painter->drawPath( path );
}
示例3: if
QMatrix &QMatrix::rotate(qreal a)
{
qreal sina = 0;
qreal cosa = 0;
if (a == 90. || a == -270.)
sina = 1.;
else if (a == 270. || a == -90.)
sina = -1.;
else if (a == 180.)
cosa = -1.;
else{
qreal b = deg2rad*a; // convert to radians
sina = qSin(b); // fast and convenient
cosa = qCos(b);
}
qreal tm11 = cosa*_m11 + sina*_m21;
qreal tm12 = cosa*_m12 + sina*_m22;
qreal tm21 = -sina*_m11 + cosa*_m21;
qreal tm22 = -sina*_m12 + cosa*_m22;
_m11 = tm11; _m12 = tm12;
_m21 = tm21; _m22 = tm22;
return *this;
}
示例4: calcRadialPos
static
QPointF calcRadialPos ( const QStyleOptionSlider *dial, qreal offset )
{
const int width = dial->rect.width();
const int height = dial->rect.height();
const int r = qMin(width, height) / 2;
const int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
qreal a = 0;
if (dial->maximum == dial->minimum)
a = Q_PI / 2;
else if (dial->dialWrapping)
a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
/ (dial->maximum - dial->minimum);
else
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
/ (dial->maximum - dial->minimum)) / 6;
qreal xc = width / 2.0;
qreal yc = height / 2.0;
qreal len = r - calcBigLineSize(r) - 3;
qreal back = offset * len;
QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
return pos;
}
示例5: line
QPainterPath GraphicsEdgeItem::shape() const
{
QPainterPath path;
QPointF source = mEdgeData->sourceNode()->sceneCoor();
QPointF dest = mEdgeData->destNode()->sceneCoor();
QLineF line(source, dest);
qreal angle = line.angle();
if(angle>=180)
angle -= 180;
qreal dx = mWidth/2.0*qSin(angle);
qreal dy = mWidth/2.0*qCos(angle);
QPointF p1(source.x()-dx,source.y()+dy);
QPointF p2(source.x()+dx,source.y()-dy);
QPointF p3(dest.x()+dx,dest.y()-dy);
QPointF p4(dest.x()-dx,dest.y()+dy);
path.moveTo(p1);
path.lineTo(p2);
path.lineTo(p3);
path.lineTo(p4);
path.lineTo(p1);
return path;
}
示例6: return
Point Toolbox::arcCenter(const Point& p1, const Point& p2,
const Angle& a) noexcept {
if (a == 0) {
// there is no arc center...just return the middle of start- and endpoint
return (p1 + p2) / 2;
} else {
// http://math.stackexchange.com/questions/27535/how-to-find-center-of-an-arc-given-start-point-end-point-radius-and-arc-direc
qreal x0 = p1.getX().toMm();
qreal y0 = p1.getY().toMm();
qreal x1 = p2.getX().toMm();
qreal y1 = p2.getY().toMm();
qreal angle = a.mappedTo180deg().toRad();
qreal angleSgn = (angle >= 0) ? 1 : -1;
qreal d = qSqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
qreal r = d / (2 * qSin(angle / 2));
qreal h = qSqrt(r * r - d * d / 4);
qreal u = (x1 - x0) / d;
qreal v = (y1 - y0) / d;
qreal a = ((x0 + x1) / 2) - h * v * angleSgn;
qreal b = ((y0 + y1) / 2) + h * u * angleSgn;
return Point::fromMm(a, b);
}
}
示例7: qSqrt
void DistortionFXFilter::multipleCornersMultithreaded(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();
double nh, nw;
int nHalfW = Width / 2;
int nHalfH = Height / 2;
double lfRadMax = qSqrt(Height * Height + Width * Width) / 2.0;
double lfAngle, lfNewRadius, lfCurrentRadius;
for (int w = prm.start; runningFlag() && (w < prm.stop); ++w)
{
// we find the distance from the center
nh = nHalfH - prm.h;
nw = nHalfW - w;
// now, we get the distance
lfCurrentRadius = qSqrt(nh * nh + nw * nw);
// we find the angle from the center
lfAngle = qAtan2(nh, nw) * (double)prm.Factor;
// ok, we sum angle with accumuled to find a new angle
lfNewRadius = lfCurrentRadius * lfCurrentRadius / lfRadMax;
// now we find the exact position's x and y
nw = (double)nHalfW - (qCos(lfAngle) * lfNewRadius);
nh = (double)nHalfH - (qSin(lfAngle) * lfNewRadius);
setPixelFromOther(Width, Height, sixteenBit, bytesDepth, data, pResBits, w, prm.h, nw, nh, prm.AntiAlias);
}
}
示例8: draw
void draw( QPainter &painter, const Slice &slice, const uiCoord2D &pithCoord, const int &intensityThreshold, const TKD::ProjectionType &view )
{
painter.save();
painter.setPen(QColor(255,255,255,127));
const uint width = painter.window().width();
const uint height = painter.window().height();
const qreal angularIncrement = TWO_PI/(qreal)(width);
uint i, j, x, y;
if ( view == TKD::Z_PROJECTION )
{
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
{
if ( slice.at(j,i) > intensityThreshold ) painter.drawPoint(i,j);
}
}
}
else if ( view == TKD::CARTESIAN_PROJECTION )
{
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
{
x = pithCoord.x + j * qCos(i*angularIncrement);
y = pithCoord.y + j * qSin(i*angularIncrement);
if ( slice.at(y,x) > intensityThreshold ) painter.drawPoint(i,j);
}
}
}
painter.restore();
}
示例9: update
void SpaceObjectShip :: update(qint64 time)
{
if (mTargetX != -1 && mTargetY != -1)
{
double tAngle = angle(mCoordX, mCoordY, mTargetX, mTargetY);
double dist = distance(mCoordX, mCoordY, mTargetX, mTargetY) / 4;
double diff = angleDiff(mRotation, tAngle);
mDirection = turnDirection(mRotation, tAngle);
if (diff > -dist && diff < dist)
mTrust = true;
else
mTrust = false;
if (dist < 2)
{
mTargetX = -1;
mTargetY = -1;
mTrust = false;
mDirection = 0;
}
}
/* normal calculation of rotation / thrust */
mRotation += mDirection * (time / 1000.0) * ROT_PER_SEC;
if (mRotation < 0) mRotation += 360;
if (mRotation >= 360) mRotation -= 360;
if (mTrust)
{
mCoordX += qCos( DEG2RAD(mRotation) ) * (time / 1000.0) * SPEED_PER_SEC;
mCoordY += qSin( DEG2RAD(mRotation) ) * (time / 1000.0) * SPEED_PER_SEC;
}
}
示例10: qCos
void NMPT_simulator::buildModel(int iterations_number)
{
stone_trajectory.resize(iterations_number);
duck_trajectory.resize(iterations_number);
max_iter_achieved = iterations_number;
stone_trajectory[0].x = 0;
stone_trajectory[0].y=0;
stone_trajectory[0].Vx = qCos(qDegreesToRadians(alpha))*V;
stone_trajectory[0].Vy = qSin(qDegreesToRadians(alpha))*V;
duck_trajectory[0].x = dX0;
duck_trajectory[0].Vx = U;
closest_encounter.first = dX0;
closest_encounter.second = 0;
for(int i=1; i<iterations_number; i++)
{
moveDuck(i);
moveStone(i);
if(stone_trajectory[i].y < 0)
{
max_iter_achieved = i;
resize_trajectory(i);
break;
}
if(abs(stone_trajectory[i].x - duck_trajectory[i].x) < closest_encounter.first)
{
closest_encounter.first = abs(stone_trajectory[i].x - duck_trajectory[i].x);
closest_encounter.second = i;
}
}
}
示例11: while
qreal ImageProcessor::vectorSum(QImage input, QPoint start, int fakeangle) {
bool goOn = true;
QPoint currentPoint;
qreal returnMe =0.0;
int length=1;
qreal angle = (fakeangle/180.0) * M_PI;
while(goOn) {
int newX = (int)(start.x() + (length * qCos(angle) ));
int newY = (int)(start.y() + (length * qSin(angle) ));
currentPoint = QPoint(newX,newY);
if(input.valid(currentPoint)) {
//qreal value = regionAvg(currentPoint.x(),currentPoint.y(),1,1,input);
qreal value = qRed(input.pixel(currentPoint));
//qDebug()<<"Adding " <<(value/length);
returnMe += (value/sqrt(length));
//qDebug()<<"Return me is now " <<returnMe;
length++;
} else {
goOn = false;
}
}
return returnMe;
}
示例12: qSin
void NotificationSound::playSound()
{
//QSound::play(":/sound/notification_sound.wav");
//return;
qreal frequency = ((sFrequency <= 0)?2000:sFrequency);
qreal mseconds = ((sDuration <= 0)?1000:sDuration);
quint8 volume = ((sVolume <= 0)?1:sVolume);
qreal sampleRate = 2.0 * M_PI / (192000./frequency);
QByteArray bytebuf;
bytebuf.resize(mseconds * 192);
for (int i=0; i < bytebuf.size(); i++) {
bytebuf[i] = (quint8)(qreal(255) * qSin(qreal(i) * sampleRate));
}
QDataStream stream(&bytebuf, QIODevice::ReadWrite);
QAudioFormat format;
format.setSampleRate(192000);
format.setChannelCount(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
QAudioOutput * audio = new QAudioOutput(format, this);
audio->setVolume(1.0 * (qreal(volume + 1)/4));
audio->setBufferSize(bytebuf.size());
audio->start(stream.device());
QEventLoop loop;
QTimer::singleShot(mseconds*2, &loop, SLOT(quit()));
loop.exec();
}
示例13: setMatrix
/*!
\fn QTransform & QTransform::rotateRadians(qreal angle, Qt::Axis axis)
Rotates the coordinate system counterclockwise by the given \a angle
about the specified \a axis and returns a reference to the matrix.
Note that if you apply a QTransform to a point defined in widget
coordinates, the direction of the rotation will be clockwise
because the y-axis points downwards.
The angle is specified in radians.
\sa setMatrix()
*/
QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
{
qreal sina = qSin(a);
qreal cosa = qCos(a);
if (axis == Qt::ZAxis) {
if (type() != TxProject) {
qreal tm11 = cosa*affine._m11 + sina*affine._m21;
qreal tm12 = cosa*affine._m12 + sina*affine._m22;
qreal tm21 = -sina*affine._m11 + cosa*affine._m21;
qreal tm22 = -sina*affine._m12 + cosa*affine._m22;
affine._m11 = tm11; affine._m12 = tm12;
affine._m21 = tm21; affine._m22 = tm22;
} else {
QTransform result;
result.affine._m11 = cosa;
result.affine._m12 = sina;
result.affine._m22 = cosa;
result.affine._m21 = -sina;
*this = result * *this;
}
m_dirty |= TxRotate;
} else {
QTransform result;
if (axis == Qt::YAxis) {
result.affine._m11 = cosa;
result.m_13 = -sina * inv_dist_to_plane;
} else {
result.affine._m22 = cosa;
result.m_23 = -sina * inv_dist_to_plane;
}
m_dirty = TxProject;
*this = result * *this;
}
return *this;
}
示例14: glMatrixMode
void Widget::drawObj()//draw obj
{
// glLoadIdentity();
// drawTriangle();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(radius*qCos(AngToRad*xRot), yRot, radius*qSin(AngToRad*xRot), 0, 0, 0, 0, 1, 0);
// glTranslatef(0.0, 0.0, -50.0+zTra);
// glRotatef(xRot, 1.0, 0.0, 0.0);
// glRotatef(yRot, 0.0, qCos(yRot*AngToRad), -qSin(yRot*AngToRad));
// glRotatef(xRot, 0.0,1.0,0.0);
// glRotatef(zRot, 0.0, 0.0, 1.0);
glBegin(GL_TRIANGLES);
qglColor(Qt::green);
for(int i=0;i<ObjFace.length();i++){
glVertex3f(ObjFace[i].a.x,ObjFace[i].a.y,ObjFace[i].a.z);
glVertex3f(ObjFace[i].b.x,ObjFace[i].b.y,ObjFace[i].b.z);
glVertex3f(ObjFace[i].c.x,ObjFace[i].c.y,ObjFace[i].c.z);
}
// QMessageBox::information(NULL, "Title", ObjFace[ObjFace.length()-1].toQString(), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
glFlush();
glEnd();
}
示例15: rotation
void Bullet::move(){
int STEP_SIZE = 5;
double theta = rotation(); //degrees
double dy = STEP_SIZE * qSin(qDegreesToRadians(theta));
double dx = STEP_SIZE * qCos(qDegreesToRadians(theta));
setPos(x()+dx, y()+dy);
// get a list of all the items currently colliding with this bullet
QList<QGraphicsItem *> colliding_items = collidingItems();
if((x()>720)||(x()<-5)||(y()>720)||(y()<-5)){
scene()->removeItem(this);
delete this;
}
// if one of the colliding items is an Enemy, destroy both the bullet and the enemy
for (int i = 0, n = colliding_items.size(); i < n; ++i){
if (typeid(*(colliding_items[i])) == typeid(Enemy)){
//remove them from the scene (still on the heap)
scene()->removeItem(colliding_items[i]);
scene()->removeItem(this);
// delete them from the heap to save memory
delete colliding_items[i];
delete this;
// return (all code below refers to a non existent bullet)
return;
}
}
}