Public Member Functions | Public Attributes | List of all members
BPoint Class Reference

A point on a two-dimensional Cartesian coordinate system. More...

Public Member Functions

 BPoint ()
 Initializes a BPoint object at the origin, (0, 0). More...
 
 BPoint (float x, float y)
 Initializes a BPoint object at the specified x and y coordinates. More...
 
 BPoint (const BPoint &p)
 Initializes a BPoint object from another BPoint. More...
 
void ConstrainTo (BRect rect)
 Moves the BPoint so that it is contained within rect. More...
 
void PrintToStream () const
 Print the x and y coordinates to standard output. More...
 
void Set (float x, float y)
 Sets the x and y coordinates of a BPoint object. More...
 
Operators
BPointoperator= (const BPoint &other)
 Initializes a BPoint object from another BPoint by overloading the = operator. More...
 
BPoint operator- () const
 Returns a BPoint object with the x and y coordinates negated. More...
 
BPoint operator+ (const BPoint &other) const
 Returns a BPoint where the x-coordinate is the sum of the x values and the y-coordinate is the sum of the y values. More...
 
BPoint operator- (const BPoint &other) const
 Returns a BPoint where the x-coordinate is the difference of the x values and the y-coordinate is the difference of the y values. More...
 
BPointoperator+= (const BPoint &other)
 Uses the BPoint as an accumulator storing the sum of the x values and the sum of the y values. More...
 
BPointoperator-= (const BPoint &other)
 Uses the BPoint as an accumulator storing the difference of the x values and the difference of the y values. More...
 
bool operator!= (const BPoint &other) const
 Returns whether or not the x and y coordinates of the BPoint objects differ. More...
 
bool operator== (const BPoint &other) const
 Returns whether or not the x and y coordinates of the BPoint objects are equal. More...
 

Public Attributes

float x
 The horizontal coordinate. More...
 
float y
 The vertical coordinate. More...
 

Detailed Description

A point on a two-dimensional Cartesian coordinate system.

Since
BeOS R3

Constructor & Destructor Documentation

◆ BPoint() [1/3]

BPoint::BPoint ( )
inline

Initializes a BPoint object at the origin, (0, 0).

See also
BPoint::Set()
Since
BeOS R3

◆ BPoint() [2/3]

BPoint::BPoint ( float  x,
float  y 
)
inline

Initializes a BPoint object at the specified x and y coordinates.

Parameters
xThe x coordinate.
yThe y coordinate.
Since
BeOS R3

◆ BPoint() [3/3]

BPoint::BPoint ( const BPoint other)
inline

Initializes a BPoint object from another BPoint.

Parameters
otherThe BPoint object to copy from.
Since
BeOS R3

Member Function Documentation

◆ ConstrainTo()

void BPoint::ConstrainTo ( BRect  rect)

Moves the BPoint so that it is contained within rect.

If the BPoint is already contained within rect this method has no effect.

Parameters
rectThe BRect to constrain the BPoint within.
Since
BeOS R3

◆ operator!=()

bool BPoint::operator!= ( const BPoint other) const

Returns whether or not the x and y coordinates of the BPoint objects differ.

Returns
true if the x or y coordinates differ, false otherwise.
Since
BeOS R3

◆ operator+()

BPoint BPoint::operator+ ( const BPoint other) const

Returns a BPoint where the x-coordinate is the sum of the x values and the y-coordinate is the sum of the y values.

Parameters
otherThe BPoint object to use in the addition.
Returns
A new BPoint object.
Since
BeOS R3

◆ operator+=()

BPoint & BPoint::operator+= ( const BPoint other)

Uses the BPoint as an accumulator storing the sum of the x values and the sum of the y values.

Parameters
otherThe BPoint object to use in the addition.
Returns
The address of the BPoint object.
Since
BeOS R3

◆ operator-() [1/2]

BPoint BPoint::operator- ( ) const

Returns a BPoint object with the x and y coordinates negated.

Returns
A new BPoint object.
Since
BeOS R3

◆ operator-() [2/2]

BPoint BPoint::operator- ( const BPoint other) const

Returns a BPoint where the x-coordinate is the difference of the x values and the y-coordinate is the difference of the y values.

Parameters
otherThe BPoint object to use in the subtraction.
Returns
A new BPoint object.
Since
BeOS R3

◆ operator-=()

BPoint & BPoint::operator-= ( const BPoint other)

Uses the BPoint as an accumulator storing the difference of the x values and the difference of the y values.

Parameters
otherThe BPoint object to use in the subtraction.
Returns
The address of the BPoint object.
Since
BeOS R3

◆ operator=()

BPoint & BPoint::operator= ( const BPoint other)
inline

Initializes a BPoint object from another BPoint by overloading the = operator.

Parameters
otherThe BPoint object to copy from.
Since
BeOS R3

References x, and y.

◆ operator==()

bool BPoint::operator== ( const BPoint other) const

Returns whether or not the x and y coordinates of the BPoint objects are equal.

Returns
true if the x and y coordinates are equal, false otherwise.
Since
BeOS R3

◆ PrintToStream()

void BPoint::PrintToStream ( ) const

Print the x and y coordinates to standard output.

Prints in the following format:

BPoint(x:%.0f, y:%.0f)
Since
BeOS R3

◆ Set()

void BPoint::Set ( float  x,
float  y 
)
inline

Sets the x and y coordinates of a BPoint object.

Parameters
xThe x coordinate to set.
yThe y coordinate to set.
Since
BeOS R3

References x, and y.

Member Data Documentation

◆ x

BPoint::x

The horizontal coordinate.

Since
BeOS R3

Referenced by operator=(), and Set().

◆ y

BPoint::y

The vertical coordinate.

Since
BeOS R3

Referenced by operator=(), and Set().