math2d
[math]

2D Mathematics functions More...

Classes

struct  __vec2f
 2D point More...
struct  GF_Rect
 rectangle 2D More...
struct  GF_IRect
 pixel-aligned rectangle More...
struct  GF_Matrix2D
 2D matrix More...

Defines

#define gf_mx2d_init(_obj)
 matrix initialization
#define gf_mx2d_copy(_obj, from)
 matrix copy
#define gf_mx2d_is_identity(_obj)
 matrix identity testing

Typedefs

typedef struct __vec2f GF_Point2D
 2D point

Functions

Fixed gf_v2d_len (GF_Point2D *vec)
 get 2D vector length
GF_Point2D gf_v2d_from_polar (Fixed length, Fixed angle)
 2D vector from polar coordinates
void gf_rect_union (GF_Rect *rc1, GF_Rect *rc2)
 rectangle union
GF_Rect gf_rect_center (Fixed w, Fixed h)
 centers a rectangle
Bool gf_rect_overlaps (GF_Rect rc1, GF_Rect rc2)
 rectangle overlap test
Bool gf_rect_equal (GF_Rect rc1, GF_Rect rc2)
 rectangle identity test
GF_IRect gf_rect_pixelize (GF_Rect *r)
 gets the pixelized version of a rectangle
void gf_mx2d_add_matrix (GF_Matrix2D *_this, GF_Matrix2D *from)
 2D matrix multiplication
void gf_mx2d_pre_multiply (GF_Matrix2D *_this, GF_Matrix2D *from)
 2D matrix pre-multiplication
void gf_mx2d_add_translation (GF_Matrix2D *_this, Fixed cx, Fixed cy)
 matrix translating
void gf_mx2d_add_rotation (GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle)
 matrix rotating
void gf_mx2d_add_scale (GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y)
 matrix scaling
void gf_mx2d_add_scale_at (GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y, Fixed cx, Fixed cy, Fixed angle)
 matrix uncentered scaling
void gf_mx2d_add_skew (GF_Matrix2D *_this, Fixed skew_x, Fixed skew_y)
 matrix skewing
void gf_mx2d_add_skew_x (GF_Matrix2D *_this, Fixed angle)
 matrix horizontal skewing
void gf_mx2d_add_skew_y (GF_Matrix2D *_this, Fixed angle)
 matrix vertical skewing
void gf_mx2d_inverse (GF_Matrix2D *_this)
 matrix inversing
void gf_mx2d_apply_coords (GF_Matrix2D *_this, Fixed *x, Fixed *y)
 matrix coordinate transformation
void gf_mx2d_apply_point (GF_Matrix2D *_this, GF_Point2D *pt)
 matrix point transformation
void gf_mx2d_apply_rect (GF_Matrix2D *_this, GF_Rect *rc)
 matrix rectangle transformation
Bool gf_mx2d_decompose (GF_Matrix2D *_this, GF_Point2D *scale, Fixed *rotate, GF_Point2D *translate)
 matrix decomposition

Detailed Description

This section documents mathematic tools for 2D geometry and color matrices operations


Define Documentation

#define gf_mx2d_init ( _obj   ) 

Inits the matrix to the identity matrix

#define gf_mx2d_copy ( _obj,
from   ) 

Copies the matrix _from to the matrix _obj

#define gf_mx2d_is_identity ( _obj   ) 

This macro evaluates to 1 if the matrix _obj is the identity matrix, 0 otherwise


Typedef Documentation

typedef struct __vec2f GF_Point2D

The 2D point object is used in all the GPAC framework for both point and vector representation.


Function Documentation

Fixed gf_v2d_len ( GF_Point2D vec  ) 

Gets the length of a 2D vector

Returns:
length of the vector
GF_Point2D gf_v2d_from_polar ( Fixed  length,
Fixed  angle 
)

Constructs a 2D vector from its polar coordinates

Parameters:
length the length of the vector
angle the angle of the vector in radians
Returns:
the 2D vector
void gf_rect_union ( GF_Rect rc1,
GF_Rect rc2 
)

Gets the union of two rectangles.

Parameters:
rc1 first rectangle of the union. Upon return, this rectangle will contain the result of the union
rc2 second rectangle of the union
GF_Rect gf_rect_center ( Fixed  w,
Fixed  h 
)

Builds a rectangle centered on the origin

Parameters:
w width of the rectangle
h height of the rectangle
Returns:
centered rectangle object
Bool gf_rect_overlaps ( GF_Rect  rc1,
GF_Rect  rc2 
)

Tests if two rectangles overlap.

Parameters:
rc1 first rectangle to test
rc2 second rectangle to test
Returns:
1 if rectangles overlap, 0 otherwise
Bool gf_rect_equal ( GF_Rect  rc1,
GF_Rect  rc2 
)

Tests if two rectangles are identical.

Parameters:
rc1 first rectangle to test
rc2 second rectangle to test
Returns:
1 if rectangles are identical, 0 otherwise
GF_IRect gf_rect_pixelize ( GF_Rect r  ) 

Returns the smallest pixel-aligned rectangle completely containing a rectangle

Parameters:
r the rectangle to transform
Returns:
the pixel-aligned transformed rectangle
void gf_mx2d_add_matrix ( GF_Matrix2D _this,
GF_Matrix2D from 
)

Multiplies two 2D matrices from*_this

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
from transformation matrix to add
void gf_mx2d_pre_multiply ( GF_Matrix2D _this,
GF_Matrix2D from 
)

Multiplies two 2D matrices _this*from

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
from transformation matrix to add
void gf_mx2d_add_translation ( GF_Matrix2D _this,
Fixed  cx,
Fixed  cy 
)

Translates a 2D matrix

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
cx horizontal translation
cy vertical translation
void gf_mx2d_add_rotation ( GF_Matrix2D _this,
Fixed  cx,
Fixed  cy,
Fixed  angle 
)

Rotates a 2D matrix

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
cx horizontal rotation center coordinate
cy vertical rotation center coordinate
angle rotation angle in radians
void gf_mx2d_add_scale ( GF_Matrix2D _this,
Fixed  scale_x,
Fixed  scale_y 
)

Scales a 2D matrix

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
scale_x horizontal scaling factor
scale_y vertical scaling factor
void gf_mx2d_add_scale_at ( GF_Matrix2D _this,
Fixed  scale_x,
Fixed  scale_y,
Fixed  cx,
Fixed  cy,
Fixed  angle 
)

Scales a 2D matrix with a non-centered scale

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
scale_x horizontal scaling factor
scale_y vertical scaling factor
cx horizontal scaling center coordinate
cy vertical scaling center coordinate
angle scale orienttion angle in radians
void gf_mx2d_add_skew ( GF_Matrix2D _this,
Fixed  skew_x,
Fixed  skew_y 
)

Skews a 2D matrix

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
skew_x horizontal skew factor
skew_y vertical skew factor
void gf_mx2d_add_skew_x ( GF_Matrix2D _this,
Fixed  angle 
)

Skews a 2D matrix horizontally by a given angle

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
angle horizontal skew angle in radians
void gf_mx2d_add_skew_y ( GF_Matrix2D _this,
Fixed  angle 
)

Skews a 2D matrix vertically by a given angle

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
angle vertical skew angle in radians
void gf_mx2d_inverse ( GF_Matrix2D _this  ) 

Inverses a 2D matrix

Parameters:
_this matrix being transformed. Once the function is called, _this contains the result matrix
void gf_mx2d_apply_coords ( GF_Matrix2D _this,
Fixed x,
Fixed y 
)

Applies a 2D matrix transformation to coordinates

Parameters:
_this transformation matrix
x pointer to horizontal coordinate. Once the function is called, x contains the transformed horizontal coordinate
y pointer to vertical coordinate. Once the function is called, y contains the transformed vertical coordinate
void gf_mx2d_apply_point ( GF_Matrix2D _this,
GF_Point2D pt 
)

Applies a 2D matrix transformation to a 2D point

Parameters:
_this transformation matrix
pt pointer to 2D point. Once the function is called, pt contains the transformed point
void gf_mx2d_apply_rect ( GF_Matrix2D _this,
GF_Rect rc 
)

Applies a 2D matrix transformation to a rectangle, giving the enclosing rectangle of the transformed one

Parameters:
_this transformation matrix
rc pointer to rectangle. Once the function is called, rc contains the transformed rectangle
Bool gf_mx2d_decompose ( GF_Matrix2D _this,
GF_Point2D scale,
Fixed rotate,
GF_Point2D translate 
)

Decomposes a 2D matrix M as M=Scale x Rotation x Translation if possible

Parameters:
_this transformation matrix
scale resulting scale part
rotate resulting rotation part
translate resulting translation part
Returns:
0 if matrix cannot be decomposed, 1 otherwise

Generated on 28 Feb 2010 for libgpac by  doxygen 1.6.1