Go to the documentation of this file.
38 inline Vec3 vec3(
float x = 0,
float y = 0,
float z = 1)
52 inline Mat3 mat3(
float r1x = 1,
float r1y = 0,
float r1z = 0,
53 float r2x = 0,
float r2y = 1,
float r2z = 0,
54 float r3x = 0,
float r3y = 0,
float r3z = 1)
56 Mat3 M = {r1x, r1y, r1z, r2x, r2y, r2z, r3x, r3y, r3z};
81 return(
vec2(a.
x*s, a.
y*s));
87 return(a.
x*b.
x + a.
y*b.
y);
93 return(a.
x*b.
x + a.
y*b.
y + a.
z*b.
z);
126 return(
vec2(v3.
x*h, v3.
y*h));
132 return((
int)(v.
x+0.5f));
138 return((
int)(v.
y+0.5f));
144 return((
int)(v.
x+0.5f));
150 return((
int)(v.
y+0.5f));
156 return((
int)(v.
z+0.5f));
188 void rotate(
float a,
float aspect = 2);
198 void scale(
float s,
float t);
211 float scaling(
float aspect = 2);
int vec2_y(Vec2 v)
convert y-component of 2D vector to rounded int
Definition: math2d.h:136
void rotate(float a, float aspect=2)
apply clockwise rotation to current transformation
Definition: math2d.cpp:74
Vec2 add2(Vec2 a, Vec2 b)
2D vector addition
Definition: math2d.h:61
float rotation(float aspect=2)
get current rotation angle
Definition: math2d.cpp:119
void scale(float f)
apply uniform scaling factor to current transformation
Definition: math2d.cpp:88
Vec3 vec3(float x=0, float y=0, float z=1)
3D vector construction from components x, y and z
Definition: math2d.h:38
float r3z
Definition: math2d.h:26
Vec2 sub2(Vec2 a, Vec2 b)
2D vector subtraction
Definition: math2d.h:67
void push()
push current transformation this duplicates the current matrix on top of the matrix stack
Definition: math2d.cpp:22
float z
Definition: math2d.h:18
Mat3 pop()
pop current transformation this removes the current matrix on top of the matrix stack
Definition: math2d.cpp:49
3D vector type
Definition: math2d.h:14
float dot2(Vec2 a, Vec2 b)
2D dot product
Definition: math2d.h:85
2D vector type
Definition: math2d.h:7
float r3y
Definition: math2d.h:26
Vec2 vec2(float x=0, float y=0)
2D vector construction from components x and y
Definition: math2d.h:30
Vec2 translation()
get current translation vector
Definition: math2d.cpp:104
float r1z
Definition: math2d.h:24
float scaling(float aspect=2)
get current scaling factor
Definition: math2d.cpp:135
float x
Definition: math2d.h:16
Vec3 col3(const Mat3 &m)
Definition: math2d.h:104
float r2x
Definition: math2d.h:25
Mat3 mul3(const Mat3 &m1, const Mat3 &m2)
3D matrix multiplication
Definition: math2d.h:107
void translate(Vec2 v)
apply translation vector to current transformation
Definition: math2d.cpp:68
3D matrix type
Definition: math2d.h:22
Vec3 row1(const Mat3 &m)
get 3D matrix row
Definition: math2d.h:97
int vec3_y(Vec3 v)
convert y-component of 3D vector to rounded int
Definition: math2d.h:148
float dot3(Vec3 a, Vec3 b)
3D dot product
Definition: math2d.h:91
int vec2_x(Vec2 v)
convert x-component of 2D vector to rounded int
Definition: math2d.h:130
float r2z
Definition: math2d.h:25
int vec3_x(Vec3 v)
convert x-component of 3D vector to rounded int
Definition: math2d.h:142
int vec3_z(Vec3 v)
convert z-component of 3D vector to rounded int
Definition: math2d.h:154
Vec2 mul3v(const Mat3 &m, Vec3 v)
3D matrix multiplication with right-hand side vector
Definition: math2d.h:115
Mat3 top()
get current transformation represented by a 3x3 homogeneous matrix the current transformation is the ...
Definition: math2d.cpp:13
Vec2 mul2(Vec2 a, Vec2 b)
2D vector multiplication
Definition: math2d.h:73
float y
Definition: math2d.h:10
float r3x
Definition: math2d.h:26
Vec2 mul2s(Vec2 a, float s)
2D vector multiplication with scalar value
Definition: math2d.h:79
Vec3 col1(const Mat3 &m)
get 3D matrix column
Definition: math2d.h:102
float r1x
Definition: math2d.h:24
Mat3 mat3(float r1x=1, float r1y=0, float r1z=0, float r2x=0, float r2y=1, float r2z=0, float r3x=0, float r3y=0, float r3z=1)
3D matrix construction
Definition: math2d.h:52
void replace(const Mat3 &m)
replace current transformation with a given transformation matrix
Definition: math2d.cpp:35
float r1y
Definition: math2d.h:24
float r2y
Definition: math2d.h:25
Vec3 row2(const Mat3 &m)
Definition: math2d.h:98
float y
Definition: math2d.h:17
Vec3 col2(const Mat3 &m)
Definition: math2d.h:103
float x
Definition: math2d.h:9
Vec3 row3(const Mat3 &m)
Definition: math2d.h:99