// // update - gets latest data from sensors if it is time to read them again // void Sensors::update() { // gps gps->update(); // barometer float temp, pressure; if (barometer->readRawValues(&temp, &pressure)) { // calculate altitude sensorData.pressAltitude = 44330 * (1.0 - pow(pressure / PRESSURE_SEA_LEVEL, 0.1903)); } // mag/accel/gyro float gyroValues[3], accelValues[3], magValues[3]; if (mag->readRawValues(magValues) && accel->readRawValues(accelValues) && gyro->readRawValues(gyroValues)) { for (int i = 0; i++; i < 3) { sensorData.gyro_b[i] = gyroValues[i]; } updateRotationMatrix(gyroValues, accelValues, magValues); eulerAngles(); } // airspeed float airspeedBody[3] = {singleWire->readAirspeed(), 0, 0}; sensorData.airspeedRaw = airspeedBody[0]; matrixRotate(airspeedBody, sensorData.airspeed_e); }
void CCAMERA::Reset() { m_parametersChanged = true; m_projectionMatrix = glm::mat4( 1.0f ); m_projectionMatrixInv = glm::mat4( 1.0f ); m_rotationMatrix = glm::mat4( 1.0f ); m_rotationMatrixAux = glm::mat4( 1.0f ); m_lastPosition = wxPoint( 0, 0 ); m_zoom = 1.0f; m_zoom_t0 = 1.0f; m_zoom_t1 = 1.0f; m_camera_pos = m_camera_pos_init; m_camera_pos_t0 = m_camera_pos_init; m_camera_pos_t1 = m_camera_pos_init; m_lookat_pos = m_board_lookat_pos_init; m_lookat_pos_t0 = m_board_lookat_pos_init; m_lookat_pos_t1 = m_board_lookat_pos_init; m_rotate_aux = SFVEC3F( 0.0f ); m_rotate_aux_t0 = SFVEC3F( 0.0f ); m_rotate_aux_t1 = SFVEC3F( 0.0f ); updateRotationMatrix(); updateViewMatrix(); m_viewMatrixInverse = glm::inverse( m_viewMatrix ); m_scr_nX.clear(); m_scr_nY.clear(); rebuildProjection(); }
void CCAMERA::Interpolate( float t ) { wxASSERT( t >= 0.0f ); const float t0 = 1.0f - t; m_camera_pos = m_camera_pos_t0 * t0 + m_camera_pos_t1 * t; m_lookat_pos = m_lookat_pos_t0 * t0 + m_lookat_pos_t1 * t; m_rotate_aux = m_rotate_aux_t0 * t0 + m_rotate_aux_t1 * t; m_zoom = m_zoom_t0 * t0 + m_zoom_t1 * t; m_parametersChanged = true; updateRotationMatrix(); rebuildProjection(); }
void CCAMERA::RotateZ( float aAngleInRadians ) { m_rotate_aux.z += aAngleInRadians; updateRotationMatrix(); }