Author: Not specified Language: text Description: Not specified Timestamp: 2013-05-20 09:08:20 +0000
1. class CartesianCoordinates
2. {
3.   double x, y, z;
4.
5. public:
6.   CartesianCoordinates(const double x, const double y, const double z)
7.     : x(x), y(y), z(z)
8.   { }
9.
10.   CartesianCoordinates(const HomogeneousCoordinates& coords)
11.   {
12.     double homox = coords.GetX();
13.     double homoy = coords.GetY();
14.     double homoz = coords.GetZ();
15.
16.     // compute x, y, z from homox, homoy, homoz
17.   }
18.
19.   double GetX() const { return x; }
20.   double GetY() const { return y; }
21.   double GetZ() const { return z; }
22. };
23.
24. class HomogeneousCoordinates
25. {
26.   double x, y, z;
27.
28. public:
29.   HomogeneousCoordinates(const double x, const double y, const double z)
30.     : x(x), y(y), z(z)
31.   { }
32.
33.   HomogeneousCoordinates(const CartesianCoordinates& coords)
34.   {
35.     auto cartesianx = coords.GetX();
36.     auto cartesiany = coords.GetY();
37.     auto cartesionz = coords.GetZ();
38.
39.     // compute x, y, z from cartesianx, cartesiany, cartesianz
40.   }
41.
42.   double GetX() const { return x; }
43.   double GetY() const { return y; }
44.   double GetZ() const { return z; }
45. };
46.
47. void main()
48. {
49.   CartesianCoordinates coords1(1, 2, 3);
50.   HomogeneousCoordinates coords2(coords1);
51.
52.   HomogeneousCoordinates coords3(7, 8, 9);
53.   CartesianCoordinates coords4(coords3);
54. }