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

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

#include <vector.h>

Collaboration diagram for qfirst:

Public Member Functions

 qfirst ()
 
 qfirst (double tq0, double tq1, double tq2, double tq3)
 
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 q0
 
double q1
 
double q2
 
double q3
 

Detailed Description

Quaternion, scalar first using vector elements.

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

Constructor & Destructor Documentation

qfirst::qfirst ( )
inline
569 {}
qfirst::qfirst ( double  tq0,
double  tq1,
double  tq2,
double  tq3 
)
inline
570  {
571  q0 = tq0;
572  q1 = tq1;
573  q2 = tq2;
574  q3 = tq3;
575  }
double q1
Definition: vector.h:565
double q0
Definition: vector.h:564
double q3
Definition: vector.h:567
double q2
Definition: vector.h:566

Member Function Documentation

json11::Json qfirst::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
581  {
582  return json11::Json::object {
583  { "q0" , q0 },
584  { "q1" , q1 },
585  { "q2" , q2 },
586  { "q3" , q3 }
587  };
588  }
std::map< std::string, Json > object
Definition: json11.hpp:88
double q1
Definition: vector.h:565
double q0
Definition: vector.h:564
double q3
Definition: vector.h:567
double q2
Definition: vector.h:566
void qfirst::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
596  {
597  string error;
598  json11::Json parsed = json11::Json::parse(s,error);
599  if(error.empty()) {
600  if(!parsed["q0"].is_null()) q0 = parsed["q0"].number_value();
601  if(!parsed["q1"].is_null()) q1 = parsed["q1"].number_value();
602  if(!parsed["q2"].is_null()) q2 = parsed["q2"].number_value();
603  if(!parsed["q3"].is_null()) q3 = parsed["q3"].number_value();
604  } else {
605  cerr<<"ERROR: <"<<error<<">"<<endl;
606  }
607  return;
608  }
Definition: json11.hpp:79
double q1
Definition: vector.h:565
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double q0
Definition: vector.h:564
double q3
Definition: vector.h:567
double q2
Definition: vector.h:566

Member Data Documentation

double qfirst::q0
double qfirst::q1
double qfirst::q2
double qfirst::q3

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