c++ - Use boost to convert degrees minutes seconds radians boost_1_48_0 -
i have got code work:
typedef model::point<double, 2, cs::spherical_equatorial<degree> > degree_point; degree_point flindersse(-37.0, 144.0);
and this:
quantity<plane_angle> flinders = 0.375 * radians; //this works 0.375 radians
but degrees minutes , seconds & convert radians again.
i have spent day trying understand how boost system works - examples bit thin on ground, wondering if show quick example?
thanks in advance 8+)
edit
//quantity<degree_base_unit> flinderssdeg2.value(-37.0); //quantity< angle::arcminute_base_unit> flinderssmin = 57.0; //quantity< angle::arcsecond_base_unit> flindersssec = 3.72030;
i guess need better understanding of how declaration works. :)
edit2:
thanks - maybe spent whole looking ways boost & facility wasn't there ! thought might have been because found obsolete code here http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/doxy/doxygen_input/sourcecode/doxygen_1.cpp
void example_dms() { /* extension, other coordinate system: // construction degree/minute/seconds boost::geometry::dms<boost::geometry::east> d1(4, 53, 32.5); // explicit conversion double. std::cout << d1.as_value() << std::endl; // conversion string, optional strings std::cout << d1.get_dms(" deg ", " min ", " sec") << std::endl; // combination latitude/longitude , cardinal directions { using namespace boost::geometry; point_ll<double, boost::geometry::cs::geographic<boost::geometry::degree> > canberra( latitude<>(dms<south>(35, 18, 27)), longitude<>(dms<east>(149, 7, 27.9))); std::cout << canberra << std::endl; } */ }
here conversion methods use boost units , angles:
double todegrees(const angle & angle) { return static_cast<boost::units::quantity<boost::units::degree::plane_angle>>(angle).value(); } double toradians(const angle & angle) { return static_cast<boost::units::quantity<boost::units::si::plane_angle>>(angle).value(); }
these complemented type-safe factories:
angle degrees(double angleindegrees) { return angleindegrees * boost::units::degree::degrees; } angle radians(double angleinradians) { return angle(angleinradians * boost::units::si::radians); }
to capture degrees, minutes, seconds, replace degrees doubles above conversion struct this:
struct dms { dms(double value) { degrees = std::floor(value); double rem = (value-degrees) * 60; minutes = std::floor(rem); seconds = (rem-minutes) * 60; } operator double() const { return degrees + minutes/60 + seconds/3600; } double degrees; double minutes; double seconds; };
Comments
Post a Comment