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 | |
| 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 | |
| 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 | |
This section documents mathematic tools for 2D geometry and color matrices operations
| #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 struct __vec2f GF_Point2D |
The 2D point object is used in all the GPAC framework for both point and vector representation.
| Fixed gf_v2d_len | ( | GF_Point2D * | vec | ) |
Gets the length of a 2D vector
| Fixed gf_v2d_distance | ( | GF_Point2D * | a, | |
| GF_Point2D * | b | |||
| ) |
Gets the distance between the 2 points
| 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 |
Returns the smallest pixel-aligned rectangle completely containing a rectangle
| r | the rectangle to transform |
| 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 |
1.6.1