libgpac
Documentation of the core library of GPAC
|
2D Mathematics More...
Data Structures | |
struct | GF_Point2D |
2D point More... | |
struct | GF_Rect |
rectangle 2D More... | |
struct | GF_IRect |
pixel-aligned rectangle More... | |
struct | GF_Matrix2D |
2D matrix More... | |
Macros | |
#define | gf_mx2d_init(_obj) |
matrix initialization More... | |
#define | gf_mx2d_copy(_obj, from) |
matrix copy More... | |
#define | gf_mx2d_is_identity(_obj) |
matrix identity testing More... | |
Functions | |
Fixed | gf_v2d_len (GF_Point2D *vec) |
get 2D vector length More... | |
Fixed | gf_v2d_distance (GF_Point2D *a, GF_Point2D *b) |
get distance between 2 points More... | |
GF_Point2D | gf_v2d_from_polar (Fixed length, Fixed angle) |
2D vector from polar coordinates More... | |
void | gf_rect_union (GF_Rect *rc1, GF_Rect *rc2) |
rectangle union More... | |
GF_Rect | gf_rect_center (Fixed w, Fixed h) |
centers a rectangle More... | |
Bool | gf_rect_overlaps (GF_Rect rc1, GF_Rect rc2) |
rectangle overlap test More... | |
Bool | gf_rect_equal (GF_Rect *rc1, GF_Rect *rc2) |
rectangle identity test More... | |
void | gf_rect_intersect (GF_Rect *rc1, GF_Rect *rc2) |
rectangle intersection More... | |
GF_IRect | gf_rect_pixelize (GF_Rect *r) |
gets the pixelized version of a rectangle More... | |
void | gf_irect_union (GF_IRect *rc1, GF_IRect *rc2) |
void | gf_mx2d_add_matrix (GF_Matrix2D *_this, GF_Matrix2D *from) |
2D matrix multiplication More... | |
void | gf_mx2d_pre_multiply (GF_Matrix2D *_this, GF_Matrix2D *from) |
2D matrix pre-multiplication More... | |
void | gf_mx2d_add_translation (GF_Matrix2D *_this, Fixed cx, Fixed cy) |
matrix translating More... | |
void | gf_mx2d_add_rotation (GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle) |
matrix rotating More... | |
void | gf_mx2d_add_scale (GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y) |
matrix scaling More... | |
void | gf_mx2d_add_scale_at (GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y, Fixed cx, Fixed cy, Fixed angle) |
matrix uncentered scaling More... | |
void | gf_mx2d_add_skew (GF_Matrix2D *_this, Fixed skew_x, Fixed skew_y) |
matrix skewing More... | |
void | gf_mx2d_add_skew_x (GF_Matrix2D *_this, Fixed angle) |
matrix horizontal skewing More... | |
void | gf_mx2d_add_skew_y (GF_Matrix2D *_this, Fixed angle) |
matrix vertical skewing More... | |
void | gf_mx2d_inverse (GF_Matrix2D *_this) |
matrix inversing More... | |
void | gf_mx2d_apply_coords (GF_Matrix2D *_this, Fixed *x, Fixed *y) |
matrix coordinate transformation More... | |
void | gf_mx2d_apply_point (GF_Matrix2D *_this, GF_Point2D *pt) |
matrix point transformation More... | |
void | gf_mx2d_apply_rect (GF_Matrix2D *_this, GF_Rect *rc) |
matrix rectangle transformation More... | |
Bool | gf_mx2d_decompose (GF_Matrix2D *_this, GF_Point2D *scale, Fixed *rotate, GF_Point2D *translate) |
matrix decomposition More... | |
This section documents mathematic tools for 2D geometry and color matrices operations
struct GF_Point2D |
struct GF_Rect |
The 2D rectangle used in the GPAC project.
Data Fields | ||
---|---|---|
Fixed | x |
the left coordinate of the rectangle |
Fixed | y |
the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the greatest coordinate value, even if the rectangle is presented bottom-up. This insures proper rectangles testing |
Fixed | width |
the width of the rectangle. Width must be greater than or equal to 0 |
Fixed | height |
the height of the rectangle. Height must be greater than or equal to 0 |
struct GF_IRect |
Pixel-aligned rectangle used in the GPAC framework. This is usually needed for 2D drawing algorithms.
Data Fields | ||
---|---|---|
s32 | x |
the left coordinate of the rectangle |
s32 | y |
the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the greatest coordinate value, even if the rectangle is presented bottom-up. This insures proper rectangles operations |
s32 | width |
the width of the rectangle. Width must be greater than or equal to 0 |
s32 | height |
the height of the rectangle. Height must be greater than or equal to 0 |
struct GF_Matrix2D |
#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
Fixed gf_v2d_len | ( | GF_Point2D * | vec | ) |
Gets the length of a 2D vector
vec | the target vector |
Fixed gf_v2d_distance | ( | GF_Point2D * | a, |
GF_Point2D * | b | ||
) |
Gets the distance between the 2 points
a | first point |
b | second point |
GF_Point2D gf_v2d_from_polar | ( | Fixed | length, |
Fixed | angle | ||
) |
Constructs a 2D vector from its polar coordinates
length | the length of the vector |
angle | the angle of the vector in radians |
Gets the union of two rectangles.
rc1 | first rectangle of the union. Upon return, this rectangle will contain the result of the union |
rc2 | second rectangle of the union |
Builds a rectangle centered on the origin
w | width of the rectangle |
h | height of the rectangle |
Tests if two rectangles overlap.
rc1 | first rectangle to test |
rc2 | second rectangle to test |
Tests if two rectangles are identical.
rc1 | first rectangle to test |
rc2 | second rectangle to test |
Intersects two rectangle.
rc1 | rectangle to use, updated to intersection result |
rc2 | second rectangle to use |
Gets the smallest pixel-aligned rectangle completely containing a rectangle
r | the rectangle to transform |
add adds rc2 to rc1 - the new rc1 contains the old rc1 and rc2
rc1 | target rectangle |
rc2 | rectangle to add |
void gf_mx2d_add_matrix | ( | GF_Matrix2D * | _this, |
GF_Matrix2D * | from | ||
) |
Multiplies two 2D matrices from*_this
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_this | transformation matrix |
scale | resulting scale part |
rotate | resulting rotation part |
translate | resulting translation part |