void eHealthDisplayClass::initECGScreen(void) { clearLCD(); delay(200); timePrevious = 0; timePreviousMeassure = 0; time = 0; countPrevious = 0; //ECG LOGO line(20, 49, 21, 49, 1); line(22, 49, 24, 55, 1); line(24, 55, 28, 45, 1); line(28, 45, 29, 49, 1); line(29, 49, 32, 49, 1); delay(100); //LETRAS POR PANTALLA coordinates(42, 52); writeLCD("ECG"); coordinates(100, 52); writeLCD( "cpm"); delay(150); timePreviousMeassure = millis(); count = 0; printHeart(1); x = 8; }
void test_spherical() { typedef typename bg::coordinate_type<P>::type ct; std::vector<P> v; v.push_back(bg::make<P>( 179.73, 71.56)); // east v.push_back(bg::make<P>( 177.47, 71.23)); // less east v.push_back(bg::make<P>(-178.78, 70.78)); // further east, = west, this is the most right point // Sort on coordinates in order x,y,z std::sort(v.begin(), v.end(), bg::less<P>()); std::string s = coordinates(v); BOOST_CHECK_EQUAL(s, "(177.47, 71.23)(179.73, 71.56)(-178.78, 70.78)"); // Sort ascending on only x-coordinate std::sort(v.begin(), v.end(), bg::less<P, 0>()); s = coordinates(v); BOOST_CHECK_EQUAL(s, "(177.47, 71.23)(179.73, 71.56)(-178.78, 70.78)"); // Sort ascending on only x-coordinate, but override with std-comparison, // (so this is the normal sorting behaviour that would have been used // if it would not have been spherical) std::sort(v.begin(), v.end(), bg::less<P, 0, std::less<ct> >()); s = coordinates(v); BOOST_CHECK_EQUAL(s, "(-178.78, 70.78)(177.47, 71.23)(179.73, 71.56)"); }
void ConvexPolygon::projectOnPlane( const Eigen::Affine3f& pose, Eigen::Affine3f& output) { Eigen::Vector3f p(pose.translation()); Eigen::Vector3f output_p; projectOnPlane(p, output_p); // ROS_INFO("[ConvexPolygon::projectOnPlane] p: [%f, %f, %f]", // p[0], p[1], p[2]); // ROS_INFO("[ConvexPolygon::projectOnPlane] output_p: [%f, %f, %f]", // output_p[0], output_p[1], output_p[2]); Eigen::Quaternionf rot; rot.setFromTwoVectors(pose.rotation() * Eigen::Vector3f::UnitZ(), coordinates().rotation() * Eigen::Vector3f::UnitZ()); Eigen::Quaternionf coords_rot(coordinates().rotation()); Eigen::Quaternionf pose_rot(pose.rotation()); // ROS_INFO("[ConvexPolygon::projectOnPlane] rot: [%f, %f, %f, %f]", // rot.x(), rot.y(), rot.z(), rot.w()); // ROS_INFO("[ConvexPolygon::projectOnPlane] coords_rot: [%f, %f, %f, %f]", // coords_rot.x(), coords_rot.y(), coords_rot.z(), coords_rot.w()); // ROS_INFO("[ConvexPolygon::projectOnPlane] pose_rot: [%f, %f, %f, %f]", // pose_rot.x(), pose_rot.y(), pose_rot.z(), pose_rot.w()); // ROS_INFO("[ConvexPolygon::projectOnPlane] normal: [%f, %f, %f]", normal_[0], normal_[1], normal_[2]); // Eigen::Affine3f::Identity() * // output.translation() = Eigen::Translation3f(output_p); // output.rotation() = rot * pose.rotation(); //output = Eigen::Translation3f(output_p) * rot * pose.rotation(); output = Eigen::Affine3f(rot * pose.rotation()); output.pretranslate(output_p); // Eigen::Vector3f projected_point = output * Eigen::Vector3f(0, 0, 0); // ROS_INFO("[ConvexPolygon::projectOnPlane] output: [%f, %f, %f]", // projected_point[0], projected_point[1], projected_point[2]); }
void eHealthDisplayClass::printValuesScreen(void) { delay(100); //Prints the current value of diastolic pressure. if (pulse != eHealth.getBPM()) { pulse = eHealth.getBPM(); clearSpace(70, 40, 90, 47); coordinates(70,47); Serial.print(pulse); delay(10); } //Stores the current value of skin conductance. float conductance = eHealth.getSkinConductance(); delay(20); //If conductance == -1, the sensor is no connected. if ( conductance == -1 ) { coordinates(70,35); Serial.print(F("NOCN")); //No connected message. delay(10); } else { coordinates(70,35); Serial.print(conductance,2); delay(10); } if (oxygen != eHealth.getOxygenSaturation()) { oxygen = eHealth.getOxygenSaturation(); clearSpace(70, 15, 90, 22); coordinates(70, 22); Serial.print(oxygen); delay(10); } //Prints the current value of temperature. coordinates(70,9); Serial.print(eHealth.getTemperature(),2); delay(10); //If no changes in position, don't refresh the screen. if (bodyPosition != eHealth.getBodyPosition()) { bodyPosition = eHealth.getBodyPosition(); clearSpace(95, 34, 117, 50); // Clear the previous position. if (bodyPosition == 1) supinePosition(); else if (bodyPosition == 2) leftLateralPosition(); else if (bodyPosition == 3) rigthLateralPosition(); else if (bodyPosition == 5) standPosition(); else pronePosition(); } delay(10); }
TEST_F(BodyTest, PreBrouwerOblateDeserializationSuccess) { EXPECT_FALSE(oblate_body_.is_massless()); EXPECT_TRUE(oblate_body_.is_oblate()); // Serialize post-Brouwer. serialization::Body post_brouwer_body; oblate_body_.WriteToMessage(&post_brouwer_body); serialization::MassiveBody const& post_brouwer_massive_body = post_brouwer_body.massive_body(); serialization::RotatingBody const& post_brouwer_rotating_body = post_brouwer_massive_body.GetExtension( serialization::RotatingBody::rotating_body); serialization::OblateBody const& post_brouwer_oblate_body = post_brouwer_rotating_body.GetExtension( serialization::OblateBody::oblate_body); // Construct explicitly an equivalent pre-Brouwer message. serialization::Body pre_brouwer_body; serialization::MassiveBody* pre_brouwer_massive_body = pre_brouwer_body.mutable_massive_body(); pre_brouwer_massive_body->mutable_gravitational_parameter()->CopyFrom( post_brouwer_massive_body.gravitational_parameter()); serialization::PreBrouwerOblateBody* pre_brouwer_oblate_body = pre_brouwer_massive_body->MutableExtension( serialization::PreBrouwerOblateBody::pre_brouwer_oblate_body); pre_brouwer_oblate_body->mutable_frame()->CopyFrom( post_brouwer_rotating_body.frame()); pre_brouwer_oblate_body->mutable_j2()->CopyFrom( post_brouwer_oblate_body.j2()); pre_brouwer_oblate_body->mutable_axis()->mutable_frame()->CopyFrom( post_brouwer_rotating_body.angular_velocity().frame()); auto const normalized_angular_velocity = Normalize(angular_velocity_); auto* const pre_brouwer_axis_r3_element = pre_brouwer_oblate_body->mutable_axis()->mutable_vector(); pre_brouwer_axis_r3_element->mutable_x()->set_double_( normalized_angular_velocity.coordinates().x); pre_brouwer_axis_r3_element->mutable_y()->set_double_( normalized_angular_velocity.coordinates().y); pre_brouwer_axis_r3_element->mutable_z()->set_double_( normalized_angular_velocity.coordinates().z); // Deserialize both. auto const post_brouwer = Body::ReadFromMessage(post_brouwer_body); auto const pre_brouwer = Body::ReadFromMessage(pre_brouwer_body); auto const* const cast_post_brouwer = dynamic_cast<OblateBody<World> const*>(&*post_brouwer); auto const* const cast_pre_brouwer = dynamic_cast<OblateBody<World> const*>(&*pre_brouwer); EXPECT_EQ(cast_post_brouwer->mass(), cast_pre_brouwer->mass()); EXPECT_EQ(cast_post_brouwer->axis(), cast_pre_brouwer->axis()); EXPECT_EQ(cast_post_brouwer->j2(), cast_pre_brouwer->j2()); }
void eHealthDisplayClass::printECGScreen(void) { for (int j=0; j<45; j++){ pixel(8,j,0); } delay(20); if (millis()-timePreviousMeassure > 10000){ countsPerMinute = 6*count; timePreviousMeassure = millis(); count = 0; //Clear space coordinates(95, 52); backspace(); coordinates(90, 52); backspace(); coordinates(85, 52); backspace(); coordinates(80, 52); backspace(); writeLcdDec(countsPerMinute); delay(20); } delay(10); printHeart(1); // Input 1 valRead = map(analogRead(0), 0, 1023, 5, 45); pixel (x, valRead, 1); if(x>12){ line(x-1, prevRead, x, valRead, 1); } //Hearth blink if(valRead> 30) { count=count+1; printHeart(0); delay(200); } //Wave refresh for (int j = 5; j<45; j++){ pixel(x+1,j,0); } //Previous value prevRead = valRead; x++; if (x == 120) x = 8; }
Teuchos::RCP<panzer_stk_classic::STK_Interface> buildMesh(int elemX,int elemY) { typedef panzer_stk_classic::STK_Interface::SolutionFieldType VariableField; typedef panzer_stk_classic::STK_Interface::VectorFieldType CoordinateField; RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList); pl->set("X Blocks",2); pl->set("Y Blocks",1); pl->set("X Elements",elemX); pl->set("Y Elements",elemY); panzer_stk_classic::SquareQuadMeshFactory factory; factory.setParameterList(pl); RCP<panzer_stk_classic::STK_Interface> mesh = factory.buildUncommitedMesh(MPI_COMM_WORLD); // add in some fields mesh->addSolutionField("dog","eblock-0_0"); mesh->addSolutionField("dog","eblock-1_0"); factory.completeMeshConstruction(*mesh,MPI_COMM_WORLD); VariableField * field = mesh->getMetaData()->get_field<VariableField>("dog"); CoordinateField * cField = mesh->getMetaData()->get_field<CoordinateField>("coordinates"); TEUCHOS_ASSERT(field!=0); TEUCHOS_ASSERT(cField!=0); // fill the fields with data const std::vector<stk_classic::mesh::Bucket*> nodeData = mesh->getBulkData()->buckets(mesh->getNodeRank()); for(std::size_t b=0; b<nodeData.size(); ++b) { stk_classic::mesh::Bucket * bucket = nodeData[b]; // build all buckets for(stk_classic::mesh::Bucket::iterator itr=bucket->begin(); itr!=bucket->end(); ++itr) { stk_classic::mesh::EntityArray<CoordinateField> coordinates(*cField,*itr); stk_classic::mesh::EntityArray<VariableField> dog_array(*field,*itr); double x = coordinates(0); double y = coordinates(1); dog_array() = 4.0*x*x+y; } } if(mesh->isWritable()) mesh->writeToExodus("output.exo"); return mesh; }
void FChart3d::Update() { double MaxX = DataMap3d->AddressZ.GetSizeX(); double MaxY = DataMap3d->AddressZ.GetSizeY(); if(DataMap3d->Data->IsEmply() || DataMap3d->AddressZ.IsEmpty()) { Surface3d->setMesh(3, 3); Surface3d->setDomain(0, 1, 0 , 1); Surface3d->create(); updateData(); updateGL(); return; } double MaxZ = GetMaxZ(); setTitle(DataMap3d->TitleGraf.isEmpty() ? "3D Map" : DataMap3d->TitleGraf); setRotation(30,0,15); setScale(MaxZ / MaxX, MaxZ / MaxY, 1); setShift(0,0,0); // Deslocamento setZoom(0.5); Surface3d->setMesh(MaxX+1, MaxY+1); Surface3d->setDomain(0, MaxX-1, 0 ,MaxY-1); Surface3d->create(); for (unsigned i=0; i!=coordinates()->axes.size(); ++i) { coordinates()->axes[i].setMajors(4); coordinates()->axes[i].setMinors(2); } coordinates()->setAutoScale(true); double Tic = (coordinates()->second() - coordinates()->first()).length() / MaxZ; Tic = Tic * 0.5; coordinates()->setTicLength(Tic,0.6*Tic); coordinates()->axes[X1].setLabelString("x-axis"); coordinates()->axes[Y1].setLabelString("y-axis"); //coordinates()->axes[Z1].setLabelString(QChar(0x38f)); // Omega - see http://www.unicode.org/charts/ //setCoordinateStyle(BOX); updateData(); updateGL(); }
void coordinates(node *p, double lengthsum, long *tipy, double *tipmax, node *start, boolean njoin) { /* establishes coordinates of nodes */ node *q, *first, *last; if (p->tip) { p->xcoord = (long)(over * lengthsum + 0.5); p->ycoord = *tipy; p->ymin = *tipy; p->ymax = *tipy; (*tipy) += down; if (lengthsum > *tipmax) *tipmax = lengthsum; return; } q = p->next; do { if (q->back) coordinates(q->back, lengthsum + q->v, tipy,tipmax, start, njoin); q = q->next; } while ((p == start || p != q) && (p != start || p->next != q)); first = p->next->back; q = p; while (q->next != p && q->next->back) /* is this right ? */ q = q->next; last = q->back; p->xcoord = (long)(over * lengthsum + 0.5); if (p == start && p->back) p->ycoord = p->next->next->back->ycoord; else p->ycoord = (first->ycoord + last->ycoord) / 2; p->ymin = first->ymin; p->ymax = last->ymax; } /* coordinates */
double EnvelopeFitRestraint::unprotected_evaluate( IMP::DerivativeAccumulator *accum) const { IMP_UNUSED(accum); // get the XYZs IMP::algebra::Vector3Ds coordinates(ps_.size()); for (unsigned int i = 0; i < ps_.size(); i++) { coordinates[i] = core::XYZ(ps_[i]).get_coordinates(); } // align algebra::Transformation3Ds map_transforms = pca_aligner_->align(coordinates); // filter and score, save best scoring only (or none if penetrating) bool best_found = false; IMP::algebra::Transformation3D best_trans; double best_score = -std::numeric_limits<double>::max(); for (unsigned int j = 0; j < map_transforms.size(); j++) { double score = envelope_score_->score(coordinates, map_transforms[j]); if (score > best_score) { best_score = score; best_trans = map_transforms[j]; best_found = true; } } if (best_found) const_cast<EnvelopeFitRestraint *>(this)->transformation_ = best_trans; else // store identity trans const_cast<EnvelopeFitRestraint *>(this)->transformation_ = algebra::Transformation3D(algebra::Vector3D(0, 0, 0)); return -best_score; }
void coordinates(node *p, double lengthsum, long *tipy, double *tipmax) { /* establishes coordinates of nodes */ node *q, *first, *last; if (p->tip) { p->xcoord = lengthsum; p->ycoord = *tipy; p->ymin = *tipy; p->ymax = *tipy; (*tipy) += down; if (lengthsum > (*tipmax)) (*tipmax) = lengthsum; return; } q = p->next; do { coordinates(q->back, lengthsum + q->v, tipy,tipmax); q = q->next; } while ((p == curtree.start || p != q) && (p != curtree.start || p->next != q)); first = p->next->back; q = p; while (q->next != p) q = q->next; last = q->back; p->xcoord = lengthsum; if (p == curtree.start) p->ycoord = p->next->next->back->ycoord; else p->ycoord = (first->ycoord + last->ycoord) / 2; p->ymin = first->ymin; p->ymax = last->ymax; } /* coordinates */
inline void createBoundingBoxesForElementsInElementBlocks(const stk::mesh::BulkData &bulk, FlaotBoxVector& domainBoxes) { stk::mesh::EntityVector elements; stk::mesh::get_selected_entities(bulk.mesh_meta_data().locally_owned_part(), bulk.buckets(stk::topology::ELEM_RANK), elements); size_t numberBoundingBoxes = elements.size(); domainBoxes.resize(numberBoundingBoxes); stk::mesh::FieldBase const * coords = bulk.mesh_meta_data().coordinate_field(); std::vector<double> boxCoordinates(6); for(size_t i=0;i<elements.size();++i) { unsigned num_nodes = bulk.num_nodes(elements[i]); std::vector<double> coordinates(3*num_nodes,0); const stk::mesh::Entity* nodes = bulk.begin_nodes(elements[i]); for(unsigned j=0;j<num_nodes;++j) { double* data = static_cast<double*>(stk::mesh::field_data(*coords, nodes[j])); coordinates[3*j] = data[0]; coordinates[3*j+1] = data[1]; coordinates[3*j+2] = data[2]; } findBoundingBoxCoordinates(coordinates, boxCoordinates); unsigned id = bulk.identifier(elements[i]); Ident domainBoxId(id, bulk.parallel_rank()); domainBoxes[i] = std::make_pair(FloatBox(boxCoordinates[0], boxCoordinates[1], boxCoordinates[2], boxCoordinates[3], boxCoordinates[4], boxCoordinates[5]), domainBoxId); } }
void FoursquareModel::parseFile( const QByteArray& file ) { QScriptValue data; QScriptEngine engine; // Qt requires parentheses around JSON data = engine.evaluate( '(' + QString::fromUtf8( file ) + ')' ); data = data.property("response"); // Parse if any result exists if ( data.property( "venues" ).isArray() ) { QScriptValueIterator iterator( data.property( "venues" ) ); // Add items to the list QList<AbstractDataPluginItem*> items; do { iterator.next(); QString id = iterator.value().property( "id" ).toString(); QString name = iterator.value().property( "name" ).toString(); QString category = iterator.value().property( "categories" ).property( 0 ).property( "name" ).toString(); QString address = iterator.value().property( "location" ).property( "address" ).toString(); QString city = iterator.value().property( "location" ).property( "city" ).toString(); QString country = iterator.value().property( "location" ).property( "country" ).toString(); double latitude = iterator.value().property( "location" ).property( "lat" ).toString().toDouble(); double longitude = iterator.value().property( "location" ).property( "lng" ).toString().toDouble(); int usersCount = iterator.value().property( "stats" ).property( "usersCount" ).toInteger(); QScriptValue categoryIcon = iterator.value().property( "categories" ).property( 0 ).property( "icon" ); QString iconUrl; QString largeIconUrl; if ( categoryIcon.isValid() ) { iconUrl = categoryIcon.property( "prefix" ).toString() + "32" // That's the icon size hardcoded + categoryIcon.property( "name" ).toString(); largeIconUrl = categoryIcon.property( "prefix" ).toString() + "64" // Larger icon + categoryIcon.property( "name" ).toString(); } if( !itemExists( id ) ) { GeoDataCoordinates coordinates( longitude, latitude, 0.0, GeoDataCoordinates::Degree ); FoursquareItem *item = new FoursquareItem( this ); item->setId( id ); item->setCoordinate( coordinates ); item->setTarget( "earth" ); item->setName( name ); item->setCategory( category ); item->setAddress( address ); item->setCity( city ); item->setCountry( country ); item->setUsersCount( usersCount ); item->setCategoryIconUrl( iconUrl ); item->setCategoryLargeIconUrl( largeIconUrl ); items << item; } } while ( iterator.hasNext() ); addItemsToList( items ); } }
void ImagePropertiesGPSTab::setMetadata(const DMetadata& meta, const KUrl& url) { double lat, lng; const bool haveCoordinates = meta.getGPSLatitudeNumber(&lat) && meta.getGPSLongitudeNumber(&lng); if (haveCoordinates) { double alt; const bool haveAlt = meta.getGPSAltitude(&alt); KGeoMap::GeoCoordinates coordinates(lat, lng); if (haveAlt) { coordinates.setAlt(alt); } GPSImageInfo gpsInfo; gpsInfo.coordinates = coordinates; gpsInfo.dateTime = meta.getImageDateTime(); gpsInfo.rating = meta.getImageRating(); gpsInfo.url = url; setGPSInfoList(GPSImageInfo::List() << gpsInfo); } else { clearGPSInfo(); } }
void coordinates(node *p, long *tipy, double f, long *fartemp) { /* establishes coordinates of nodes */ /* used in dollop, dolpenny, dolmove, & move */ node *q, *first, *last; if (p->tip) { p->xcoord = 0; p->ycoord = *tipy; p->ymin = *tipy; p->ymax = *tipy; *tipy += down; return; } q = p->next; do { coordinates(q->back, tipy, f, fartemp); q = q->next; } while (p != q); first = p->next->back; q = p->next; while (q->next != p) q = q->next; last = q->back; p->xcoord = (last->ymax - first->ymin) * f; p->ycoord = (first->ycoord + last->ycoord) / 2; p->ymin = first->ymin; p->ymax = last->ymax; if (p->xcoord > *fartemp) *fartemp = p->xcoord; } /* coordinates */
json QgsMultiPolygon::asJsonObject( int precision ) const { json polygons( json::array( ) ); for ( const QgsAbstractGeometry *geom : qgis::as_const( mGeometries ) ) { if ( qgsgeometry_cast<const QgsPolygon *>( geom ) ) { json coordinates( json::array( ) ); const QgsPolygon *polygon = static_cast<const QgsPolygon *>( geom ); std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() ); QgsPointSequence exteriorPts; exteriorLineString->points( exteriorPts ); coordinates.push_back( QgsGeometryUtils::pointsToJson( exteriorPts, precision ) ); std::unique_ptr< QgsLineString > interiorLineString; for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i ) { interiorLineString.reset( polygon->interiorRing( i )->curveToLine() ); QgsPointSequence interiorPts; interiorLineString->points( interiorPts ); coordinates.push_back( QgsGeometryUtils::pointsToJson( interiorPts, precision ) ); } polygons.push_back( coordinates ); } } return { { "type", "MultiPolygon" }, { "coordinates", polygons } }; }
std::vector<double> PottsMeshWriter<SPACE_DIM>::GetNextNode() { if (mpMesh) { // Sanity check assert(this->mNumNodes == mpMesh->GetNumNodes()); std::vector<double> coordinates(SPACE_DIM+1); // Get the node coordinates using the node iterator (thus skipping deleted nodes) for (unsigned j=0; j<SPACE_DIM; j++) { coordinates[j] = (*(mpIters->pNodeIter))->GetPoint()[j]; } coordinates[SPACE_DIM] = (*(mpIters->pNodeIter))->IsBoundaryNode(); ++(*(mpIters->pNodeIter)); return coordinates; } else { return AbstractMeshWriter<SPACE_DIM,SPACE_DIM>::GetNextNode(); } }
boost::optional< coordinates > great_circle::arc::intersection_with( const arc& rhs ) const { if (!may_intersect(rhs)) { return boost::optional< coordinates >(); } if( equal_( axis(), rhs.axis() ) || equal_( axis(), -rhs.axis() ) ) { return boost::optional< coordinates >(); } Eigen::Vector3d cross = axis().cross( rhs.axis() ); if( is_between_( *this, cross ) && is_between_( rhs, cross ) ) { snark::range_bearing_elevation a( cross ); // quick and dirty, quite excessive return coordinates( a.e(), a.b() ); } if( is_between_( *this, -cross ) && is_between_( rhs, -cross ) ) { snark::range_bearing_elevation a( -cross ); // quick and dirty, quite excessive return coordinates( a.e(), a.b() ); } return boost::optional< coordinates >(); }
Eigen::Vector2d great_circle::arc::tangent_in_navigation_frame_at( double angle ) const { const Eigen::Vector3d& v = at( angle ); const Eigen::Vector3d& n = snark::spherical::to_navigation_frame( coordinates( v ), angle_axis_.axis().cross( v ) ); Eigen::Vector2d projection( n.x(), n.y() ); //Eigen::Vector2d projection( v.y(), v.z() ); //Eigen::Vector2d projection( v.z(), v.y() ); projection.normalize(); return projection; }
void InternalCoordinatesTest::size() { chemkit::InternalCoordinates coordinates(1); QCOMPARE(coordinates.size(), size_t(1)); chemkit::InternalCoordinates newCoordinates(coordinates); QCOMPARE(newCoordinates.size(), size_t(1)); }
int GpsConnection::connectionState() const { const GgaSentence sentence = coordinates (); int result = 0; if (!sentence.isNull ()) { result = sentence.fixQuality () == GgaSentence::InvalidFix ? 1 : 2; } return result; }
/// @brief Element-by-element in-place addition of skew matrices. /// @note This operation corresponds to multiplication of the respective rotations. const Twist<NumType>& operator +=(const Twist<NumType>& T) { Twist<NumType> newTwist(T.coordinates() + coordinates()); _skew = newTwist._skew; _velocity = newTwist._velocity; return *this; }
double QhullHyperplane:: norm() const { double d= 0.0; const coordT *c= coordinates(); for (int k=dimension(); k--; ){ d += *c * *c; ++c; } return sqrt(d); }//norm
coordinates pretty_uniform_sample( const coordinates& centre, double radius ) { if( radius >= M_PI ) { COMMA_THROW( comma::exception, "support containing circle radius less than pi; got " << radius ); } const Eigen::Matrix3d& r1 = Eigen::AngleAxis< double >( centre.longitude, Eigen::Vector3d( 0, 0, 1 ) ).toRotationMatrix(); double a = ( impl::random() * 2 - 1 ) * radius; // double a = impl::random() * M_PI * 2; double b = ( impl::random() * 2 - 1 ) * radius; // double b = std::sqrt( impl::random() ) * radius; const Eigen::Vector3d& s = snark::range_bearing_elevation( 1, a, b ).to_cartesian(); // const Eigen::Vector3d& s = snark::range_bearing_elevation( 1, b * std::cos( a ), b * std::sin( a ) ).to_cartesian(); const Eigen::Matrix3d& r2 = Eigen::AngleAxis< double >( centre.latitude, Eigen::Vector3d( 0, -1, 0 ) ).toRotationMatrix(); return coordinates( r1 * r2 * s ); }
/* whether w lies inside the sector spanned by v1 and v2 */ bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w) { std::pair<double, double> coords = coordinates (v1, v2, w); if (coords.first == HUGE_VAL) { // catch the case that the vectors are not linearly independent // FIXME: Can we assume that it's safe to return true if the vectors point in different directions? return (Geom::dot (v1, v2) < 0); } return (coords.first >= 0 and coords.second >= 0); }
void Plane::project(const Eigen::Affine3f& pose, Eigen::Affine3f& output) { Eigen::Vector3f p(pose.translation()); Eigen::Vector3f output_p; project(p, output_p); Eigen::Quaternionf rot; rot.setFromTwoVectors(pose.rotation() * Eigen::Vector3f::UnitZ(), coordinates().rotation() * Eigen::Vector3f::UnitZ()); output = Eigen::Affine3f::Identity() * Eigen::Translation3f(output_p) * rot; }
std::tuple<std::valarray<std::string>, matrix, int> get_coordinates(const std::string filename) { std::string line; std::vector<std::string> coordinate_line; std::ifstream xyzfile (filename); unsigned int n_atoms {0}; std::string atom; std::vector<double> coordinate {}; double x, y, z; if(xyzfile.is_open()) { // Get number of atoms getline(xyzfile, line); n_atoms = stoi(line); // Allocate atoms and coordinates, // now that we know how many atoms are included std::valarray<std::string> atoms(n_atoms); matrix coordinates(3 * n_atoms); // Empty line getline(xyzfile, line); // Read coordinates int i = 0; while(getline(xyzfile, line)) { coordinate_line = split(line, ' '); atom = coordinate_line[0]; x = std::stod(coordinate_line[1]); y = std::stod(coordinate_line[2]); z = std::stod(coordinate_line[3]); // n_cols * row + col coordinates[3*i + 0] = x; coordinates[3*i + 1] = y; coordinates[3*i + 2] = z; atoms[i] = atom; i++; } xyzfile.close(); return make_tuple(atoms, coordinates, n_atoms); } else { std::cerr << "Unable to open " << filename << std::endl; exit(0); } }
static void checkOneArgMethod( Implementation::Model* model, Func model_method, int arg1, int arg2 ) { Abstract::Point coordinates(arg1, arg2); BOOST_REQUIRE_THROW( ((*model).*model_method)(coordinates), Exception ); }
void checkModelMethodForThrow<ThreeArgsMethod>( Implementation::Model* model, ThreeArgsMethod model_method, int arg1, int arg2 ) { Abstract::Point coordinates(0, 0); BOOST_REQUIRE_THROW( ((*model).*model_method)(arg1, arg2, coordinates), Exception ); }
/** * Recalculate the generated coordinates of the curve with specified step (0 to 1) */ void BezierCurve::regeneratePath(double step) { // The number of cubic curves to generate (4 points make 1 curve, 7 points make 2 curves etc) int curves = ((coordinates().size() - 4) / 3) + 1; const auto &coords = coordinates(); path.clear(); for (int i = 0; i < curves; i++) { /* calculate the polynomial coefficients */ double ax, bx, cx, dx; double ay, by, cy, dy; double az, bz, cz, dz; cx = 3.0 * (coords[i*3 + 1].x - coords[i*3 + 0].x); bx = 3.0 * (coords[i*3 + 2].x - coords[i*3 + 1].x) - cx; ax = coords[i*3 + 3].x - coords[i*3 + 0].x - cx - bx; dx = coords[i*3 + 0].x; cy = 3.0 * (coords[i*3 + 1].y - coords[i*3 + 0].y); by = 3.0 * (coords[i*3 + 2].y - coords[i*3 + 1].y) - cy; ay = coords[i*3 + 3].y - coords[i*3 + 0].y - cy - by; dy = coords[i*3 + 0].y; cz = 3.0 * (coords[i*3 + 1].z - coords[i*3 + 0].z); bz = 3.0 * (coords[i*3 + 2].z - coords[i*3 + 1].z) - cz; az = coords[i*3 + 3].z - coords[i*3 + 0].z - cz - bz; dz = coords[i*3 + 0].z; /* calculate the curve point at parameter value t */ for (double t = 0; t < 1; t += step) { double tSquared, tCubed; double x, y, z; tSquared = t * t; tCubed = tSquared * t; x = (ax * tCubed) + (bx * tSquared) + (cx * t) + dx; y = (ay * tCubed) + (by * tSquared) + (cy * t) + dy; z = (az * tCubed) + (bz * tSquared) + (cz * t) + dz; path.emplace_back(x, y, z); } } path.push_back(coordinates()[curves * 3]); // Make sure the last point is included }