Node: Point Operators, Next: , Previous: Point Destructor, Up: Point Reference



Operators

void operator= (const Point& p) Assignment operator
Makes *this a copy of p.

Transform operator*= (const Transform& t) Operator
Multiplies transform by t. By multiplying a Point successively by one or more Transforms, the effect of the transformations is "saved up" in transform. Only when an operation that needs updated values for the world_coordinates is called on a Point, or the Point is passed as an argument to such an operation, is the transformation stored in transform applied to world_coordinates by apply_transform(), which subsequently, resets transform to the identity Transform. See Point Reference; Applying Transformations.

Point operator+ (Point p) const operator
Returns a Point with world_coordinates that are the sums of the corresponding world_coordinates of *this and p, after they've been updated. *this remains unchanged; as in many other functions with Point arguments, p is passed by value, because apply_transform() must be called on it, in order to update its world_coordinates. If p were a const Point&, it would have to copied within the function anyway, because apply_transform() is a non-const operation.
          Point p0(-2, -6, -28);
          Point p1(3, 14, 92);
          Point p2(p0 + p1);
          p2.show("p2:");
          -| p2: (1, 8, 64)
          

void operator+= (Point p) Operator
Adds the updated world_coordinates of p to those of *this. Equivalent in effect to shift(p) In fact, this function merely calls p.apply_transform() and Point::shift(real, real, real) with p's x, y, and z coordinates (from world_coordinates) as its arguments. See Point Reference; Affine Transformations.

Point operator- (Point p) const operator
Returns a Point with world_coordinates representing the difference between the updated values of this->world_coordinates and p.world_coordinates.

void operator-= (Point p) Operator
Subtracts the updated values of p.world_coordinates from those of this->world_coordinates.

real operator*= (const real r) Operator
Multiplies the updated x, y, and z coordinates (world_coordinates) of the Point by r and returns r. This makes it possible to chain invocations of this function.

If P is a Point then P *= r is equivalent in its effect to P.scale(r, r, r), except that P.world_coordinates is modified directly and immediately, without changing P.transform. This is possible, because this function calls apply_transform() to update the world_coordinates before multiplying them r, so transform is the identity Transform.

          Point P(1, 2, 3);
          P *= 7;
          P.show("P:");
          -| P: (7, 14, 21);
          Point Q(1.5, 2.7, 13.82);
          Q *= P *= -1.28;
          P.show("P:");
          -| P: (-8.96, -17.92, -26.88)
          Q.show("Q:");
          -| Q: (-1.92, -3.456, -17.6896)
          

Point operator* (const real r) const operator
Returns a Point with x, y, and z coordinates (world_coordinates) equal to the updated x, y, and z coordinates of *this multiplied by r.

Point operator* (const real r, const Point& p) Non-member operator
Equivalent to Point::operator*(const real r) (see above), but with r placed first.
          Point p0(10, 11, 12);
          real r = 2.5;
          Point p1 = r * p0;
          p1.show();
          -|Point:
          -|(25, 27.5, 30)
          

Point operator- (void) const operator
Unary minus (prefix). Returns a Point with x, y, and z coordinates (world_coordinates) equal to the the x, y, and z-coordinates (world_coordinates) of *this multiplied by -1.

void operator/= (const real r) Operator
Divides the updated x, y, and z coordinates (world_coordinates) of the Point by r.

Point operator/ (const real r) const operator
Returns a Point with x, y, and z coordinates (world_coordinates) equal to the updated x, y, and z coordinates of *this divided by r.

bool operator== (Point p) Operator
bool operator== (const Point& p) const operator
Equality comparison for Points. These functions return true if the updated values of the world_coordinates of the two Points differ by less than the value returned by Point::epsilon(), otherwise false. See Point Reference; Returning Information.

bool operator!= (const Point& p) const operator
Inequality comparison for Points. Returns false if *this == p, otherwise true.