本文整理汇总了C++中qSin函数的典型用法代码示例。如果您正苦于以下问题:C++ qSin函数的具体用法?C++ qSin怎么用?C++ qSin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qSin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:HoraceLee,项目名称:Tacters,代码行数:23,代码来源:blurpicker.cpp
示例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 );
}
开发者ID:lolsborn,项目名称:RovDash,代码行数:23,代码来源:qwt_dial_needle.cpp
示例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;
}
开发者ID:Marforius,项目名称:qt,代码行数:23,代码来源:qmatrix.cpp
示例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;
}
开发者ID:rncbc,项目名称:qmidictl,代码行数:23,代码来源:qmidictlDialStyle.cpp
示例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;
}
开发者ID:wolfbing,项目名称:graduate-pro,代码行数:23,代码来源:graphicsedgeitem.cpp
示例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);
}
}
开发者ID:LibrePCB,项目名称:LibrePCB,代码行数:23,代码来源:toolbox.cpp
示例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);
}
}
开发者ID:KDE,项目名称:digikam,代码行数:37,代码来源:distortionfxfilter.cpp
示例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();
}
开发者ID:kerautret,项目名称:TKDetection,代码行数:37,代码来源:slicealgorithm.cpp
示例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;
}
}
开发者ID:gmoonen,项目名称:OpenSpaceProject2D,代码行数:37,代码来源:SpaceObjectShip.cpp
示例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;
}
}
}
开发者ID:blenten,项目名称:nmiz,代码行数:37,代码来源:nmpt_simulator.cpp
示例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;
}
开发者ID:DesiOtaku,项目名称:gdrip,代码行数:24,代码来源:imageprocessor.cpp
示例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();
}
开发者ID:nhinze,项目名称:rhodes,代码行数:36,代码来源:notificationsound.cpp
示例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;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:50,代码来源:qtransform.cpp
示例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();
}
开发者ID:shibajiu,项目名称:qt_code,代码行数:24,代码来源:widget.cpp
示例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;
}
}
}
开发者ID:bananatreedad,项目名称:Tower_Defence,代码行数:36,代码来源:bullet.cpp
示例16: y
virtual double y ( double x ) const
{
return qSin( x );
}
开发者ID:CarnationTL,项目名称:cmd_sim,代码行数:4,代码来源:setwpdlg.cpp
示例17: d2aCallback
//--------------------------------------------------------------- d2aCallback
extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesToProcess,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
{
paUserData *udata=(paUserData*)userData;
short *wptr = (short*)outputBuffer;
unsigned int i;
static int n;
static int ic=0;
static bool btxok0=false;
static bool bTune0=false;
static int nStart=0;
static double phi=0.;
double tsec,tstart,dphi;
int nsec;
int nTRperiod=udata->nTRperiod;
// Get System time
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
tsec = 0.001*ms;
nsec = ms/1000;
qreal dPhase=iqPhase/5729.57795131;
qreal amp=1.0 + 0.0001*iqAmp;
qreal xAmp=txPower*295.00*qSqrt(2.0 - amp*amp);
qreal yAmp=txPower*295.00*amp;
static int nsec0=0;
if(bTune) {
ic=0;
dphi=6.28318530718*1270.46/11025.0;
}
if(bTune0 and !bTune) btxok=false;
bTune0=bTune;
if(nsec!=nsec0) {
// qDebug() << txPower << iqAmp << iqPhase << amp << xAmp << yAmp << dPhase << bTune;
// qDebug() << "A" << nsec%60 << bTune << btxok;
// ic=0;
nsec0=nsec;
}
if(btxok and !btxok0) { //Start (or re-start) a transmission
n=nsec/nTRperiod;
tstart=tsec - n*nTRperiod - 1.0;
if(tstart<1.0) {
ic=0; //Start of Tx cycle, set starting index to 0
nStart=n;
} else {
if(n != nStart) { //Late start in new Tx cycle: compute starting index
ic=(int)(tstart*11025.0);
ic=2*ic;
nStart=n;
}
}
}
btxok0=btxok;
if(btxok) {
for(i=0 ; i<framesToProcess; i++ ) {
short int i2a=iwave[ic++];
short int i2b=iwave[ic++];
if(ic > nwave) {i2a=0; i2b=0;}
// i2 = 500.0*(i2/32767.0 + 5.0*gran()); //Add noise (tests only!)
// if(bIQxt) {
if(1) {
if(bTune) {
phi += dphi;
} else {
phi=qAtan2(qreal(i2a),qreal(i2b));
}
i2a=xAmp*qCos(phi);
i2b=yAmp*qSin(phi + dPhase);
// qDebug() << xAmp << yAmp << phi << i2a << i2b;
}
// i2a=0.01*txPower*i2a;
// i2b=0.01*txPower*i2b;
*wptr++ = i2a; //left
*wptr++ = i2b; //right
}
} else {
for(i=0 ; i<framesToProcess; i++ ) {
*wptr++ = 0;
*wptr++ = 0;
ic++; ic++;
}
}
if(ic > nwave) {
btxok=0;
ic=0;
}
return 0;
}
开发者ID:BackupTheBerlios,项目名称:wsjt-svn,代码行数:96,代码来源:soundout.cpp
示例18: QLineF
/*!
\since 4.4
Returns a QLineF with the given \a length and \a angle.
The first point of the line will be on the origin.
Positive values for the angles mean counter-clockwise while negative values
mean the clockwise direction. Zero degrees is at the 3 o'clock position.
*/
QLineF QLineF::fromPolar(qreal length, qreal angle)
{
const qreal angleR = angle * M_2PI / 360.0;
return QLineF(0, 0, qCos(angleR) * length, -qSin(angleR) * length);
}
开发者ID:eaglezzb,项目名称:wtlcontrols,代码行数:15,代码来源:qline.cpp
示例19: sin
void MathPlot::setupScatterStyleDemo(QCustomPlot *customPlot)
{
customPlot->legend->setVisible(true);
customPlot->legend->setFont(QFont("Helvetica", 9));
customPlot->legend->setRowSpacing(-3);
QVector<QCPScatterStyle::ScatterShape> shapes;
shapes << QCPScatterStyle::ssCross;
shapes << QCPScatterStyle::ssPlus;
shapes << QCPScatterStyle::ssCircle;
shapes << QCPScatterStyle::ssDisc;
shapes << QCPScatterStyle::ssSquare;
shapes << QCPScatterStyle::ssDiamond;
shapes << QCPScatterStyle::ssStar;
shapes << QCPScatterStyle::ssTriangle;
shapes << QCPScatterStyle::ssTriangleInverted;
shapes << QCPScatterStyle::ssCrossSquare;
shapes << QCPScatterStyle::ssPlusSquare;
shapes << QCPScatterStyle::ssCrossCircle;
shapes << QCPScatterStyle::ssPlusCircle;
shapes << QCPScatterStyle::ssPeace;
shapes << QCPScatterStyle::ssCustom;
QPen pen;
// add graphs with different scatter styles:
for (int i=0; i<shapes.size(); ++i)
{
customPlot->addGraph();
pen.setColor(QColor(sin(i*0.3)*100+100, sin(i*0.6+0.7)*100+100, sin(i*0.4+0.6)*100+100));
// generate data:
QVector<double> x(10), y(10);
for (int k=0; k<10; ++k)
{
x[k] = k/10.0 * 4*3.14 + 0.01;
y[k] = 7*sin(x[k])/x[k] + (shapes.size()-i)*5;
}
customPlot->graph()->setData(x, y);
customPlot->graph()->rescaleAxes(true);
customPlot->graph()->setPen(pen);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
customPlot->graph()->setName(QCPScatterStyle::staticMetaObject.enumerator(QCPScatterStyle::staticMetaObject.indexOfEnumerator("ScatterShape")).valueToKey(shapes.at(i)));
#endif
customPlot->graph()->setLineStyle(QCPGraph::lsLine);
// set scatter style:
if (shapes.at(i) != QCPScatterStyle::ssCustom)
{
customPlot->graph()->setScatterStyle(QCPScatterStyle(shapes.at(i), 10));
}
else
{
QPainterPath customScatterPath;
for (int i=0; i<3; ++i)
customScatterPath.cubicTo(qCos(2*M_PI*i/3.0)*9, qSin(2*M_PI*i/3.0)*9, qCos(2*M_PI*(i+0.9)/3.0)*9, qSin(2*M_PI*(i+0.9)/3.0)*9, 0, 0);
customPlot->graph()->setScatterStyle(QCPScatterStyle(customScatterPath, QPen(), QColor(40, 70, 255, 50), 10));
}
}
// set blank axis lines:
customPlot->rescaleAxes();
customPlot->xAxis->setTicks(false);
customPlot->yAxis->setTicks(false);
customPlot->xAxis->setTickLabels(false);
customPlot->yAxis->setTickLabels(false);
// make top right axes clones of bottom left axes:
customPlot->axisRect()->setupFullAxesBox();
}
开发者ID:zhoajianjun,项目名称:QT,代码行数:65,代码来源:mathplot.cpp
示例20: qrand
void Meteor::init(const float& radiantAlpha, const float& radiantDelta,
const float& speed, const QList<ColorPair> colors)
{
// meteor velocity in km/s
m_speed = speed;
// find the radiant in horizontal coordinates
Vec3d radiantAltAz;
StelUtils::spheToRect(radiantAlpha, radiantDelta, radiantAltAz);
radiantAltAz = m_core->j2000ToAltAz(radiantAltAz);
float radiantAlt, radiantAz;
// S is zero, E is 90 degrees (SDSS)
StelUtils::rectToSphe(&radiantAz, &radiantAlt, radiantAltAz);
// meteors won't be visible if radiant is below 0degrees
if (radiantAlt < 0.f)
{
return;
}
// define the radiant coordinate system
// rotation matrix to align z axis with radiant
m_matAltAzToRadiant = Mat4d::zrotation(radiantAz) * Mat4d::yrotation(M_PI_2 - radiantAlt);
// select a random initial meteor altitude in the horizontal system [MIN_ALTITUDE, MAX_ALTITUDE]
float initialAlt = MIN_ALTITUDE + (MAX_ALTITUDE - MIN_ALTITUDE) * ((float) qrand() / ((float) RAND_MAX + 1));
// calculates the max z-coordinate for the currrent radiant
float maxZ = meteorZ(M_PI_2 - radiantAlt, initialAlt);
// meteor trajectory
// select a random xy position in polar coordinates (radiant system)
float xyDist = maxZ * ((double) qrand() / ((double) RAND_MAX + 1)); // [0, maxZ]
float theta = 2 * M_PI * ((double) qrand() / ((double) RAND_MAX + 1)); // [0, 2pi]
// initial meteor coordinates (radiant system)
m_position[0] = xyDist * qCos(theta);
m_position[1] = xyDist * qSin(theta);
m_position[2] = maxZ;
m_posTrain = m_position;
// store the initial z-component (radiant system)
m_initialZ = m_position[2];
// find the initial meteor coordinates in the horizontal system
Vec3d positionAltAz = m_position;
positionAltAz.transfo4d(m_matAltAzToRadiant);
// find the angle from horizon to meteor
float meteorAlt = qAsin(positionAltAz[2] / positionAltAz.length());
// this meteor should not be visible if it is above the maximum altitude
// or if it's below the horizon!
if (positionAltAz[2] > MAX_ALTITUDE || meteorAlt <= 0.f)
{
return;
}
// determine the final z-component and the min distance between meteor and observer
if (radiantAlt < 0.0262f) // (<1.5 degrees) earth grazing meteor ?
{
// earth-grazers are rare!
// introduce a probabilistic factor just to make them a bit harder to occur
float prob = ((float) qrand() / ((float) RAND_MAX + 1));
if (prob > 0.3f) {
return;
}
// limit lifetime to 12sec
m_finalZ = -m_position[2];
m_finalZ = qMax(m_position[2] - m_speed * 12.f, (double) m_finalZ);
m_minDist = xyDist;
}
else
{
// limit lifetime to 12sec
m_finalZ = meteorZ(M_PI_2 - meteorAlt, MIN_ALTITUDE);
m_finalZ = qMax(m_position[2] - m_speed * 12.f, (double) m_finalZ);
m_minDist = qSqrt(m_finalZ * m_finalZ + xyDist * xyDist);
}
// a meteor cannot hit the observer!
if (m_minDist < MIN_ALTITUDE) {
return;
}
// select random magnitude [-3; 4.5]
float Mag = (float) qrand() / ((float) RAND_MAX + 1) * 7.5f - 3.f;
// compute RMag and CMag
RCMag rcMag;
m_core->getSkyDrawer()->computeRCMag(Mag, &rcMag);
m_absMag = rcMag.radius <= 1.2f ? 0.f : rcMag.luminance;
if (m_absMag == 0.f) {
return;
}
//.........这里部分代码省略.........
开发者ID:PhiTheta,项目名称:stellarium,代码行数:101,代码来源:Meteor.cpp
注:本文中的qSin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论