void Node2D::set_global_rotation(float p_radians) { CanvasItem *pi = get_parent_item(); if (pi) { const float parent_global_rot = pi->get_global_transform().get_rotation(); set_rotation(p_radians - parent_global_rot); } else { set_rotation(p_radians); } }
static void s6d04h0_clear(struct gpanel_hw *h, int color, int width, int height) { gpanel_cs_active(); /* Switch screen orientaation. */ if (width > height) set_rotation(1); /* Landscape */ else if (width < height) set_rotation(0); /* Portrait */ /* Fill the screen with a color. */ set_window(0, 0, _width-1, _height-1); flood(color, _width * _height); gpanel_cs_idle(); }
void ts::action::Stage::create_stage_entities(const Stage_data& stage_data) { const auto& track = world_->track(); const auto& start_points = track.start_points(); for (const auto& car_data : stage_data.cars) { if (car_data.car_def.model && car_data.start_pos < start_points.size() && car_lookup_.find(car_data.car_id) == car_lookup_.end()) { const auto& start_point = start_points[car_data.start_pos]; auto car = world_->create_car(*car_data.car_def.model); car->set_position(start_point.position); car->set_rotation(start_point.rotation); car->set_z_position(start_point.level); car_data_.emplace_back(); car_data_.back().car = car; cup::Car_data& internal = car_data_.back(); internal = car_data; if (car_data.controller && car_data.controller->control_slot != controls::invalid_slot) { control_center_->assume_control(car_data.controller->control_slot, car); } car_lookup_[car_data.car_id] = car; car->set_controllable_id(car_data.car_id); } } }
void zz_sky::render (bool recursive) { assert(is_visible()); // save rotation quat rot = this->get_rotation(); // rotation axis (z-axis) const vec3 axis(0, 0, 1); // render the first object only rotate_by_axis(this->rot_angles_current[0]*ZZ_TO_RAD, axis); invalidate_transform(); // TODO: extract this code out of render() call zz_material * mat = runits[0].material; if (mat) { mat->set_alpha_test(true); mat->set_receive_fog(receive_fog); mat->set_ztest(ztest); mat->set_zwrite(false); } // render unit render_runit(0); // restore rotation set_rotation(rot); invalidate_transform(); }
void set_phys_rotation(dBodyID body, const float *r) { dMatrix3 R; set_rotation(R, r); dBodySetRotation(body, R); }
void ThreadPiece::update_bishop_frame() { calculateBinormal(); //now rotate frame double curvature_binormal_norm = _curvature_binormal.norm(); Vector3d toRotAround = _curvature_binormal/curvature_binormal_norm; //this is last material frame rotated with curvature if (isnan(toRotAround(0))) { _bishop_frame = _prev_piece->_bishop_frame; } else { double for_ang = (_prev_piece->_edge.dot(_edge))/(_prev_piece->_edge_norm*_edge_norm); for_ang = max( min ( for_ang, 1.0), -1.0); double ang_to_rot_old = acos(for_ang); //double ang_to_rot = atan2(curvature_binormal_norm/2.0)*2.0; set_rotation(ang_to_rot_old, toRotAround); _bishop_frame = rot*_prev_piece->_bishop_frame; //this never seemed to happen, so comment for efficiency? double old_err = (_bishop_frame.col(0) - _edge.normalized()).norm(); if ( old_err > 1e-5) { //std::cout << "old err: " << old_err; set_rotation(-ang_to_rot_old, toRotAround); _bishop_frame = rot*_prev_piece->_bishop_frame; double new_err = (_bishop_frame.col(0) - _edge.normalized()).norm(); //std::cout << "new err: " << new_err << std::endl; // //in case it actually got worse, switch back if (new_err > old_err) { set_rotation(ang_to_rot_old, toRotAround); _bishop_frame = rot*_prev_piece->_bishop_frame; } } // _bishop_frame = Eigen::AngleAxisd(ang_to_rot, toRotAround)*_prev_piece->_bishop_frame; } }
RegistrationResult::RegistrationResult() { ccc_ = 0.0; name_ = ""; image_index_ = 0; projection_index_ = 0; set_shift(algebra::Vector2D(0., 0.)); set_rotation(0, 0, 0); }
void RegistrationResult::read_from_image(const em::ImageHeader &header) { algebra::Vector3D euler = header.get_euler_angles(); phi_ = euler[0]; theta_ = euler[1]; psi_ = euler[2]; set_rotation(phi_, theta_, psi_); algebra::Vector3D origin = header.get_origin(); shift_ = algebra::Vector2D(origin[0], origin[1]); }
RegistrationResult::RegistrationResult(double phi, double theta, double psi, algebra::Vector2D shift, int projection_index, int image_index, String name) { set_rotation(phi, theta, psi); set_shift(shift); projection_index_ = projection_index; image_index_ = image_index; name_ = name; }
RegistrationResult::RegistrationResult(algebra::Rotation3D R, algebra::Vector2D shift, int projection_index, int image_index, String name) { ccc_ = 0.0; set_rotation(R); set_shift(shift); projection_index_ = projection_index; image_index_ = image_index; name_ = name; }
void ThreadPiece::update_material_frame() { //if (_next_piece==NULL || _next_piece->_next_piece == NULL || _prev_piece==NULL) // return; if (_angle_twist == 0.0) { _material_frame = _bishop_frame; } else { set_rotation(_angle_twist, _edge/_edge_norm); //rot = Eigen::AngleAxisd(_angle_twist, _edge/_edge_norm); _material_frame = rot*_bishop_frame; } }
void GameObject::Reset() { Clamp clamp = { { 0.f, 0.f }, { 0.f, 0.f } }; set_position(); set_rotation(); set_size(); set_linear_velocity(); set_angular_velocity(); set_clamp(clamp); set_movement_velocity(); set_rotation_velocity(); }
void RegistrationResult::set_random_registration(unsigned int index, double maximum_shift) { // Random point in the sphere, pick to ensure even distribution double u=get_random_between_zero_and_one(); double v=get_random_between_zero_and_one(); double w=get_random_between_zero_and_one(); double phi = 2*PI*u; double theta = acos((2*v-1))/2; double psi=2*PI*w; set_rotation(phi,theta,psi); shift_[0] = maximum_shift*get_random_between_zero_and_one(); shift_[1] = maximum_shift*get_random_between_zero_and_one(); set_ccc(0.0); set_name(""); set_projection_index(index); set_image_index(0); }
inline void set_rotation_angles( const glm::vec3 &rotation_angles) noexcept { glm::quat rotation; rotation = glm::quat(); rotation = glm::rotate(rotation, rotation_angles.z, glm::vec3(0.0f, 0.0f, 1.0f)); rotation = glm::rotate(rotation, rotation_angles.x, glm::vec3(1.0f, 0.0f, 0.0f)); rotation = glm::rotate(rotation, rotation_angles.y, glm::vec3(0.0f, 1.0f, 0.0f)); set_rotation(rotation); }
void RegistrationResult::set_random_registration(unsigned int index, double maximum_shift) { ::boost::uniform_real<> rand(0., 1.); // Random point in the sphere, pick to ensure even distribution double u = rand(random_number_generator); double v = rand(random_number_generator); double w = rand(random_number_generator); double phi = 2 * PI * u; double theta = acos((2 * v - 1)) / 2; double psi = 2 * PI * w; set_rotation(phi, theta, psi); shift_[0] = maximum_shift * rand(random_number_generator); shift_[1] = maximum_shift * rand(random_number_generator); set_ccc(0.0); set_name(""); set_projection_index(index); set_image_index(0); }
void CameraSettings::setup(MMAL_COMPONENT_T *camera_) { camera = camera_; set_saturation(saturation); set_sharpness(sharpness); set_contrast(contrast); set_brightness(brightness); //set_ISO(ISO); TODO Not working for some reason set_video_stabilisation(videoStabilisation); set_exposure_compensation(exposureCompensation); set_exposure_mode(exposureMode); set_metering_mode(exposureMeterMode); set_awb_mode(awbMode); set_imageFX(imageEffect); set_colourFX(&colourEffects); //set_thumbnail_parameters(camera, ¶ms->thumbnailConfig); TODO Not working for some reason set_rotation(rotation); set_flips(hflip, vflip); }
void GLViewController::set_view_param(const Vec3f& e, const Vec3f& c, const Vec3f& u) { // native viewing direction is the negative z-axis // while right is the x-axis and up is the y-axis Vec3f view = c - e; float eye_dist = length(view); view /= eye_dist; Vec3f right = normalize(cross(view, u)); Vec3f up = cross(right, view); Mat3x3f rot(right, up, -view); rot = transpose(rot); // since matrix is row-major // convert the change-of-basis matrix to a quaternion Quatf qrot; qrot.make_rot(rot); set_rotation(qrot); set_centre(c); set_eye_dist(eye_dist); }
void calc() { value_type temp; for(size_type j=0;j<R.dimension().second;j++) { for(size_type i=R.dimension().first-1;i>j;i--) { if(std::abs(R[i][j])>eps) { set_rotation(R[j][j],R[i][j]); for(size_type k=0;k<R.dimension().second;k++) { temp = R[j][k]; R[j][k] = c*R[j][k] + s*R[i][k]; R[i][k] = -s*temp + c*R[i][k]; temp = G[j][k]; G[j][k] = c*G[j][k] + s*G[i][k]; G[i][k] = -s*temp + c*G[i][k]; } } R[i][j] = 0.0; } } G = G.trans(); }
void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float in_rotation_acceleration_time, float in_rotation_deceleration_time) { matrix temp_matrix = IDENTITY_MATRIX; if(in_target != NULL) { vec3d position = vmd_zero_vector; this->get_info(&position, NULL); if(in_target->xyz.x == position.xyz.x && in_target->xyz.y == position.xyz.y && in_target->xyz.z == position.xyz.z) { Warning(LOCATION, "Camera tried to point to self"); return; } vec3d targetvec; vm_vec_normalized_dir(&targetvec, in_target, &position); vm_vector_2_matrix(&temp_matrix, &targetvec, NULL, NULL); } set_rotation(&temp_matrix, in_rotation_time, in_rotation_acceleration_time, in_rotation_deceleration_time); }
void add_phys_mass(dMass *mass, dGeomID geom, const float p[3], const float r[16]) { dVector3 v; dMatrix3 M; dReal rad; dReal len; dMass add; if (r) set_rotation(M, r); if (dGeomGetClass(geom) != dPlaneClass) { dReal m = get_data(geom)->mass; /* Create a new mass for the given geom. */ switch (dGeomGetClass(geom)) { case dBoxClass: dGeomBoxGetLengths(geom, v); dMassSetBoxTotal(&add, m, v[0], v[1], v[2]); break; case dSphereClass: rad = dGeomSphereGetRadius(geom); dMassSetSphereTotal(&add, m, rad); break; case dCapsuleClass: dGeomCapsuleGetParams(geom, &rad, &len); dMassSetCapsuleTotal(&add, m, 3, rad, len); break; default: dMassSetZero(&add); break; } /* Transform the geom and mass to the given position and rotation. */ if(dGeomGetBody(geom)) { if (p) { dGeomSetOffsetPosition(geom, p[0], p[1], p[2]); dMassTranslate (&add, p[0], p[1], p[2]); } if (r) { dGeomSetOffsetRotation(geom, M); dMassRotate (&add, M); } } else { if (p) dGeomSetPosition(geom, p[0], p[1], p[2]); if (r) dGeomSetRotation(geom, M); } /* Accumulate the new mass with the body's existing mass. */ dMassAdd(mass, &add); } }
void PathFollow2D::_update_transform() { if (!path) return; Ref<Curve2D> c = path->get_curve(); if (!c.is_valid()) return; float path_length = c->get_baked_length(); float bounded_offset = offset; if (loop) bounded_offset = Math::fposmod(bounded_offset, path_length); else bounded_offset = CLAMP(bounded_offset, 0, path_length); Vector2 pos = c->interpolate_baked(bounded_offset, cubic); if (rotate) { float ahead = bounded_offset + lookahead; if (loop && ahead >= path_length) { // If our lookahead will loop, we need to check if the path is closed. int point_count = c->get_point_count(); if (point_count > 0) { Vector2 start_point = c->get_point_position(0); Vector2 end_point = c->get_point_position(point_count - 1); if (start_point == end_point) { // Since the path is closed we want to 'smooth off' // the corner at the start/end. // So we wrap the lookahead back round. ahead = Math::fmod(ahead, path_length); } } } Vector2 ahead_pos = c->interpolate_baked(ahead, cubic); Vector2 tangent_to_curve; if (ahead_pos == pos) { // This will happen at the end of non-looping or non-closed paths. // We'll try a look behind instead, in order to get a meaningful angle. tangent_to_curve = (pos - c->interpolate_baked(bounded_offset - lookahead, cubic)).normalized(); } else { tangent_to_curve = (ahead_pos - pos).normalized(); } Vector2 normal_of_curve = -tangent_to_curve.tangent(); pos += tangent_to_curve * h_offset; pos += normal_of_curve * v_offset; set_rotation(tangent_to_curve.angle()); } else { pos.x += h_offset; pos.y += v_offset; } set_position(pos); }
void Node2D::rotate(float p_radians) { set_rotation(get_rotation() + p_radians); }
void Node2D::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); }
void CanvasLayer::set_rotationd(real_t p_degrees) { set_rotation(Math::deg2rad(p_degrees)); }
void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) { set_rotation(p_euler_deg * Math_PI / 180.0); }
void CanvasLayer::_set_rotationd(real_t p_rotation) { set_rotation(Math::deg2rad(p_rotation)); }
int set_data_source_l(State **ps, const char* path) { printf("set_data_source\n"); int audio_index = -1; int video_index = -1; int i; State *state = *ps; printf("Path: %s\n", path); AVDictionary *options = NULL; av_dict_set(&options, "icy", "1", 0); av_dict_set(&options, "user-agent", "FFmpegMediaMetadataRetriever", 0); if (state->headers) { av_dict_set(&options, "headers", state->headers, 0); } if (state->offset > 0) { state->pFormatCtx = avformat_alloc_context(); state->pFormatCtx->skip_initial_bytes = state->offset; } if (avformat_open_input(&state->pFormatCtx, path, NULL, &options) != 0) { printf("Metadata could not be retrieved\n"); *ps = NULL; return FAILURE; } if (avformat_find_stream_info(state->pFormatCtx, NULL) < 0) { printf("Metadata could not be retrieved\n"); avformat_close_input(&state->pFormatCtx); *ps = NULL; return FAILURE; } set_duration(state->pFormatCtx); set_shoutcast_metadata(state->pFormatCtx); //av_dump_format(state->pFormatCtx, 0, path, 0); // Find the first audio and video stream for (i = 0; i < state->pFormatCtx->nb_streams; i++) { if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_index < 0) { video_index = i; } if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_index < 0) { audio_index = i; } set_codec(state->pFormatCtx, i); } if (audio_index >= 0) { stream_component_open(state, audio_index); } if (video_index >= 0) { stream_component_open(state, video_index); } /*if(state->video_stream < 0 || state->audio_stream < 0) { avformat_close_input(&state->pFormatCtx); *ps = NULL; return FAILURE; }*/ set_rotation(state->pFormatCtx, state->audio_st, state->video_st); set_framerate(state->pFormatCtx, state->audio_st, state->video_st); set_filesize(state->pFormatCtx); set_chapter_count(state->pFormatCtx); /*printf("Found metadata\n"); AVDictionaryEntry *tag = NULL; while ((tag = av_dict_get(state->pFormatCtx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { printf("Key %s: \n", tag->key); printf("Value %s: \n", tag->value); }*/ *ps = state; return SUCCESS; }
int decode_thread(void *arg) { VideoState *is = (VideoState *)arg; AVPacket pkt1, *packet = &pkt1; AVDictionary *io_dict = NULL; AVIOInterruptCB callback; int video_index = -1; int audio_index = -1; int i; int ret; int eof = 0; is->videoStream=-1; is->audioStream=-1; AVDictionary *options = NULL; av_dict_set(&options, "icy", "1", 0); av_dict_set(&options, "user-agent", "FFmpegMediaPlayer", 0); if (is->headers) { av_dict_set(&options, "headers", is->headers, 0); } if (is->offset > 0) { is->pFormatCtx = avformat_alloc_context(); is->pFormatCtx->skip_initial_bytes = is->offset; //is->pFormatCtx->iformat = av_find_input_format("mp3"); } // will interrupt blocking functions if we quit! callback.callback = decode_interrupt_cb; callback.opaque = is; if (avio_open2(&is->io_context, is->filename, 0, &callback, &io_dict)) { fprintf(stderr, "Unable to open I/O for %s\n", is->filename); return -1; } // Open video file if(avformat_open_input(&is->pFormatCtx, is->filename, NULL, &options)!=0) return -1; // Couldn't open file // Retrieve stream information if(avformat_find_stream_info(is->pFormatCtx, NULL)<0) return -1; // Couldn't find stream information // Dump information about file onto standard error av_dump_format(is->pFormatCtx, 0, is->filename, 0); // Find the first video stream for(i=0; i<is->pFormatCtx->nb_streams; i++) { if(is->pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && video_index < 0) { video_index=i; } if(is->pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audio_index < 0) { audio_index=i; } set_codec(is->pFormatCtx, i); } if(audio_index >= 0) { stream_component_open(is, audio_index); } if(video_index >= 0) { stream_component_open(is, video_index); } if(is->videoStream < 0 && is->audioStream < 0) { //if(is->videoStream < 0 || is->audioStream < 0) { fprintf(stderr, "%s: could not open codecs\n", is->filename); notify(is, MEDIA_ERROR, 0, 0); return 0; } set_rotation(is->pFormatCtx, is->audio_st, is->video_st); set_framerate(is->pFormatCtx, is->audio_st, is->video_st); set_filesize(is->pFormatCtx); set_chapter_count(is->pFormatCtx); // main decode loop for(;;) { if(is->quit) { break; } /*if (is->paused != is->last_paused) { is->last_paused = is->paused; if (is->paused) is->read_pause_return = av_read_pause(is->pFormatCtx); else av_read_play(is->pFormatCtx); }*/ // seek stuff goes here if(is->seek_req) { int64_t seek_target = is->seek_pos; int64_t seek_min = is->seek_rel > 0 ? seek_target - is->seek_rel + 2: INT64_MIN; int64_t seek_max = is->seek_rel < 0 ? seek_target - is->seek_rel - 2: INT64_MAX; int ret = avformat_seek_file(is->pFormatCtx, -1, seek_min, seek_target, seek_max, is->seek_flags); if(ret < 0) { fprintf(stderr, "%s: error while seeking\n", is->pFormatCtx->filename); } else { if(is->audioStream >= 0) { packet_queue_flush(&is->audioq); packet_queue_put(is, &is->audioq, &is->flush_pkt); } if(is->videoStream >= 0) { packet_queue_flush(&is->videoq); packet_queue_put(is, &is->videoq, &is->flush_pkt); } notify(is, MEDIA_SEEK_COMPLETE, 0, 0); } is->seek_req = 0; eof = 0; } if (is->audioq.size >= MAX_AUDIOQ_SIZE && !is->prepared) { queueAudioSamples(&is->audio_player, is); notify(is, MEDIA_PREPARED, 0, 0); is->prepared = 1; } if(is->audioq.size > MAX_AUDIOQ_SIZE || is->videoq.size > MAX_VIDEOQ_SIZE) { SDL_Delay(10); continue; } if((ret = av_read_frame(is->pFormatCtx, packet)) < 0) { if (ret == AVERROR_EOF || !is->pFormatCtx->pb->eof_reached) { eof = 1; break; } if(is->pFormatCtx->pb->error == 0) { SDL_Delay(100); /* no error; wait for user input */ continue; } else { break; } } // Is this a packet from the video stream? if(packet->stream_index == is->videoStream) { packet_queue_put(is, &is->videoq, packet); } else if(packet->stream_index == is->audioStream) { packet_queue_put(is, &is->audioq, packet); } else { av_free_packet(packet); } if (eof) { break; } } if (eof) { notify(is, MEDIA_PLAYBACK_COMPLETE, 0, 0); } return 0; }
void Spatial::_set_rotation_deg(const Vector3& p_deg) { set_rotation(p_deg * Math_PI / 180.0); }
void Object3D::set_global_rotation(const glm::quat &rotation) { glm::quat parent_rotation = parent() ? parent()->global_rotation() : glm::quat(); set_rotation(glm::inverse(parent_rotation) * rotation); }