MinGfx Toolkit
1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
|
A 2D Point with floating point coordinates, used for storing 2D texture coordinates, screen-space graphics, and mouse input.
#include <point2.h>
Public Member Functions | |
Point2 () | |
Default point at the origin. More... | |
Point2 (float x, float y) | |
Constructs a point given (x,y,1), where the 1 comes from the use of homogeneous coordinates in computer graphics. More... | |
Point2 (float *p) | |
Constructs a point given a pointer to x,y data. More... | |
Point2 (const Point2 &p) | |
Copy constructor for point. More... | |
virtual | ~Point2 () |
Point destructor. More... | |
bool | operator== (const Point2 &p) const |
Check for "equality", taking floating point imprecision into account. More... | |
bool | operator!= (const Point2 &p) const |
Check for "inequality", taking floating point imprecision into account. More... | |
Point2 & | operator= (const Point2 &p) |
Assignment operator. More... | |
float | operator[] (const int i) const |
Read only access to the ith coordinate of the point. More... | |
float & | operator[] (const int i) |
Returns a reference to the ith coordinate of the point. Use this accessor if you wish to set the coordinate rather than just request its value. Example: More... | |
float | x () const |
Read only access to the x coordinate. Can also use my_point[0]. Use the my_point[0] = 1.0; form if you need to set the value. More... | |
float | y () const |
Read only access to the y coordinate. Can also use my_point[1]. Use the my_point[1] = 1.0; form if you need to set the value. More... | |
float | w () const |
In homogeneous coordinates, the w coordinate for all points is 1.0. More... | |
const float * | value_ptr () const |
Returns a const pointer to the raw data array. More... | |
Point2 | Lerp (const Point2 &b, float alpha) const |
Linear interpolation between this point and another. Alpha=0.0 returns this point, and alpha=1.0 returns the other point, other values blend between the two. More... | |
Static Public Member Functions | |
static const Point2 & | Origin () |
(0,0) - a shortcut for a special point that is frequently needed More... | |
static const Point2 & | Zero () |
(0,0) - a shortcut for a special point that is frequently needed More... | |
static const Point2 & | One () |
(1,1) - a shortcut for a special point that is frequently needed More... | |
static Point2 | Lerp (const Point2 &a, const Point2 &b, float alpha) |
Linear interpolation between two points. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two. More... | |
mingfx::Point2::Point2 | ( | ) |
Default point at the origin.
mingfx::Point2::Point2 | ( | float | x, |
float | y | ||
) |
Constructs a point given (x,y,1), where the 1 comes from the use of homogeneous coordinates in computer graphics.
mingfx::Point2::Point2 | ( | float * | p | ) |
Constructs a point given a pointer to x,y data.
mingfx::Point2::Point2 | ( | const Point2 & | p | ) |
Copy constructor for point.
|
virtual |
Point destructor.
Linear interpolation between two points. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two.
Linear interpolation between this point and another. Alpha=0.0 returns this point, and alpha=1.0 returns the other point, other values blend between the two.
|
static |
(1,1) - a shortcut for a special point that is frequently needed
bool mingfx::Point2::operator!= | ( | const Point2 & | p | ) | const |
Check for "inequality", taking floating point imprecision into account.
bool mingfx::Point2::operator== | ( | const Point2 & | p | ) | const |
Check for "equality", taking floating point imprecision into account.
float& mingfx::Point2::operator[] | ( | const int | i | ) |
Returns a reference to the ith coordinate of the point. Use this accessor if you wish to set the coordinate rather than just request its value. Example:
float mingfx::Point2::operator[] | ( | const int | i | ) | const |
Read only access to the ith coordinate of the point.
|
static |
(0,0) - a shortcut for a special point that is frequently needed
const float* mingfx::Point2::value_ptr | ( | ) | const |
Returns a const pointer to the raw data array.
|
inline |
|
inline |
|
inline |
|
static |
(0,0) - a shortcut for a special point that is frequently needed