vcsl_cylindrical_to_cartesian_3d.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_cylindrical_to_cartesian_3d.cxx
2 #include <cmath>
4 #include <cassert>
5 #ifdef _MSC_VER
6 # include <vcl_msvc_warnings.h>
7 #endif
8 
9 //---------------------------------------------------------------------------
10 // Is `this' invertible at time `time'?
11 // REQUIRE: valid_time(time)
12 //---------------------------------------------------------------------------
14 {
15  // require
16  assert(valid_time(time));
17 
18  return true;
19 }
20 
21 //---------------------------------------------------------------------------
22 // Image of `v' by `this'
23 // REQUIRE: is_valid()
24 // REQUIRE: v.size()==3
25 //---------------------------------------------------------------------------
28  double /*time*/) const
29 {
30  // require
31  assert(is_valid());
32  assert(v.size()==3);
33 
34  vnl_vector<double> result(3);
35 
36  double rho=v.get(0);
37  double theta=v.get(1);
38  double z=v.get(2);
39 
40  double x=rho*std::cos(theta);
41  double y=rho*std::sin(theta);
42 
43  result.put(0,x);
44  result.put(1,y);
45  result.put(2,z);
46 
47  return result;
48 }
49 
50 //---------------------------------------------------------------------------
51 // Image of `v' by the inverse of `this'
52 // REQUIRE: is_valid()
53 // REQUIRE: is_invertible(time)
54 // REQUIRE: v.size()==3
55 //---------------------------------------------------------------------------
58  double time) const
59 {
60  // require
61  assert(is_valid());
62  assert(is_invertible(time));
63  assert(v.size()==3);
64 
65  vnl_vector<double> result(3);
66 
67  double x=v.get(0);
68  double y=v.get(1);
69  double z=v.get(2);
70 
71  double rho=std::sqrt(x*x+y*y);
72  double theta=std::atan2(y,x);
73 
74  result.put(0,rho);
75  result.put(1,theta);
76  result.put(2,z);
77 
78  return result;
79 }
80 
81 // Return the reference to the unique vcsl_length object
84 {
87  return instance_;
88 }
static vcsl_cylindrical_to_cartesian_3d_sptr instance()
Return the reference to the unique vcsl_length object.
vnl_vector< double > execute(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by ‘this’.
Convert 3D cartesian coordinates to cylindrical coordinates.
#define v
bool is_invertible(double time) const override
Is ‘this’ invertible at time ‘time’?.
vnl_vector< double > inverse(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by the inverse of ‘this’.
bool valid_time(double time) const
Is ‘time’ between the two time bounds ?.
bool is_valid() const override
Is ‘this’ correctly set ?.