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

Detailed Description

This class holds a variety of static math functions that are useful to have defined with creating graphics programs.

Definition at line 28 of file gfxmath.h.

#include <gfxmath.h>

Static Public Member Functions

static float Clamp (float x, float a, float b)
 Returns a if x is less than a and b if x is greater than b. More...
 
static float ToRadians (float degrees)
 
static float ToDegrees (float radians)
 
static Vector3 ToRadians (Vector3 degrees)
 
static Vector3 ToDegrees (Vector3 radians)
 
static float Lerp (float a, float b, float alpha)
 
static int iLerp (int a, int b, float alpha)
 
static Point3 ScreenToNearPlane (const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt)
 Converts a 2D point on the filmplane represented in Normalized Device Coorindates, which means (-1,1) for the top left corner of the screen and (1,-1) for the bottom right corner, to a 3D point that lies on the camera's near plane. Useful for converting mouse coordinates into a 3D point. Remember that this uses NORMALIZED device coordinates for the screenPt, not pixels. GraphicsApp and most other graphics engines report mouse move events in pixels, so you need to convert these to normalized device coordinates first. If you are using GraphicsApp, you can do this with: Point2 normPos = graphicsApp->pixels_to_normalized_coordinates(mousePos);. More...
 
static Point3 ScreenToDepthPlane (const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt, float planeDepth)
 Similar to filmplane2D_to_nearplane3D() but here rather than using the nearplane, you specify the depth of the plane to use as a distance away from the camera's focal point. More...
 
static Point3 ScreenToWorld (const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt, float normalizedZ)
 Converts a 2D point on the filmplane represented in Normalized Device Coorindates, which means (-1,1) for the top left corner of the screen and (1,-1) for the bottom right corner, to a 3D point in the world. The depth buffer value under the pixel must be supplied. If you are using GraphicsApp, you can use the mouse pos in pixels to get the required arguments like this: Point2 normPos = graphicsApp->pixels_to_normalized_coordinates(mousePos); float normZ = graphicsApp->z_value_at_pixel(mousePos);. More...
 

Static Public Attributes

static const float PI
 
static const float TWO_PI
 
static const float HALF_PI
 

Member Function Documentation

◆ Clamp()

static float mingfx::GfxMath::Clamp ( float  x,
float  a,
float  b 
)
static

Returns a if x is less than a and b if x is greater than b.

◆ iLerp()

static int mingfx::GfxMath::iLerp ( int  a,
int  b,
float  alpha 
)
static

◆ Lerp()

static float mingfx::GfxMath::Lerp ( float  a,
float  b,
float  alpha 
)
static

◆ ScreenToDepthPlane()

static Point3 mingfx::GfxMath::ScreenToDepthPlane ( const Matrix4 viewMatrix,
const Matrix4 projMatrix,
const Point2 normalizedScreenPt,
float  planeDepth 
)
static

Similar to filmplane2D_to_nearplane3D() but here rather than using the nearplane, you specify the depth of the plane to use as a distance away from the camera's focal point.

◆ ScreenToNearPlane()

static Point3 mingfx::GfxMath::ScreenToNearPlane ( const Matrix4 viewMatrix,
const Matrix4 projMatrix,
const Point2 normalizedScreenPt 
)
static

Converts a 2D point on the filmplane represented in Normalized Device Coorindates, which means (-1,1) for the top left corner of the screen and (1,-1) for the bottom right corner, to a 3D point that lies on the camera's near plane. Useful for converting mouse coordinates into a 3D point. Remember that this uses NORMALIZED device coordinates for the screenPt, not pixels. GraphicsApp and most other graphics engines report mouse move events in pixels, so you need to convert these to normalized device coordinates first. If you are using GraphicsApp, you can do this with: Point2 normPos = graphicsApp->pixels_to_normalized_coordinates(mousePos);.

◆ ScreenToWorld()

static Point3 mingfx::GfxMath::ScreenToWorld ( const Matrix4 viewMatrix,
const Matrix4 projMatrix,
const Point2 normalizedScreenPt,
float  normalizedZ 
)
static

Converts a 2D point on the filmplane represented in Normalized Device Coorindates, which means (-1,1) for the top left corner of the screen and (1,-1) for the bottom right corner, to a 3D point in the world. The depth buffer value under the pixel must be supplied. If you are using GraphicsApp, you can use the mouse pos in pixels to get the required arguments like this: Point2 normPos = graphicsApp->pixels_to_normalized_coordinates(mousePos); float normZ = graphicsApp->z_value_at_pixel(mousePos);.

◆ ToDegrees() [1/2]

static float mingfx::GfxMath::ToDegrees ( float  radians)
static

◆ ToDegrees() [2/2]

static Vector3 mingfx::GfxMath::ToDegrees ( Vector3  radians)
static

◆ ToRadians() [1/2]

static float mingfx::GfxMath::ToRadians ( float  degrees)
static

◆ ToRadians() [2/2]

static Vector3 mingfx::GfxMath::ToRadians ( Vector3  degrees)
static

Member Data Documentation

◆ HALF_PI

const float mingfx::GfxMath::HALF_PI
static

Definition at line 74 of file gfxmath.h.

◆ PI

const float mingfx::GfxMath::PI
static

Definition at line 72 of file gfxmath.h.

◆ TWO_PI

const float mingfx::GfxMath::TWO_PI
static

Definition at line 73 of file gfxmath.h.


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