Matrix LiuWestParticleFilter::state_distribution(RNG *rng) const { if (rng) { Resampler resampler(particle_weights(), false); return to_matrix(resampler(state_particles_, -1, *rng)); } else { return to_matrix(state_particles_); } }
HeartbeatResponse MatrixMasterThriftRpc::to_matrix(const ThriftHeartbeatResponse& t_res) { AgentConf conf = to_matrix(t_res.agentConf); std::vector<InstanceInfo> expect_instances; for (std::vector<ThriftInstanceInfo>::const_iterator itr = t_res.expectInstance.begin(); itr != t_res.expectInstance.end(); ++itr) { expect_instances.push_back(to_matrix(*itr)); } return HeartbeatResponse(conf, expect_instances); } // END OF CONVERT
AgentConf MatrixMasterThriftRpc::to_matrix(const ThriftAgentConf& t_conf) { return AgentConf(t_conf.safeMode, t_conf.heartbeatIntervalSec, t_conf.agentHttpPort, to_matrix(t_conf.reservedResource)); }
/// update of the rotation matrix 'mat_cur', using the position /// of the beginning of the dragging and the current position. /// both coordinates mapped to the surface of the virtual trackball. inline void update(void) { math::vec3 v_from = map_sphere(v_down, center, radius); math::vec3 v_to = map_sphere(v_cur, center, radius); if (drag) q_cur = from_ball_points(v_from, v_to) * q_end; to_matrix(mat_cur, q_cur); }
InstanceInfo MatrixMasterThriftRpc::to_matrix(const ThriftInstanceInfo& t_instance) { InstanceInfo instance(t_instance.serviceName, t_instance.offset); instance.set_error_code(static_cast<InstanceInfo::ErrorCode::type>(t_instance.errorCode)); instance.set_instance_state(static_cast<InstanceInfo::InstanceState::type>(t_instance.instanceState)); instance.set_instance_meta(to_matrix(t_instance.instanceMeta)); return instance; }
void Quaternion::rotate_vector(float *in,float *out) { float matrix[16]; normalize(); to_matrix(matrix); ApplyMatrix(in,matrix,out); } /* Quaternion::rotate_vector */
int update_circuit(Circuit* c) { gsl_matrix* A; gsl_vector* b; to_matrix(c,&A,&b); if(A==NULL){ return -1; } gsl_permutation * p=gsl_permutation_alloc(b->size); gsl_vector* x =gsl_vector_alloc(b->size); if(p==NULL||x==NULL){ printf("unable to allocate memory (update_circuit()), freeing and halting\n"); gsl_matrix_free(A); gsl_vector_free(b); if(p!=NULL){ gsl_permutation_free(p); } if(x!=NULL){ gsl_vector_free(x); } return -1; } int i,j; for(i=0;i<A->size1;i++){ printf("[ "); for(j=0;j<A->size2;j++) { printf("%6.3g ",gsl_matrix_get(A,i,j)); } printf("] [ %6.3g ]\n",gsl_vector_get(b,i)); } int s; gsl_linalg_LU_decomp(A,p,&s); double det=gsl_linalg_LU_det(A,s); printf("\ndeterminant is %g\n",det); if(det==0.0||(det<0x1p-16&&det>-0x1p-16)){ printf("ERROR, NON-TRIVIAL SOLUTION\nFREEING MEMORY AND HALTING COMPUTATION\n..."); gsl_vector_free(x); gsl_vector_free(b); gsl_matrix_free(A); gsl_permutation_free(p); printf("DONE\n"); return -1; } gsl_linalg_LU_solve(A,p,b,x); printf("\nthe solution is:\n"); print_vector(x); to_circuit(x,c); gsl_vector_free(x); gsl_matrix_free(A); gsl_vector_free(b); gsl_permutation_free(p); return 0; }
int main () { printf ("Results of utility_quat_to_matrix_test:\n"); quatf q = to_quat (degree (90.0f), vec3f (0, 0, 1)); dump ("q", q); dump ("to_matrix (q)", to_matrix (q)); mat3f m1; mat4f m2; to_matrix (q, m1); to_matrix (q, m2); dump ("to_matrix (q, m1)", m1); dump ("to_matrix (q, m2)", m2); return 0; }
void Quaternion::rotate_vector(Vector in,Vector &out) { float inv[4]={float(in.x),float(in.y),float(in.z),0},outv[4]={float(out.x),float(out.y),float(out.z),0}; float matrix[16]; normalize(); to_matrix(matrix); ApplyMatrix(inv,matrix,outv); out.x=outv[0]; out.y=outv[1]; out.z=outv[2]; } /* Quaternion::rotate_vector */
int main(void) { plan(375); assignment(); cmp(); init_from_vector(); init_from_angle_and_axe(); times_quaternion(); norm2(); conjugate(); to_matrix(); to_angle_and_axe(); return 0; }
InstanceMeta MatrixMasterThriftRpc::to_matrix(const ThriftAgentInstanceMeta& t_meta) { InstanceMeta meta; meta._meta_version = t_meta.metaVersion; meta._package_source = t_meta.packageSource; meta._package_version = t_meta.packageVersion; meta._package_type = static_cast<InstanceMeta::PackageType::type>(t_meta.packageType); meta._deploy_dir = t_meta.deployDir; meta._process_name = t_meta.processName; meta._tag = t_meta.tag; meta._deploy_timeout_sec = t_meta.deployTimeoutSec; meta._health_check_timeout_sec = t_meta.healthCheckTimeoutSec; meta._port = t_meta.port.port; meta._group = t_meta.group; meta._min_port_include = t_meta.port.minPortInclude; meta._max_port_include = t_meta.port.maxPortInclude; meta._resource = to_matrix(t_meta.resource); return meta; }
HeartbeatResponse MatrixMasterThriftRpc::heartbeat(const HeartbeatMessage& msg) throw (MatrixRpcException) { ::sailor::MutexLocker locker(&_mutex); // check connection. if (!_connected) { // close old connection. close_connection(); // init new connection. init_connection(); } // connection is not ready, try next time. if (!_connected) { throw MatrixRpcException("connection is not ready."); } try { ThriftHeartbeatMessage t_msg = to_thrift(msg, _host_ip, _host_name); ThriftHeartbeatResponse t_res; LOG.trace("MatrixMasterThriftRpc: heartbeat called"); _client->heartbeat(t_res, t_msg); LOG.trace("MatrixMasterThriftRpc: heartbeat finished."); return to_matrix(t_res); } catch (std::exception& ex) { LOG.warn("MatrixMasterThriftRpc: heartbeat error %s", ex.what()); _connected = false; throw MatrixRpcException(ex.what()); } }
/* virtual */ void av::utils::Trackball::evaluate() { av::FieldContainer::evaluate(); if(!Enable.getValue()) return; if(mReset) reset(); const bool newDragging = RotateTrigger.getValue() || ZoomTrigger.getValue() || PanTrigger.getValue(); const ::gua::math::vec3 projected = projectToSphere(Direction.getValue()); if(mDragging && newDragging) { if(RotateTrigger.getValue()) { auto quat = ::scm::math::quat<double>::from_arc(projected, mLastProjected); ::gua::math::mat4 rotMat = quat.to_matrix(); double fac = double(SpinningWeightingCoefficient.getValue()); mRotation = rotMat * ::scm::math::make_scale(fac, fac, fac) * mRotation; Matrix.setValue(mCenterTransInv * rotMat * CenterTransform.getValue() * Matrix.getValue()); } else if(ZoomTrigger.getValue()) { const ::gua::math::vec2 offset = mLastDirection - Direction.getValue(); float zoomFactor = offset.y; zoomFactor *= BoundingSphere.getValue()->Radius.getValue() * ZoomPanFactor.getValue(); if(AutoAdjustCenterTransform.getValue()) { ::gua::math::mat4 mat = CenterTransform.getValue() * ::scm::math::make_translation(double(0.0), double(0.0), double(zoomFactor)); CenterTransform.setValue(mat); } Matrix.setValue(mCenterTransInv * ::scm::math::make_translation(double(0.0), double(0.0), double(-zoomFactor)) * CenterTransform.getValue() * Matrix.getValue()); } else if(PanTrigger.getValue()) { const ::gua::math::vec2 offset = mLastDirection - Direction.getValue(); float xPanFactor = offset.x * BoundingSphere.getValue()->Radius.getValue() * ZoomPanFactor.getValue(); float yPanFactor = offset.y * BoundingSphere.getValue()->Radius.getValue() * ZoomPanFactor.getValue(); Matrix.setValue(mCenterTransInv * ::scm::math::make_translation(double(xPanFactor), double(yPanFactor), double(0.0)) * CenterTransform.getValue() * Matrix.getValue()); } mSpinning = false; } else if(!mDragging && newDragging) { mRotation = ::gua::math::mat4::identity(); mTimeLastMovement = TimeIn.getValue(); } else if(mDragging && !newDragging) { float timeSinceLastRecordEvent = TimeIn.getValue() - mTimeLastMovement; if(timeSinceLastRecordEvent < SpinningTimeThreshold.getValue()) { mSpinning = true; } } if(mSpinning) { ::gua::math::quat rot = ::scm::math::quat<double>::from_matrix(mRotation); Matrix.setValue(mCenterTransInv * rot.to_matrix() * CenterTransform.getValue() * Matrix.getValue()); } if(ResetTrigger.getValue()) { reset(); mSpinning = false; } mDragging = newDragging; mLastDirection = Direction.getValue(); mLastProjected = projected; }