MinGfx Toolkit  1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
Public Member Functions | Static Public Member Functions | List of all members
mingfx::Point2 Class Reference

Detailed Description

A 2D Point with floating point coordinates, used for storing 2D texture coordinates, screen-space graphics, and mouse input.

Definition at line 28 of file point2.h.

#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...
 
Point2operator= (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 Point2Origin ()
 (0,0) - a shortcut for a special point that is frequently needed More...
 
static const Point2Zero ()
 (0,0) - a shortcut for a special point that is frequently needed More...
 
static const Point2One ()
 (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...
 

Constructor & Destructor Documentation

◆ Point2() [1/4]

mingfx::Point2::Point2 ( )

Default point at the origin.

◆ Point2() [2/4]

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.

◆ Point2() [3/4]

mingfx::Point2::Point2 ( float *  p)

Constructs a point given a pointer to x,y data.

◆ Point2() [4/4]

mingfx::Point2::Point2 ( const Point2 p)

Copy constructor for point.

◆ ~Point2()

virtual mingfx::Point2::~Point2 ( )
virtual

Point destructor.

Member Function Documentation

◆ Lerp() [1/2]

static Point2 mingfx::Point2::Lerp ( const Point2 a,
const Point2 b,
float  alpha 
)
static

Linear interpolation between two points. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two.

◆ Lerp() [2/2]

Point2 mingfx::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.

◆ One()

static const Point2& mingfx::Point2::One ( )
static

(1,1) - a shortcut for a special point that is frequently needed

◆ operator!=()

bool mingfx::Point2::operator!= ( const Point2 p) const

Check for "inequality", taking floating point imprecision into account.

◆ operator=()

Point2& mingfx::Point2::operator= ( const Point2 p)

Assignment operator.

◆ operator==()

bool mingfx::Point2::operator== ( const Point2 p) const

Check for "equality", taking floating point imprecision into account.

◆ operator[]() [1/2]

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:

a[0] = 5.0; // set the x-coordinate of the point
Point2()
Default point at the origin.

◆ operator[]() [2/2]

float mingfx::Point2::operator[] ( const int  i) const

Read only access to the ith coordinate of the point.

◆ Origin()

static const Point2& mingfx::Point2::Origin ( )
static

(0,0) - a shortcut for a special point that is frequently needed

◆ value_ptr()

const float* mingfx::Point2::value_ptr ( ) const

Returns a const pointer to the raw data array.

◆ w()

float mingfx::Point2::w ( ) const
inline

In homogeneous coordinates, the w coordinate for all points is 1.0.

Definition at line 76 of file point2.h.

◆ x()

float mingfx::Point2::x ( ) const
inline

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.

Definition at line 69 of file point2.h.

◆ y()

float mingfx::Point2::y ( ) const
inline

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.

Definition at line 73 of file point2.h.

◆ Zero()

static const Point2& mingfx::Point2::Zero ( )
static

(0,0) - a shortcut for a special point that is frequently needed


The documentation for this class was generated from the following file: