ASCII-GFX  2.0
Functions | Variables
math2d.cpp File Reference
#include <math.h>
#include "math2d.h"

Functions

Mat3 top ()
 get current transformation represented by a 3x3 homogeneous matrix the current transformation is the top of the matrix stack More...
 
void push ()
 push current transformation this duplicates the current matrix on top of the matrix stack More...
 
void replace (const Mat3 &m)
 replace current transformation with a given transformation matrix More...
 
Mat3 pop ()
 pop current transformation this removes the current matrix on top of the matrix stack More...
 
void translate (float x, float y)
 apply translation to current transformation More...
 
void translate (Vec2 v)
 apply translation vector to current transformation More...
 
void rotate (float a, float aspect)
 apply clockwise rotation to current transformation More...
 
void scale (float f)
 apply uniform scaling factor to current transformation More...
 
void scale (float s, float t)
 apply non-uniform scaling to current transformation More...
 
Vec2 translation ()
 get current translation vector More...
 
float rotation (float aspect)
 get current rotation angle More...
 
float scaling (float aspect)
 get current scaling factor More...
 

Variables

static const int mat3_stack_max = 100
 
static int mat3_stack_size = 0
 
static Mat3 mat3_stack [mat3_stack_max]
 

Function Documentation

◆ pop()

Mat3 pop ( )

pop current transformation this removes the current matrix on top of the matrix stack

◆ push()

void push ( )

push current transformation this duplicates the current matrix on top of the matrix stack

◆ replace()

void replace ( const Mat3 m)

replace current transformation with a given transformation matrix

◆ rotate()

void rotate ( float  a,
float  aspect = 2 
)

apply clockwise rotation to current transformation

  • the current transformation matrix is multiplied with a rotation matrix
  • defined by a rotation angle a given in degrees
  • the rotation aspect is 2 by default for characters two times higher than wide

◆ rotation()

float rotation ( float  aspect = 2)

get current rotation angle

  • does not work for non-uniformly scaled transformations
  • the rotation aspect is 2 by default for characters two times higher than wide

◆ scale() [1/2]

void scale ( float  f)

apply uniform scaling factor to current transformation

  • the current transformation matrix is multiplied with a scaling matrix
  • defined by the scaling factor f in x- and y-direction

◆ scale() [2/2]

void scale ( float  s,
float  t 
)

apply non-uniform scaling to current transformation

  • the current transformation matrix is multiplied with a scaling matrix
  • defined by the scaling factors in x- and y-direction s and t

◆ scaling()

float scaling ( float  aspect = 2)

get current scaling factor

  • does not work for non-uniformly scaled transformations
  • the rotation aspect is 2 by default for characters two times higher than wide

◆ top()

Mat3 top ( )

get current transformation represented by a 3x3 homogeneous matrix the current transformation is the top of the matrix stack

◆ translate() [1/2]

void translate ( float  x,
float  y 
)

apply translation to current transformation

  • the current transformation matrix is multiplied with a translation matrix
  • defined by the translation vector (x, y)

◆ translate() [2/2]

void translate ( Vec2  v)

apply translation vector to current transformation

  • the current transformation matrix is multiplied with a translation matrix
  • defined by the translation vector v

◆ translation()

Vec2 translation ( )

get current translation vector

Variable Documentation

◆ mat3_stack

Mat3 mat3_stack[mat3_stack_max]
static

◆ mat3_stack_max

const int mat3_stack_max = 100
static

◆ mat3_stack_size

int mat3_stack_size = 0
static