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

Quaternion, scalar last, using x, y, z. More...

#include <vector.h>

Collaboration diagram for quaternion:

Public Member Functions

 quaternion ()
 
 quaternion (cvector td, double tw)
 
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

cvector d
 Orientation. More...
 
double w = 0.
 Rotation. More...
 

Detailed Description

Quaternion, scalar last, using x, y, z.

Can be thought of as rvector with scalar last. One can be set equal to other. First 3 elements are the scaled orientation axis. Fourth element is the scaled amount of rotation. Can alternatively be thought of as a cvector, followed by a scalar.

Constructor & Destructor Documentation

quaternion::quaternion ( )
inline
409 {}
quaternion::quaternion ( cvector  td,
double  tw 
)
inline
410  {
411  d = td;
412  w = tw;
413  }
cvector d
Orientation.
Definition: vector.h:405
double w
Rotation.
Definition: vector.h:407

Member Function Documentation

json11::Json quaternion::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
419  {
420  return json11::Json::object {
421  { "d" , d },
422  { "w" , w }
423  };
424  }
std::map< std::string, Json > object
Definition: json11.hpp:88
cvector d
Orientation.
Definition: vector.h:405
double w
Rotation.
Definition: vector.h:407
void quaternion::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
431  {
432  string error;
433  json11::Json parsed = json11::Json::parse(s,error);
434  if(error.empty()) {
435  if(!parsed["d"].is_null()) d.from_json(parsed["d"].dump());
436  if(!parsed["w"].is_null()) w = parsed["w"].number_value();
437  } else {
438  cerr<<"ERROR: <"<<error<<">"<<endl;
439  }
440  return;
441  }
Definition: json11.hpp:79
cvector d
Orientation.
Definition: vector.h:405
void dump(std::string &out) const
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:150
double w
Rotation.
Definition: vector.h:407

Member Data Documentation

cvector quaternion::d

Orientation.

double quaternion::w = 0.

Rotation.


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