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

3 element cartesian vector More...

#include <vector.h>

Collaboration diagram for cvector:

Public Member Functions

 cvector ()
 
 cvector (double tx, double ty, double tz)
 
void normalize (double scale=1.)
 Normalize cartesian vector in place, i.e. divides it by its own norm. More...
 
double length ()
 
double norm ()
 
double norm2 ()
 
cvector normalized (double scale=1.)
 Normalize cartesian vector. More...
 
double & operator[] (const int index)
 Index into cvector. More...
 
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 x = 0.
 X value. More...
 
double y = 0.
 Y value. More...
 
double z = 0.
 Z value. More...
 

Detailed Description

3 element cartesian vector

3 double precision numbers representing a vector in a right handed cartesian space

Constructor & Destructor Documentation

cvector::cvector ( )
inline
118 {}
cvector::cvector ( double  tx,
double  ty,
double  tz 
)
inline
119  {
120  x = tx;
121  y = ty;
122  z = tz;
123  }
double y
Y value.
Definition: vector.h:114
double x
X value.
Definition: vector.h:112
double z
Z value.
Definition: vector.h:116

Member Function Documentation

json11::Json cvector::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
136  {
137  return json11::Json::object {
138  { "x" , x },
139  { "y" , y },
140  { "z" , z }
141  };
142  }
double y
Y value.
Definition: vector.h:114
std::map< std::string, Json > object
Definition: json11.hpp:88
double x
X value.
Definition: vector.h:112
double z
Z value.
Definition: vector.h:116
void cvector::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
150  {
151  string error;
152  json11::Json parsed = json11::Json::parse(s,error);
153  if(error.empty()) {
154  if(!parsed["x"].is_null()) x = parsed["x"].number_value();
155  if(!parsed["y"].is_null()) y = parsed["y"].number_value();
156  if(!parsed["z"].is_null()) z = parsed["z"].number_value();
157  } else {
158  cerr<<"ERROR: <"<<error<<">"<<endl;
159  }
160  return;
161  }
double y
Y value.
Definition: vector.h:114
Definition: json11.hpp:79
double x
X value.
Definition: vector.h:112
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double z
Z value.
Definition: vector.h:116

Member Data Documentation

double cvector::x = 0.

X value.

double cvector::y = 0.

Y value.

double cvector::z = 0.

Z value.


The documentation for this class was generated from the following files: