vcsl_coordinate_system.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_coordinate_system.cxx
3 #include <cassert>
4 #ifdef _MSC_VER
5 # include <vcl_msvc_warnings.h>
6 #endif
7 #include <vcsl/vcsl_axis.h>
8 #include <vcsl/vcsl_unit.h> // for method vcsl_axis::unit()
9 
10 //---------------------------------------------------------------------------
11 // Return the axis `i'
12 // REQUIRE: valid_axis(i)
13 //---------------------------------------------------------------------------
15 {
16  // require
17  assert(valid_axis(i));
18 
19  return axes_[i];
20 }
21 
22 //---------------------------------------------------------------------------
23 // Convert `v', expressed with cs units, to standard units
24 // REQUIRE: v.size()==dimensionality()
25 //---------------------------------------------------------------------------
28 {
29  vnl_vector<double> result(v.size());
30 
31  int j=0;
32  std::vector<vcsl_axis_sptr>::const_iterator i;
33  for (i=axes_.begin();i!=axes_.end();++i,++j)
34  result.put(j,v.get(j)/(*i)->unit()->units_per_standard_unit()); // a vcsl_unit
35 
36  return result;
37 }
38 
39 //---------------------------------------------------------------------------
40 // Convert `v', expressed with standard units, to cs units
41 // REQUIRE: v.size()==dimensionality()
42 //---------------------------------------------------------------------------
45 {
46  vnl_vector<double> result(v.size());
47 
48  int j=0;
49  std::vector<vcsl_axis_sptr>::const_iterator i;
50  for (i=axes_.begin();i!=axes_.end();++i,++j)
51  result.put(j,v.get(j)*(*i)->unit()->units_per_standard_unit());
52 
53  return result;
54 }
#define v
Abstract coordinate system.
Axis descriptor: a dimension, a unit, a label.
vnl_vector< double > from_standard_units_to_cs(const vnl_vector< double > &v) const
Convert ‘v’, expressed with standard units, to cs units.
void put(size_t i, double const &v)
Abstract unit associated to a dimension.
vnl_vector< double > from_cs_to_standard_units(const vnl_vector< double > &v) const
Convert ‘v’, expressed with cs units, to standard units.
vcsl_axis_sptr axis(int i) const
Return the axis ‘i’.
std::vector< vcsl_axis_sptr > axes_
List of axes.
bool valid_axis(unsigned int i) const
Is ‘i’ an index on an axis ?.