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

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

#include <vector.h>

Collaboration diagram for qcomplex:

Public Member Functions

 qcomplex ()
 
 qcomplex (double ti, double tj, double tk, double tr)
 
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 i = 0.
 
double j = 0.
 
double k = 0.
 
double r = 0.
 

Detailed Description

Quaternion, scalar last, using imaginary elements.

Can be thought of as i, j, k elements, followed by scalar.

Constructor & Destructor Documentation

qcomplex::qcomplex ( )
inline
457 {}
qcomplex::qcomplex ( double  ti,
double  tj,
double  tk,
double  tr 
)
inline
458  {
459  i = ti;
460  j = tj;
461  k = tk;
462  r = tr;
463  }
double j
Definition: vector.h:453
double i
Definition: vector.h:452
double r
Definition: vector.h:455
double k
Definition: vector.h:454

Member Function Documentation

json11::Json qcomplex::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
469  {
470  return json11::Json::object {
471  { "i" , i },
472  { "j" , j },
473  { "k" , k },
474  { "r" , r }
475  };
476  }
std::map< std::string, Json > object
Definition: json11.hpp:88
double j
Definition: vector.h:453
double i
Definition: vector.h:452
double r
Definition: vector.h:455
double k
Definition: vector.h:454
void qcomplex::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
484  {
485  string error;
486  json11::Json parsed = json11::Json::parse(s,error);
487  if(error.empty()) {
488  if(!parsed["i"].is_null()) i = parsed["i"].number_value();
489  if(!parsed["j"].is_null()) j = parsed["j"].number_value();
490  if(!parsed["k"].is_null()) k = parsed["k"].number_value();
491  if(!parsed["r"].is_null()) r = parsed["r"].number_value();
492  } else {
493  cerr<<"ERROR: <"<<error<<">"<<endl;
494  }
495  return;
496  }
Definition: json11.hpp:79
double j
Definition: vector.h:453
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double i
Definition: vector.h:452
double r
Definition: vector.h:455
double k
Definition: vector.h:454

Member Data Documentation

double qcomplex::i = 0.
double qcomplex::j = 0.
double qcomplex::k = 0.
double qcomplex::r = 0.

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