![]() |
libgpac
Documentation of the core library of GPAC
|
2D Mathematics More...
Collaboration diagram for Math 2d: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 | |
| #define | gf_mx2d_copy(_obj, from) |
| matrix copy | |
| #define | gf_mx2d_is_identity(_obj) |
| matrix identity testing | |
Functions | |
| Fixed | gf_v2d_len (GF_Point2D *vec) |
| get 2D vector length | |
| Fixed | gf_v2d_distance (GF_Point2D *a, GF_Point2D *b) |
| get distance between 2 points | |
| 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 | |
| void | gf_rect_intersect (GF_Rect *rc1, GF_Rect *rc2) |
| rectangle intersection | |
| GF_IRect | gf_rect_pixelize (GF_Rect *r) |
| gets the pixelized version of a rectangle | |
| void | gf_irect_union (GF_IRect *rc1, GF_IRect *rc2) |
| 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 | |
2D Mathematics
This section documents mathematic tools for 2D geometry and color matrices operations
| struct GF_Point2D |
| struct GF_Rect |
rectangle 2D
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
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 | ) |
matrix initialization
Inits the matrix to the identity matrix
| #define gf_mx2d_copy | ( | _obj, | |
| from | |||
| ) |
matrix copy
Copies the matrix _from to the matrix _obj
| #define gf_mx2d_is_identity | ( | _obj | ) |
matrix identity testing
This macro evaluates to 1 if the matrix _obj is the identity matrix, 0 otherwise
| Fixed gf_v2d_len | ( | GF_Point2D * | vec | ) |
get 2D vector length
Gets the length of a 2D vector
| vec | the target vector |
Here is the caller graph for this function:| Fixed gf_v2d_distance | ( | GF_Point2D * | a, |
| GF_Point2D * | b | ||
| ) |
get distance between 2 points
Gets the distance between the 2 points
| a | first point |
| b | second point |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_Point2D gf_v2d_from_polar | ( | Fixed | length, |
| Fixed | angle | ||
| ) |
2D vector from polar coordinates
Constructs a 2D vector from its polar coordinates
| length | the length of the vector |
| angle | the angle of the vector in radians |
Here is the caller graph for this function:rectangle union
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 |
Here is the caller graph for this function:centers a rectangle
Builds a rectangle centered on the origin
| w | width of the rectangle |
| h | height of the rectangle |
Here is the caller graph for this function:rectangle overlap test
Tests if two rectangles overlap.
| rc1 | first rectangle to test |
| rc2 | second rectangle to test |
Here is the caller graph for this function:rectangle identity test
Tests if two rectangles are identical.
| rc1 | first rectangle to test |
| rc2 | second rectangle to test |
Here is the caller graph for this function:rectangle intersection
Intersects two rectangle.
| rc1 | rectangle to use, updated to intersection result |
| rc2 | second rectangle to use |
Here is the call graph for this function:
Here is the caller graph for this function:gets the pixelized version of a rectangle
Gets the smallest pixel-aligned rectangle completely containing a rectangle
| r | the rectangle to transform |
Here is the caller graph for this function:add adds rc2 to rc1 - the new rc1 contains the old rc1 and rc2
| rc1 | target rectangle |
| rc2 | rectangle to add |
Here is the caller graph for this function:| void gf_mx2d_add_matrix | ( | GF_Matrix2D * | _this, |
| GF_Matrix2D * | from | ||
| ) |
2D matrix multiplication
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 |
Here is the caller graph for this function:| void gf_mx2d_pre_multiply | ( | GF_Matrix2D * | _this, |
| GF_Matrix2D * | from | ||
| ) |
2D matrix pre-multiplication
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 |
Here is the caller graph for this function:| void gf_mx2d_add_translation | ( | GF_Matrix2D * | _this, |
| Fixed | cx, | ||
| Fixed | cy | ||
| ) |
matrix translating
Translates a 2D matrix
| _this | matrix being transformed. Once the function is called, _this contains the result matrix |
| cx | horizontal translation |
| cy | vertical translation |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_rotation | ( | GF_Matrix2D * | _this, |
| Fixed | cx, | ||
| Fixed | cy, | ||
| Fixed | angle | ||
| ) |
matrix rotating
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_scale | ( | GF_Matrix2D * | _this, |
| Fixed | scale_x, | ||
| Fixed | scale_y | ||
| ) |
matrix scaling
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_scale_at | ( | GF_Matrix2D * | _this, |
| Fixed | scale_x, | ||
| Fixed | scale_y, | ||
| Fixed | cx, | ||
| Fixed | cy, | ||
| Fixed | angle | ||
| ) |
matrix uncentered scaling
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_skew | ( | GF_Matrix2D * | _this, |
| Fixed | skew_x, | ||
| Fixed | skew_y | ||
| ) |
matrix skewing
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_skew_x | ( | GF_Matrix2D * | _this, |
| Fixed | angle | ||
| ) |
matrix horizontal skewing
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_add_skew_y | ( | GF_Matrix2D * | _this, |
| Fixed | angle | ||
| ) |
matrix vertical skewing
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_inverse | ( | GF_Matrix2D * | _this | ) |
matrix inversing
Inverses a 2D matrix
| _this | matrix being transformed. Once the function is called, _this contains the result matrix |
Here is the caller graph for this function:| void gf_mx2d_apply_coords | ( | GF_Matrix2D * | _this, |
| Fixed * | x, | ||
| Fixed * | y | ||
| ) |
matrix coordinate transformation
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 |
Here is the caller graph for this function:| void gf_mx2d_apply_point | ( | GF_Matrix2D * | _this, |
| GF_Point2D * | pt | ||
| ) |
matrix point transformation
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| void gf_mx2d_apply_rect | ( | GF_Matrix2D * | _this, |
| GF_Rect * | rc | ||
| ) |
matrix rectangle transformation
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 |
Here is the call graph for this function:
Here is the caller graph for this function:| Bool gf_mx2d_decompose | ( | GF_Matrix2D * | _this, |
| GF_Point2D * | scale, | ||
| Fixed * | rotate, | ||
| GF_Point2D * | translate | ||
| ) |
matrix decomposition
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 |
Here is the caller graph for this function: