MinGfx Toolkit  1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
gfxmath.h
Go to the documentation of this file.
1 /*
2  This file is part of the MinGfx Project.
3 
4  Copyright (c) 2017,2018 Regents of the University of Minnesota.
5  All Rights Reserved.
6 
7  Original Author(s) of this File:
8  Dan Keefe, 2018, University of Minnesota
9 
10  Author(s) of Significant Updates/Modifications to the File:
11  ...
12  */
13 
14 #ifndef SRC_GFXMATH_H_
15 #define SRC_GFXMATH_H_
16 
17 #include "point2.h"
18 #include "point3.h"
19 #include "vector3.h"
20 #include "matrix4.h"
21 
22 namespace mingfx {
23 
24 
28 class GfxMath {
29 public:
30 
32  static float Clamp(float x, float a, float b);
33 
34  static float ToRadians(float degrees);
35 
36  static float ToDegrees(float radians);
37 
38  static Vector3 ToRadians(Vector3 degrees);
39 
40  static Vector3 ToDegrees(Vector3 radians);
41 
42  static float Lerp(float a, float b, float alpha);
43 
44  static int iLerp(int a, int b, float alpha);
45 
55  static Point3 ScreenToNearPlane(const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt);
56 
60  static Point3 ScreenToDepthPlane(const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt, float planeDepth);
61 
69  static Point3 ScreenToWorld(const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt, float normalizedZ);
70 
71 
72  static const float PI;
73  static const float TWO_PI;
74  static const float HALF_PI;
75 };
76 
77 
78 
79 } // end namespace
80 
81 #endif
This class holds a variety of static math functions that are useful to have defined with creating gra...
Definition: gfxmath.h:28
static const float TWO_PI
Definition: gfxmath.h:73
static float ToRadians(float degrees)
static Point3 ScreenToNearPlane(const Matrix4 &viewMatrix, const Matrix4 &projMatrix, const Point2 &normalizedScreenPt)
Converts a 2D point on the filmplane represented in Normalized Device Coorindates,...
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,...
static Vector3 ToRadians(Vector3 degrees)
static float ToDegrees(float radians)
static Vector3 ToDegrees(Vector3 radians)
static const float PI
Definition: gfxmath.h:72
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 dep...
static const float HALF_PI
Definition: gfxmath.h:74
static float Lerp(float a, float b, float alpha)
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.
static int iLerp(int a, int b, float alpha)
A 4x4 transformation matrix stored internally as an array of floats in column-major order so as to be...
Definition: matrix4.h:50
A 2D Point with floating point coordinates, used for storing 2D texture coordinates,...
Definition: point2.h:28
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
Definition: point3.h:52
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Definition: vector3.h:62
Namespace for the MinGfx Toolkit.
Definition: aabb.h:21