Overview
The RosePoint2D class is a variation of the RosePoint class for use with 2D planar data or UV data. It wraps a double[2] array with inline member functions for simple access and update. The RosePoint class discusses how to use these class wrappers instead of the raw arrays.
It is defined in the rose_xform.h header file.
Array Member
public: double m[2];
The class has a public array member with the coordinates. You can access the data directly whenever you want. The member functions are strictly for clearer code and better compiler checking.
RosePoint2D pt1 (300, 75); // completely equivalent printf (My data is %g, %g\n, pt1.m[0], pt1.m[1]); printf (My data is %g, %g\n, pt1.x(), pt1.y()); printf (My data is %g, %g\n, pt1.u(), pt1.v());
Constructor
RosePoint2D(); RosePoint2D(double x, double y); RosePoint2D(const double src[2]); RosePoint2D(ListOfDouble * lst);
The RosePoint2D() default constructor initializes the coordinates to zero, while the other initialize the coordinates from an array, separate parameters, or a list object.
double foo[2] = { 1, 2 }; // default ctor initializes as zeros RosePoint2D i_am_all_zero; // initialized with three arguments RosePoint2D pt1 (300, 75); // initialized by copying contents of foo RosePoint2D pt2 (foo); RosePoint2D pt3 = foo; // same // initialized by copying another RosePoint2D RosePoint2D pt4 = pt3;
u()
double u() const; void u (double val);
The u() function gets or sets the first element of the array, which represents the u parameter of a point in UV parameter space. The x() function operates on the same array element, just with a different name.
uv()
void uv (double x, double y);
The uv() function sets both elements of the array with a single call instead of two separate calls. This function is appropriate if the data represents a point in UV parameter space. The xy() function operates does the same thing, but with a name that is more appropriate for planar cartesian data.
RosePoint2D pt1; // completely equivalent pt1.uv (0.1, 0.5); pt1.u (0.1); pt1.v (0.5);
v()
double v() const; void v (double val);
The v() function gets or sets the second element of the array, which represents the v parameter of a point in UV parameter space. The y() function operates on the same array element, just with a different name.
x()
double x() const; void x (double val);
The x() function gets or sets the first element of the array, which represents the x coordinate of a cartesian point. The u() function operates on the same array element, and can make your code clearer when a 2D point is used for a point in UV parameter space.
xy()
void xy (double x, double y);
The xy() function sets both elements of the array with a single call instead of two separate calls.
RosePoint2D pt1; // completely equivalent pt1.xy (300, 75); pt1.x (300); pt1.y (75);
y()
double y() const; void y (double val);
The y() function gets or sets the second element of the array, which represents the y coordinate of a cartesian point. The v() function operates on the same array element, and can make your code clearer when a 2D point is used for a point in UV parameter space.