void detectLanding() { // if we are not trying to move by setting motor outputs if (isAlmostZero(goal_.roll()) && isAlmostZero(goal_.pitch()) && isAlmostZero(goal_.yaw()) && isGreaterThanMinThrottle(goal_.throttle())) { // and we are not currently moving (based on current velocities) auto angular = state_estimator_->getAngularVelocity(); auto velocity = state_estimator_->getLinearVelocity(); if (isAlmostZero(angular.roll()) && isAlmostZero(angular.pitch()) && isAlmostZero(angular.yaw()) && isAlmostZero(velocity.roll()) && isAlmostZero(velocity.pitch()) && isAlmostZero(velocity.yaw())) { // then we must be landed... landed_ = true; return; } } landed_ = false; }
unsigned int * generate_frequency_table (void) { for(int i = 0; i < NOTES; i++) { fFrequency[i] = pitch(fFCMIN, i); iFrequency[i] = (unsigned int) (pow(2.0,16.0)*fFrequency[i]); } return iFrequency; }
int LtpEncode(faacEncHandle hEncoder, CoderInfo *coderInfo, LtpInfo *ltpInfo, TnsInfo *tnsInfo, double *p_spectrum, double *p_time_signal) { int i, last_band; double num_bit[MAX_SHORT_WINDOWS]; double *predicted_samples; ltpInfo->global_pred_flag = 0; ltpInfo->side_info = 0; predicted_samples = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double)); switch(coderInfo->block_type) { case ONLY_LONG_WINDOW: case LONG_SHORT_WINDOW: case SHORT_LONG_WINDOW: last_band = (coderInfo->nr_of_sfb < MAX_LT_PRED_LONG_SFB) ? coderInfo->nr_of_sfb : MAX_LT_PRED_LONG_SFB; ltpInfo->delay[0] = pitch(p_time_signal, ltpInfo->buffer, 2 * BLOCK_LEN_LONG, 0, 2 * BLOCK_LEN_LONG, predicted_samples, <pInfo->weight, <pInfo->weight_idx); num_bit[0] = ltp_enc_tf(hEncoder, coderInfo, p_spectrum, predicted_samples, ltpInfo->mdct_predicted, coderInfo->sfb_offset, coderInfo->nr_of_sfb, last_band, ltpInfo->side_info, ltpInfo->sfb_prediction_used, tnsInfo); ltpInfo->global_pred_flag = (num_bit[0] == 0.0) ? 0 : 1; if(ltpInfo->global_pred_flag) for (i = 0; i < coderInfo->sfb_offset[last_band]; i++) p_spectrum[i] -= ltpInfo->mdct_predicted[i]; else ltpInfo->side_info = 1; break; default: break; } if (predicted_samples) FreeMemory(predicted_samples); return (ltpInfo->global_pred_flag); }
IplImage* host_image2d<V>::getIplImage() const { assert(begin_); //allocate the structure IplImage* frameIPL = cvCreateImageHeader(cvSize(ncols(),nrows()), sizeof(typename V::vtype)*8, V::size); //init the data structure cvSetData(frameIPL, (void*)begin(), pitch()); return frameIPL; }
void tImgLinear::alloc_data_buffer() { if( _data != nullptr ) { free_data_buffer(); } size_t s = size().y() * pitch(); uint8_t* p = static_cast<uint8_t*>( rlf::rimg_alloc_raw_data::alloc_raw_data( s ) ); // t_Img_template<uint8_t>::set_data((uint8_t *) GlobalAlloc(GMEM_FIXED, s) ); set_data( p ); _is_allocated = true; }
oz::cpu_image oz::cpu_image::copy( int x1, int y1, int x2, int y2 ) const { int cw = x2 - x1 + 1; int ch = y2 - y1 + 1; if ((x1 < 0) || (x2 >= (int)w()) || (y1 < 0) || (y2 >= (int)h()) || (cw <= 0) || (ch <= 0)) OZ_X() << "Invalid region!"; cpu_image dst(cw, ch, format()); uchar *src_ptr = ptr<uchar>() + y1 * row_size() + x1 * type_size(); cudaMemcpy2D(dst.ptr(), dst.pitch(), src_ptr, pitch(), dst.row_size(), dst.h(), cudaMemcpyHostToHost); return dst; }
void Controllable::trackMouse() { float deltaX, deltaY; input->getMouseDelta(deltaX, deltaY); // Adjust the deltas by the sensitivity. deltaX *= sensitivity / 100; deltaY *= sensitivity / 100; // DirectInput maps +y to down in screen coords. yaw(deltaX); pitch(deltaY); }
VideoFrame VideoFrameConverter::convert(const VideoFrame &frame, int fffmt) const { if (!frame.isValid() || fffmt == QTAV_PIX_FMT_C(NONE)) return VideoFrame(); if (!frame.constBits(0)) // hw surface return frame.to(VideoFormat::pixelFormatFromFFmpeg(fffmt)); const VideoFormat format(frame.format()); //if (fffmt == format.pixelFormatFFmpeg()) // return *this; if (!m_cvt) { m_cvt = new ImageConverterSWS(); } m_cvt->setBrightness(m_eq[0]); m_cvt->setContrast(m_eq[1]); m_cvt->setSaturation(m_eq[2]); m_cvt->setInFormat(format.pixelFormatFFmpeg()); m_cvt->setOutFormat(fffmt); m_cvt->setInSize(frame.width(), frame.height()); m_cvt->setOutSize(frame.width(), frame.height()); m_cvt->setInRange(frame.colorRange()); const int pal = format.hasPalette(); QVector<const uchar*> pitch(format.planeCount() + pal); QVector<int> stride(format.planeCount() + pal); for (int i = 0; i < format.planeCount(); ++i) { pitch[i] = frame.constBits(i); stride[i] = frame.bytesPerLine(i); } const QByteArray paldata(frame.metaData(QStringLiteral("pallete")).toByteArray()); if (pal > 0) { pitch[1] = (const uchar*)paldata.constData(); stride[1] = paldata.size(); } if (!m_cvt->convert(pitch.constData(), stride.constData())) { return VideoFrame(); } const VideoFormat fmt(fffmt); VideoFrame f(frame.width(), frame.height(), fmt, m_cvt->outData()); f.setBits(m_cvt->outPlanes()); f.setBytesPerLine(m_cvt->outLineSizes()); f.setTimestamp(frame.timestamp()); f.setDisplayAspectRatio(frame.displayAspectRatio()); // metadata? if (fmt.isRGB()) { f.setColorSpace(fmt.isPlanar() ? ColorSpace_GBR : ColorSpace_RGB); } else { f.setColorSpace(ColorSpace_Unknown); } // TODO: color range return f; }
Fl_Image *Fl_Image::scale(int W, int H) { Fl_Image *ret = new Fl_Image(W, H, bitspp()); ret->format()->copy(format()); Fl_Rect olds(0,0,width(),height()); Fl_Rect news(0,0,W,H); bool success = Fl_Renderer::stretch(m_data, bytespp(), pitch(), &olds, ret->data(), bytespp(), ret->pitch(), &news); if(!success) { delete ret; ret = 0; } return ret; }
void CameraComponent::onUpdate(float delta) { //Event_GetWindowResolution windowResolution; //SEND_EVENT(&windowResolution); //// Calculate split screen attribute //float aspectRatio = windowResolution.getAspectRatio(); // Update rotation while(itrPlayer.hasNext()) { AttributePtr<Attribute_Player> ptr_player = itrPlayer.getNext(); AttributePtr<Attribute_Health> ptr_health = ptr_player->ptr_health; AttributePtr<Attribute_Input> ptr_input = ptr_player->ptr_input; AttributePtr<Attribute_Camera> ptr_camera = ptr_player->ptr_camera; if(ptr_health->health <= 0) { //camera->aspectRatio += delta*100; //updateProj(camera); } else { yaw(ptr_input->rotation.x, ptr_camera); pitch(ptr_input->rotation.y, ptr_camera); } //Entity* entity = itrInput.owner(); //if(entity->hasAttribute(ATTRIBUTE_CAMERA)) //{ //std::vector<Attribute_Camera*> cameras = itrCamera.getMultiple(entity->getAttributes(ATTRIBUTE_CAMERA)); //for(int i=0; i<(int)cameras.size(); i++) //{ //Attribute_Camera* camera = itrCamera.at(player->ptr_camera);//cameras.at(i); //yaw(input->rotation.x, camera); //pitch(input->rotation.y, camera); //} //} } // Recalculate view while(itrCamera.hasNext()) { AttributePtr<Attribute_Camera> ptr_camera = itrCamera.getNext(); AttributePtr<Attribute_Spatial> ptr_spatial = ptr_camera->ptr_spatial; updateView(ptr_camera); updateProj(ptr_camera); } }
/* * Servo Information (all servos are generic) * */ void Heli::setup_servos() { this->servos.clear(); Servo pitch( -8.0*C_DEG2RAD, 8.0*C_DEG2RAD ); Servo roll( -8.0*C_DEG2RAD, 8.0*C_DEG2RAD ); Servo coll( -12.5*C_DEG2RAD, 18.0*C_DEG2RAD ); Servo tr( -20.0*C_DEG2RAD, 20.0*C_DEG2RAD ); this->servos.push_back( pitch ); this->servos.push_back( roll ); this->servos.push_back( coll ); this->servos.push_back( tr ); }
//////////////////////////////////////////////////////////////////////////////////////// // Convert From {Picth, Yaw} (DEGREES) //////////////////////////////////////////////////////////////////////////////////////// void CVec3::AngToVec() { float angle; float sp, sy, cp, cy; angle = yaw() * (RAVL_VEC_DEGTORADCONST); sy = sinf(angle); cy = cosf(angle); angle = pitch() * (RAVL_VEC_DEGTORADCONST); sp = sinf(angle); cp = cosf(angle); v[0] = cp * cy; v[1] = cp * sy; v[2] = -sp; }
void PeripheralSetup::setup(Projector& _proj) { QMatrix4x4 _matrix; qreal _theta = yaw().radians(); qreal _ct = -cos(_theta), _st = -sin(_theta); QVector2D _shiftVec = QVector2D(-_st,_ct) * shift_; QVector2D _p = _shiftVec + distanceCenter_ * QVector2D(_ct,_st); QVector3D _pos = QVector3D(_p.x(),_p.y(),towerHeight_); _matrix.translate(_pos); _matrix.rotate(yaw().degrees() + deltaYaw_.degrees(),QVector3D(0.0,0.0,1.0)); _matrix.rotate(-pitch().degrees(),QVector3D(0.0,1.0,0.0)); _matrix.rotate(roll().degrees(),QVector3D(1.0,0.0,0.0)); _proj.setMatrix(_matrix); }
void FreeCamera::cursorPositionCallback(const double xpos, const double ypos) { int dx, dy; if (cursorLastPos.x != Utils::MAX_INT) { dx = int(cursorLastPos.x - float(xpos)); yaw(dx * 0.1f, WORLD); } if (cursorLastPos.y != Utils::MAX_INT) { dy = int(cursorLastPos.y - float(ypos)); pitch(dy * 0.1f, LOCAL); } cursorLastPos.x = static_cast<int>(xpos); cursorLastPos.y = static_cast<int>(ypos); }
void IMU::UpdateData(IMU_DATA &data) { XsByteArray imuData; XsMessageArray msgs; while (msgs.empty()) { Aris::Core::Sleep(1); pDevice->readDataToBuffer(imuData); pDevice->processBufferedData(imuData, msgs); } //std::cout << "msg num:" << msgs.size()<<std::endl; for (XsMessageArray::iterator it = msgs.begin(); it != msgs.end(); ++it) { // Retrieve a packet XsDataPacket packet; if ((*it).getMessageId() == XMID_MtData2) { packet.setMessage((*it)); packet.setDeviceId(pDevice->mtPort.deviceId()); } // Get the all data auto eul = packet.orientationEuler(); auto sdi = packet.sdiData(); auto acc = packet.calibratedAcceleration(); data.yaw = eul.yaw()*PI / 180; data.pitch = eul.pitch()*PI / 180; data.roll = eul.roll()*PI / 180; data.va = sdi.orientationIncrement().x() * 2 * 100; data.vb = sdi.orientationIncrement().y() * 2 * 100; data.vc = sdi.orientationIncrement().z() * 2 * 100; std::copy_n(acc.data(), acc.size(), data.acc); data.time = packet.timeOfArrival().nowMs(); data.pmLhs = *pDevice->pmImuGround2BodyGround; data.pmRhs = *pDevice->pmBody2Imu; } msgs.clear(); }
WT_Boolean WT_Font::operator== (WT_Attribute const & attrib) const { if (attrib.object_id() == Font_ID && style() == ((WT_Font const &)attrib).style() && charset() == ((WT_Font const &)attrib).charset() && pitch() == ((WT_Font const &)attrib).pitch() && family() == ((WT_Font const &)attrib).family() && font_name() == ((WT_Font const &)attrib).font_name() && height() == ((WT_Font const &)attrib).height() && rotation() == ((WT_Font const &)attrib).rotation() && width_scale() == ((WT_Font const &)attrib).width_scale() && spacing() == ((WT_Font const &)attrib).spacing() && oblique() == ((WT_Font const &)attrib).oblique() && flags() == ((WT_Font const &)attrib).flags() ) return WD_True; else return WD_False; }
void BgLoader::RotateSelected(const csVector2& pos) { if(selectedMesh.IsValid()) { float factor_h = 6 * PI * ((float)previousPosition.x - pos.x) / g2d->GetHeight(); float factor_v = 6 * PI * ((float)previousPosition.y - pos.y) / g2d->GetHeight(); origRot += factor_h*currRot_h + factor_v*currRot_v; csYRotMatrix3 pitch(origRot.x); csYRotMatrix3 roll(origRot.y); csZRotMatrix3 yaw(origRot.z); csReversibleTransform trans(roll*yaw, rotBase); trans *= csReversibleTransform(pitch, -rotBase+origTrans); selectedMesh->GetMovable()->SetTransform(trans); previousPosition = pos; } }
SoXipNeheBoxGenerator::SoXipNeheBoxGenerator() { SO_NODE_CONSTRUCTOR(SoXipNeheBoxGenerator); SbRotation pitch(SbVec3f(1, 0, 0), 0); // rotation around X SbMatrix pitchM; SbRotation yaw(SbVec3f(0, 1, 0), 0); // rotation around Y SbMatrix yawM; SbMatrix transM = SbMatrix::identity(); // translation SbMatrix compM = SbMatrix::identity(); float xrot = 0; float yrot = 0; for (int yloop = 1; yloop < 6 /* number of rows */ ; yloop++) { for (int xloop = 0; xloop < yloop; xloop++) { // another magic formula from Nehe for the translation... transM.setTranslate(SbVec3f(1.4f+(float(xloop)*2.8f)-(float(yloop)*1.4f),((6.0f-float(yloop))*2.4f)-7.0f,-20.0f)); pitch.setValue(SbVec3f(1, 0, 0), (M_PI/180) * (45.0f-(2.0f*yloop)+ xrot)); pitch.getValue(pitchM); yaw.setValue(SbVec3f(0,1,0), (M_PI/180) * (45.0f + yrot)); yaw.getValue(yawM); compM = yawM * pitchM * transM; SoXipNeheBox* neheBox = new SoXipNeheBox(); neheBox->transform.setValue(compM); neheBox->topColor.setValue(topCol[yloop - 1]); neheBox->boxColor.setValue(boxCol[yloop - 1]); this->addChild(neheBox); } } }
//----------------------------------------------------------------------------- //! @brief TODO enter a description //! @remark //----------------------------------------------------------------------------- void Camera::update( float elapsedTime, double time, const Input& input ) { const InputState* inputState = input.getInput(0); if (inputState) { InputActions::ActionType fowardAction; InputActions::ActionType backwardAction; InputActions::ActionType moveLeftAction; InputActions::ActionType moveRightAction; InputActions::ActionType yawLeftAction; InputActions::ActionType yawRightAction; InputActions::ActionType pitchUpAction; InputActions::ActionType pitchDownAction; InputActions::ActionType rollLeftAction; InputActions::ActionType rollRightAction; InputSystem::getInputActionFromName(moveForward.getHash(), fowardAction); InputSystem::getInputActionFromName(moveBackWards.getHash(), backwardAction); InputSystem::getInputActionFromName(moveLeft.getHash(), moveLeftAction); InputSystem::getInputActionFromName(moveRight.getHash(), moveRightAction); InputSystem::getInputActionFromName(yawLeft.getHash(), yawLeftAction); InputSystem::getInputActionFromName(yawRight.getHash(), yawRightAction); InputSystem::getInputActionFromName(pitchUp.getHash(), pitchUpAction); InputSystem::getInputActionFromName(pitchDown.getHash(), pitchDownAction); InputSystem::getInputActionFromName(rollLeft.getHash(), rollLeftAction); InputSystem::getInputActionFromName(rollRight.getHash(), rollRightAction); float moveAlongDirectionFactor = inputState->getActionValue(fowardAction) - inputState->getActionValue(backwardAction); moveAlongDirection(moveAlongDirectionFactor * m_movementSpeed * elapsedTime );//Move forwared, backward float strafeFactor = inputState->getActionValue(moveLeftAction) - inputState->getActionValue(moveRightAction); strafe(strafeFactor * m_movementSpeed * elapsedTime);//Move left/right float yawFactor = inputState->getActionValue(yawLeftAction) - inputState->getActionValue(yawRightAction); yaw(yawFactor * m_rotationSpeed * elapsedTime); float pitchFactor = inputState->getActionValue(pitchUpAction) - inputState->getActionValue(pitchDownAction); pitch(pitchFactor * m_rotationSpeed * elapsedTime); float zAxisDelta = inputState->getActionValue(rollLeftAction) - inputState->getActionValue(rollRightAction); roll(zAxisDelta * m_rotationSpeed * 0.05f); } //Use the varibles to avoid a warning and allows us to use them in the code above without change time = 0.0; elapsedTime = 0.0f; }
Atm_player& Atm_player::begin( int pin /* = - 1 */ ) { // clang-format off const static state_t state_table[] PROGMEM = { /* ON_ENTER ON_LOOP ON_EXIT EVT_START EVT_STOP EVT_TOGGLE EVT_TIMER EVT_EOPAT EVT_REPEAT ELSE */ /* IDLE */ ENT_IDLE, ATM_SLEEP, -1, START, -1, START, -1, -1, -1, -1, /* START */ ENT_START, -1, -1, -1, -1, -1, -1, -1, -1, SOUND, /* SOUND */ ENT_SOUND, -1, -1, -1, IDLE, IDLE, QUIET, -1, -1, -1, /* QUIET */ ENT_QUIET, -1, -1, -1, IDLE, IDLE, NEXT, -1, -1, -1, /* NEXT */ ENT_NEXT, -1, -1, -1, IDLE, IDLE, -1, REPEAT, -1, SOUND, /* REPEAT */ ENT_REPEAT, -1, -1, -1, IDLE, IDLE, -1, -1, FINISH, START, /* FINISH */ ENT_FINISH, -1, -1, -1, IDLE, -1, -1, -1, IDLE, START, }; // clang-format on Machine::begin( state_table, ELSE ); Atm_player::pin = pin; speed( 100 ); pitch( 100 ); repeat( 1 ); return *this; }
void FreeCameraController::handleMouseMoveEvent(int x, int y) { if (!isActive()) return; if (mNaviPrimary) { double scalar = getCameraSensitivity() * (getInverted() ? -1.0 : 1.0); yaw(x * scalar); pitch(y * scalar); } else if (mNaviSecondary) { osg::Vec3d movement; movement += LocalLeft * -x * getSecondaryMovementMultiplier(); movement += LocalUp * y * getSecondaryMovementMultiplier(); translate(movement); } }
VideoFrame VideoFrameConverter::convert(const VideoFrame &frame, int fffmt) const { if (!frame.isValid() || fffmt == QTAV_PIX_FMT_C(NONE)) return VideoFrame(); if (!frame.bits(0)) // hw surface return frame.to(VideoFormat::pixelFormatFromFFmpeg(fffmt)); const VideoFormat format(frame.format()); //if (fffmt == format.pixelFormatFFmpeg()) // return *this; if (!m_cvt) { m_cvt = new ImageConverterSWS(); } m_cvt->setBrightness(m_eq[0]); m_cvt->setContrast(m_eq[1]); m_cvt->setSaturation(m_eq[2]); m_cvt->setInFormat(format.pixelFormatFFmpeg()); m_cvt->setOutFormat(fffmt); m_cvt->setInSize(frame.width(), frame.height()); m_cvt->setOutSize(frame.width(), frame.height()); QVector<const uchar*> pitch(format.planeCount()); QVector<int> stride(format.planeCount()); for (int i = 0; i < format.planeCount(); ++i) { pitch[i] = frame.bits(i); stride[i] = frame.bytesPerLine(i); } if (!m_cvt->convert(pitch.constData(), stride.constData())) { return VideoFrame(); } const VideoFormat fmt(fffmt); VideoFrame f(m_cvt->outData(), frame.width(), frame.height(), fmt); f.setBits(m_cvt->outPlanes()); f.setBytesPerLine(m_cvt->outLineSizes()); f.setTimestamp(frame.timestamp()); // metadata? if (fmt.isRGB()) { f.setColorSpace(fmt.isPlanar() ? ColorSpace_GBR : ColorSpace_RGB); } else { f.setColorSpace(ColorSpace_Unknow); } return f; }
WT_Result WT_Font::sync(WT_File & file) const { WD_Assert( (file.file_mode() == WT_File::File_Write) || (file.file_mode() == WT_File::Block_Append) || (file.file_mode() == WT_File::Block_Write)); if (*this != file.rendition().font()) { // Find out which fields of the font definition have changed and only // output those sub-fields. ((WT_Font &)(*this)).m_fields_defined = 0; if (font_name() != file.rendition().font().font_name()) ((WT_Font &)(*this)).m_fields_defined |= FONT_NAME_BIT; if (charset() != file.rendition().font().charset()) ((WT_Font &)(*this)).m_fields_defined |= FONT_CHARSET_BIT; if (pitch() != file.rendition().font().pitch()) ((WT_Font &)(*this)).m_fields_defined |= FONT_PITCH_BIT; if (family() != file.rendition().font().family()) ((WT_Font &)(*this)).m_fields_defined |= FONT_FAMILY_BIT; if (style() != file.rendition().font().style()) ((WT_Font &)(*this)).m_fields_defined |= FONT_STYLE_BIT; if (height() != file.rendition().font().height()) ((WT_Font &)(*this)).m_fields_defined |= FONT_HEIGHT_BIT; if (width_scale() != file.rendition().font().width_scale()) ((WT_Font &)(*this)).m_fields_defined |= FONT_WIDTH_SCALE_BIT; if (spacing() != file.rendition().font().spacing()) ((WT_Font &)(*this)).m_fields_defined |= FONT_SPACING_BIT; if (oblique() != file.rendition().font().oblique()) ((WT_Font &)(*this)).m_fields_defined |= FONT_OBLIQUE_BIT; if (flags() != file.rendition().font().flags()) ((WT_Font &)(*this)).m_fields_defined |= FONT_FLAGS_BIT; if (rotation() != file.rendition().font().rotation()) ((WT_Font &)(*this)).m_fields_defined |= FONT_ROTATION_BIT; WD_CHECK (serialize(file)); file.rendition().font() = *this; } return WT_Result::Success; }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void Camera::pitch(const Math::Radian& _pitch, bool _parent, bool _local) { Ogre::Radian pitch(_pitch); if (m_pSceneNode) { if (_parent) { m_pSceneNode->getParentSceneNode()->pitch(pitch, _local ? Ogre::Node::TS_LOCAL : Ogre::Node::TS_WORLD); } else { m_pSceneNode->pitch(pitch, _local ? Ogre::Node::TS_LOCAL : Ogre::Node::TS_WORLD); } } else { m_camera.pitch(pitch); } }
void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item) { if (!m_initialized) { auto qquickMapbox = static_cast<QQuickMapboxGL*>(item); QObject::connect(m_map.data(), &QMapboxGL::needsRendering, qquickMapbox, &QQuickMapboxGL::update); QObject::connect(this, &QQuickMapboxGLRenderer::centerChanged, qquickMapbox, &QQuickMapboxGL::setCenter); m_initialized = true; } auto quickMap = static_cast<QQuickMapboxGL*>(item); auto syncStatus = quickMap->swapSyncState(); if (syncStatus & QQuickMapboxGL::CenterNeedsSync || syncStatus & QQuickMapboxGL::ZoomNeedsSync) { const auto& center = quickMap->center(); m_map->setCoordinateZoom({ center.latitude(), center.longitude() }, quickMap->zoomLevel()); } if (syncStatus & QQuickMapboxGL::StyleNeedsSync) { m_map->setStyleURL(quickMap->style()); } if (syncStatus & QQuickMapboxGL::PanNeedsSync) { m_map->moveBy(quickMap->swapPan()); emit centerChanged(QGeoCoordinate(m_map->latitude(), m_map->longitude())); } if (syncStatus & QQuickMapboxGL::BearingNeedsSync) { m_map->setBearing(quickMap->bearing()); } if (syncStatus & QQuickMapboxGL::PitchNeedsSync) { m_map->setPitch(quickMap->pitch()); } if (syncStatus & QQuickMapboxGL::ColorNeedsSync && m_map->isFullyLoaded()) { m_map->setPaintProperty("background", "background-color", quickMap->color()); } }
void checkMouseRotation() { static const float maxAngle = 89.5f; // Max degrees of rotation static const float rotateSpeed = 5.0f * (1.0f / 60.0f); static float pitchAmt; if (!mouse.leftButtonDown) { return; } // Rotate left/right: float amt = static_cast<float>(mouse.deltaX) * rotateSpeed; rotate(degToRad(-amt)); // Calculate amount to rotate up/down: amt = static_cast<float>(mouse.deltaY) * rotateSpeed; // Clamp pitch amount: if ((pitchAmt + amt) <= -maxAngle) { amt = -maxAngle - pitchAmt; pitchAmt = -maxAngle; } else if ((pitchAmt + amt) >= maxAngle) { amt = maxAngle - pitchAmt; pitchAmt = maxAngle; } else { pitchAmt += amt; } pitch(degToRad(-amt)); }
//returns true if the pitch attempt failed due to constraints bool Camera::constrainedPitch(float theta) { auto oldUpVector = upVector_; auto oldLookingAt = lookingAt_; pitch(theta); /* revert the pitch if any of the conditions are true: (orientation.z < 0 && upVector_.z < 0) ==> if looking down upside-down (orientation.z > 0 && upVector_.z < 0) ==> if looking up but tilted back */ if (upVector_.z < 0 && (float)fabs(calculateLookDirection().z) > 0.00001f) // != 0 { upVector_ = oldUpVector; lookingAt_ = oldLookingAt; viewUpdated_ = true; //std::cout << "Camera pitch constrained. Reverted request." << std::endl; return true; } return false; }
qreal BarChartCore::barWidth() const { return qRound(pitch() / (dimensionsList().length() + 1)); }
autoPitch SPINET_to_Pitch (SPINET me, double harmonicFallOffSlope, double ceiling, int maxnCandidates) { try { long nPointsPerOctave = 48; double fmin = NUMerbToHertz (Sampled2_rowToY (me, 1)); double fmax = NUMerbToHertz (Sampled2_rowToY (me, my ny)); double fminl2 = NUMlog2 (fmin), fmaxl2 = NUMlog2 (fmax); double points = (fmaxl2 - fminl2) * nPointsPerOctave; double dfl2 = (fmaxl2 - fminl2) / (points - 1); long nFrequencyPoints = (long) floor (points); long maxHarmonic = (long) floor (fmax / fmin); double maxStrength = 0.0, unvoicedCriterium = 0.45, maxPower = 0.0; if (nFrequencyPoints < 2) { Melder_throw (U"Frequency range too small."); } if (ceiling <= fmin) { Melder_throw (U"Ceiling is smaller than centre frequency of lowest filter."); } autoPitch thee = Pitch_create (my xmin, my xmax, my nx, my dx, my x1, ceiling, maxnCandidates); autoNUMvector<double> power (1, my nx); autoNUMvector<double> pitch (1, nFrequencyPoints); autoNUMvector<double> sumspec (1, nFrequencyPoints); autoNUMvector<double> y (1, my ny); autoNUMvector<double> yv2 (1, my ny); autoNUMvector<double> fl2 (1, my ny); // From ERB's to log (f) for (long i = 1; i <= my ny; i++) { double f = NUMerbToHertz (my y1 + (i - 1) * my dy); fl2[i] = NUMlog2 (f); } // Determine global maximum power in frame for (long j = 1; j <= my nx; j++) { double p = 0.0; for (long i = 1; i <= my ny; i++) { p += my s[i][j]; } if (p > maxPower) { maxPower = p; } power[j] = p; } if (maxPower == 0.0) { Melder_throw (U"No power"); } for (long j = 1; j <= my nx; j++) { Pitch_Frame pitchFrame = &thy frame[j]; pitchFrame -> intensity = power[j] / maxPower; for (long i = 1; i <= my ny; i++) { y[i] = my s[i][j]; } NUMspline (fl2.peek(), y.peek(), my ny, 1e30, 1e30, yv2.peek()); for (long k = 1; k <= nFrequencyPoints; k++) { double f = fminl2 + (k - 1) * dfl2; NUMsplint (fl2.peek(), y.peek(), yv2.peek(), my ny, f, & pitch[k]); sumspec[k] = 0.0; } // Formula (8): weighted harmonic summation. for (long m = 1; m <= maxHarmonic; m++) { double hm = 1 - harmonicFallOffSlope * NUMlog2 (m); long kb = 1 + (long) floor (nPointsPerOctave * NUMlog2 (m)); for (long k = kb; k <= nFrequencyPoints; k++) { if (pitch[k] > 0.0) { sumspec[k - kb + 1] += pitch[k] * hm; } } } // into Pitch object Pitch_Frame_init (pitchFrame, maxnCandidates); pitchFrame -> nCandidates = 0; /* !!!!! */ Pitch_Frame_addPitch (pitchFrame, 0, 0, maxnCandidates); /* unvoiced */ for (long k = 2; k <= nFrequencyPoints - 1; k++) { double y1 = sumspec[k - 1], y2 = sumspec[k], y3 = sumspec[k + 1]; if (y2 > y1 && y2 >= y3) { double denum = y1 - 2.0 * y2 + y3, tmp = y3 - 4.0 * y2; double x = dfl2 * (y1 - y3) / (2 * denum); double f = pow (2.0, fminl2 + (k - 1) * dfl2 + x); double strength = (2.0 * y1 * (4.0 * y2 + y3) - y1 * y1 - tmp * tmp) / (8.0 * denum); if (strength > maxStrength) { maxStrength = strength; } Pitch_Frame_addPitch (pitchFrame, f, strength, maxnCandidates); } } } // Scale the pitch strengths for (long j = 1; j <= my nx; j++) { double f0, localStrength; Pitch_Frame_getPitch (&thy frame[j], &f0, &localStrength); Pitch_Frame_resizeStrengths (&thy frame[j], localStrength / maxStrength, unvoicedCriterium); } return thee; } catch (MelderError) { Melder_throw (me, U": no Pitch created."); } }
void mouse(const float dX, const float dY, AttributePtr<Attribute_Camera> camera) { yaw(dY, camera); pitch(dY, camera); }