Math namespace

Basic mathematical objects and functions, such as vectors, random numbers,...

Contents

Classes

struct BoundingBox
A pair of two Vector3 that define the boundaries of an object (the minimum point and the maximum point in the space).
struct Color
An ARGB color represented by a 32 bit integer value.
struct ColorHSV
Three float values that represent a color (the hue, saturation and value/brightness values).
struct ColorRGB
Three float values in the range [0, 1] that represent a color (the red, green and blue components).
struct ColorRGBA
Four float values in the range [0, 1] that represent a color (the red, green, blue and alpha components).
struct Dimensions
A pair of two float values that represents the dimensions of an image (width, height).
struct IntDimensions
A pair of two integer values that represents the dimensions of an image (width, height).
struct Matrix3
A 3x3 matrix.
struct Matrix4
A 4x4 matrix.
struct Point
Represents a point in the space, defined by two float coordinates (x, y).
struct Quaternion
A vector of 4 float values (x, y, z, w) representing a quaternion rotation; same as a Vector4.
struct RandomNumberGenerator
union Rectangle
Represents a rectangular space, defined by two points or by the four edges.
struct Vector2
A vector of 2 float values (x, y).
struct Vector3
A vector of 3 float values (x, y, z).
struct Vector4
A vector of 4 float values (x, y, z, w).

Functions

auto ToRadians(float degrees) -> float
Converts the given angle in degrees into the angle in radians.
auto ToDegrees(float radians) -> float
Converts the given angle in radians into the angle in degrees.
auto Addresses(BoundingBox) -> namespace
auto HSVtoRGB(const ColorHSV& hsv) -> ColorRGB
Converts the given HSV color into a RGB color.
auto RGBtoHSV(const ColorRGB& rgb) -> ColorHSV
Converts the given RGB color into a HSV color.
auto GetRNG() -> RandomNumberGenerator&
Returns the generic random number generator.
auto rand(int range) -> int
Generates a random integer between 0 and the given parameter, included.
auto randf() -> float
Generates a random float number between 0.0 and 1.0.
auto randf(float minValue, float maxValue) -> float
Generates a random float number between minValue and maxValue.
auto Addresses(RandomNumberGenerator) -> namespace
auto operator*(Matrix3 a, const Vector3& b) -> Vector3
auto operator*(Matrix3 a, const Matrix3& b) -> Matrix3
auto operator+(Point a, const Point& b) -> Point
auto operator+(Point a, float b) -> Point
auto operator-(Point a, const Point& b) -> Point
auto operator-(Point a, float b) -> Point
auto operator*(Point a, float b) -> Point
auto operator/(Point a, float b) -> Point
auto operator-(const Point& a) -> Point
auto operator+(float a, const Point& b) -> Point
auto operator-(float a, const Point& b) -> Point
auto operator*(float a, const Point& b) -> Point
auto operator+(Vector2 a, const Vector2& b) -> Vector2
auto operator+(Vector2 a, float b) -> Vector2
auto operator-(Vector2 a, const Vector2& b) -> Vector2
auto operator-(Vector2 a, float b) -> Vector2
auto operator*(Vector2 a, float b) -> Vector2
auto operator/(Vector2 a, float b) -> Vector2
auto operator-(const Vector2& a) -> Vector2
auto operator+(float a, const Vector2& b) -> Vector2
auto operator-(float a, const Vector2& b) -> Vector2
auto operator*(float a, const Vector2& b) -> Vector2
auto operator+(Vector3 a, const Vector3& b) -> Vector3
auto operator+(Vector3 a, float b) -> Vector3
auto operator-(Vector3 a, const Vector3& b) -> Vector3
auto operator-(Vector3 a, float b) -> Vector3
auto operator*(Vector3 a, float b) -> Vector3
auto operator/(Vector3 a, float b) -> Vector3
auto operator-(const Vector3& a) -> Vector3
auto operator+(float a, const Vector3& b) -> Vector3
auto operator-(float a, const Vector3& b) -> Vector3
auto operator*(float a, const Vector3& b) -> Vector3
auto operator-(const Vector4& a) -> Vector4
auto operator+(Vector4 a, const Vector4& b) -> Vector4
auto operator+(Vector4 a, float b) -> Vector4
auto operator-(Vector4 a, const Vector4& b) -> Vector4
auto operator-(Vector4 a, float b) -> Vector4
auto operator*(Vector4 a, float b) -> Vector4
auto operator/(Vector4 a, float b) -> Vector4
auto operator+(float a, const Vector4& b) -> Vector4
auto operator-(float a, const Vector4& b) -> Vector4
auto operator*(float a, const Vector4& b) -> Vector4

Variables

const float PI

Function documentation

float Math::ToRadians(float degrees)

Converts the given angle in degrees into the angle in radians.

Parameters
degrees The angle, in degrees.
Returns The angle in radians.

float Math::ToDegrees(float radians)

Converts the given angle in radians into the angle in degrees.

Parameters
radians The angle, in radians.
Returns The angle in degrees.

namespace Math::Addresses(BoundingBox)

ColorRGB Math::HSVtoRGB(const ColorHSV& hsv)

Converts the given HSV color into a RGB color.

ColorHSV Math::RGBtoHSV(const ColorRGB& rgb)

Converts the given RGB color into a HSV color.

RandomNumberGenerator& Math::GetRNG()

Returns the generic random number generator.

int Math::rand(int range)

Generates a random integer between 0 and the given parameter, included.

Parameters
range The maximum value that can be generated.

This uses the default RNG, which uses the time stamp as seed.

float Math::randf()

Generates a random float number between 0.0 and 1.0.

This uses the default RNG, which uses the time stamp as seed.

float Math::randf(float minValue, float maxValue)

Generates a random float number between minValue and maxValue.

Parameters
minValue The minimum possible value.
maxValue The maximum possible value.

This uses the default RNG, which uses the time stamp as seed.

Vector3 Math::operator*(Matrix3 a, const Vector3& b)

Matrix3 Math::operator*(Matrix3 a, const Matrix3& b)

Point Math::operator+(Point a, const Point& b)

Point Math::operator+(Point a, float b)

Point Math::operator-(Point a, const Point& b)

Point Math::operator-(Point a, float b)

Point Math::operator*(Point a, float b)

Point Math::operator/(Point a, float b)

Point Math::operator-(const Point& a)

Point Math::operator+(float a, const Point& b)

Point Math::operator-(float a, const Point& b)

Point Math::operator*(float a, const Point& b)

Vector2 Math::operator+(Vector2 a, const Vector2& b)

Vector2 Math::operator+(Vector2 a, float b)

Vector2 Math::operator-(Vector2 a, const Vector2& b)

Vector2 Math::operator-(Vector2 a, float b)

Vector2 Math::operator*(Vector2 a, float b)

Vector2 Math::operator/(Vector2 a, float b)

Vector2 Math::operator-(const Vector2& a)

Vector2 Math::operator+(float a, const Vector2& b)

Vector2 Math::operator-(float a, const Vector2& b)

Vector2 Math::operator*(float a, const Vector2& b)

Vector3 Math::operator+(Vector3 a, const Vector3& b)

Vector3 Math::operator+(Vector3 a, float b)

Vector3 Math::operator-(Vector3 a, const Vector3& b)

Vector3 Math::operator-(Vector3 a, float b)

Vector3 Math::operator*(Vector3 a, float b)

Vector3 Math::operator/(Vector3 a, float b)

Vector3 Math::operator-(const Vector3& a)

Vector3 Math::operator+(float a, const Vector3& b)

Vector3 Math::operator-(float a, const Vector3& b)

Vector3 Math::operator*(float a, const Vector3& b)

Vector4 Math::operator-(const Vector4& a)

Vector4 Math::operator+(Vector4 a, const Vector4& b)

Vector4 Math::operator+(Vector4 a, float b)

Vector4 Math::operator-(Vector4 a, const Vector4& b)

Vector4 Math::operator-(Vector4 a, float b)

Vector4 Math::operator*(Vector4 a, float b)

Vector4 Math::operator/(Vector4 a, float b)

Vector4 Math::operator+(float a, const Vector4& b)

Vector4 Math::operator-(float a, const Vector4& b)

Vector4 Math::operator*(float a, const Vector4& b)

Variable documentation

const float Math::PI