COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
qlast Struct Reference

Quaternion, scalar last, using vector elements. More...

#include <vector.h>

Collaboration diagram for qlast:

Public Member Functions

 qlast ()
 
 qlast (double tq1, double tq2, double tq3, double tq4)
 
json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

double q1 = 0.
 
double q2 = 0.
 
double q3 = 0.
 
double q4 = 0.
 

Detailed Description

Quaternion, scalar last, using vector elements.

Can be thought of as vector elements, q1, q2, q3, followed by scalar q4.

Constructor & Destructor Documentation

qlast::qlast ( )
inline
513 {}
qlast::qlast ( double  tq1,
double  tq2,
double  tq3,
double  tq4 
)
inline
514  {
515  q1 = tq1;
516  q2 = tq2;
517  q3 = tq3;
518  q4 = tq4;
519  }
double q2
Definition: vector.h:509
double q4
Definition: vector.h:511
double q3
Definition: vector.h:510
double q1
Definition: vector.h:508

Member Function Documentation

json11::Json qlast::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
525  {
526  return json11::Json::object {
527  { "q1" , q1 },
528  { "q2" , q2 },
529  { "q3" , q3 },
530  { "q4" , q4 }
531  };
532  }
std::map< std::string, Json > object
Definition: json11.hpp:88
double q2
Definition: vector.h:509
double q4
Definition: vector.h:511
double q3
Definition: vector.h:510
double q1
Definition: vector.h:508
void qlast::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
540  {
541  string error;
542  json11::Json parsed = json11::Json::parse(s,error);
543  if(error.empty()) {
544  if(!parsed["q1"].is_null()) q1 = parsed["q1"].number_value();
545  if(!parsed["q2"].is_null()) q2 = parsed["q2"].number_value();
546  if(!parsed["q3"].is_null()) q3 = parsed["q3"].number_value();
547  if(!parsed["q4"].is_null()) q4 = parsed["q4"].number_value();
548  } else {
549  cerr<<"ERROR: <"<<error<<">"<<endl;
550  }
551  return;
552  }
Definition: json11.hpp:79
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double q2
Definition: vector.h:509
double q4
Definition: vector.h:511
double q3
Definition: vector.h:510
double q1
Definition: vector.h:508

Member Data Documentation

double qlast::q1 = 0.
double qlast::q2 = 0.
double qlast::q3 = 0.
double qlast::q4 = 0.

The documentation for this struct was generated from the following file: