libgpac
Documentation of the core library of GPAC
maths.h File Reference

Mathematics and Trigonometric. More...

#include <gpac/setup.h>
#include <math.h>
+ Include dependency graph for maths.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  SFVec2f
 2D point More...
 
struct  GF_Rect
 rectangle 2D More...
 
struct  GF_IRect
 pixel-aligned rectangle More...
 
struct  GF_Matrix2D
 2D matrix More...
 
struct  SFVec3f
 3D point or vector More...
 
struct  SFVec4f
 4D vector More...
 
struct  GF_Matrix_unexposed
 3D matrix More...
 
struct  GF_BBox
 3D Bounding Box More...
 
struct  GF_Plane
 Plane object. More...
 
struct  GF_Ray
 3D Ray More...
 

Macros

#define FIX_ONE
 
#define INT2FIX(v)
 
#define FLT2FIX(v)
 
#define FIX2INT(v)
 
#define FIX2FLT(v)
 
#define FIX_EPSILON
 
#define FIX_MAX
 
#define FIX_MIN
 
#define GF_PI2
 
#define GF_PI
 
#define GF_2PI
 
#define gf_invfix(_a)
 
#define gf_mulfix(_a, _b)
 
#define gf_muldiv(_a, _b, _c)
 
#define gf_divfix(_a, _b)
 
#define gf_sqrt(_a)
 
#define gf_ceil(_a)
 
#define gf_floor(_a)
 
#define gf_cos(_a)
 
#define gf_sin(_a)
 
#define gf_tan(_a)
 
#define gf_atan2(_y, _x)
 
#define gf_acos(_a)
 
#define gf_asin(_a)
 
#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...
 
#define gf_vec_equal(v1, v2)
 
#define gf_vec_rev(v)
 
#define gf_vec_diff(res, v1, v2)
 
#define gf_vec_add(res, v1, v2)
 
#define gf_quat_len(v)
 
#define gf_quat_norm(v)
 
#define gf_mx_init(_obj)
 matrix initialization More...
 
#define gf_mx_is_identity(_obj)   ((!(_obj).m[1] && !(_obj).m[2] && !(_obj).m[3] && !(_obj).m[4] && !(_obj).m[6] && !(_obj).m[7] && !(_obj).m[8] && !(_obj).m[9] && !(_obj).m[11] && !(_obj).m[12] && !(_obj).m[13] && !(_obj).m[14] && ((_obj).m[0]==FIX_ONE) && ((_obj).m[5]==FIX_ONE)&& ((_obj).m[10]==FIX_ONE)&& ((_obj).m[15]==FIX_ONE)) ? 1 : 0)
 
#define gf_mx_copy(_obj, from)
 matrix copy More...
 

Typedefs

typedef Float Fixed
 

Enumerations

enum  { GF_BBOX_FRONT, GF_BBOX_INTER, GF_BBOX_BACK }
 

Functions

Fixed gf_angle_diff (Fixed a, Fixed b)
 
u32 gf_get_bit_size (u32 MaxVal)
 Field bit-size. More...
 
u32 gf_get_next_pow2 (u32 val)
 Get power of 2. More...
 
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_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...
 
Fixed gf_vec_len (GF_Vec v)
 get 3D vector length More...
 
Fixed gf_vec_len_p (GF_Vec *v)
 get 3D vector length More...
 
Fixed gf_vec_lensq (GF_Vec v)
 get 3D vector square length More...
 
Fixed gf_vec_lensq_p (GF_Vec *v)
 get 3D vector square length More...
 
Fixed gf_vec_dot (GF_Vec v1, GF_Vec v2)
 get 3D vector dot product More...
 
Fixed gf_vec_dot_p (GF_Vec *v1, GF_Vec *v2)
 get 3D vector dot product More...
 
void gf_vec_norm (GF_Vec *v)
 vector normalization More...
 
GF_Vec gf_vec_scale (GF_Vec v, Fixed f)
 vector scaling More...
 
GF_Vec gf_vec_scale_p (GF_Vec *v, Fixed f)
 vector scaling More...
 
GF_Vec gf_vec_cross (GF_Vec v1, GF_Vec v2)
 vector cross product More...
 
GF_Vec gf_vec_cross_p (GF_Vec *v1, GF_Vec *v2)
 vector cross product More...
 
GF_Vec4 gf_quat_to_rotation (GF_Vec4 *quat)
 quaternion to rotation More...
 
GF_Vec4 gf_quat_from_rotation (GF_Vec4 rot)
 quaternion from rotation More...
 
GF_Vec4 gf_quat_get_inv (GF_Vec4 *quat)
 
GF_Vec4 gf_quat_multiply (GF_Vec4 *q1, GF_Vec4 *q2)
 quaternion multiplication More...
 
GF_Vec gf_quat_rotate (GF_Vec4 *quat, GF_Vec *vec)
 quaternion vector rotating More...
 
GF_Vec4 gf_quat_from_axis_cos (GF_Vec axis, Fixed cos_a)
 quaternion from axis and cos More...
 
GF_Vec4 gf_quat_slerp (GF_Vec4 q1, GF_Vec4 q2, Fixed frac)
 quaternion interpolation More...
 
void gf_bbox_refresh (GF_BBox *b)
 
void gf_bbox_from_rect (GF_BBox *box, GF_Rect *rc)
 
void gf_rect_from_bbox (GF_Rect *rc, GF_BBox *box)
 
void gf_bbox_grow_point (GF_BBox *box, GF_Vec pt)
 bounding box expansion More...
 
void gf_bbox_union (GF_BBox *b1, GF_BBox *b2)
 
Bool gf_bbox_equal (GF_BBox *b1, GF_BBox *b2)
 
Bool gf_bbox_point_inside (GF_BBox *box, GF_Vec *p)
 
void gf_bbox_get_vertices (GF_Vec bmin, GF_Vec bmax, GF_Vec *vecs)
 get box vertices More...
 
void gf_mx_from_mx2d (GF_Matrix *mx, GF_Matrix2D *mat2D)
 matrix constructor from 2D More...
 
Bool gf_mx_equal (GF_Matrix *mx1, GF_Matrix *mx2)
 matrix equality testing More...
 
void gf_mx_add_translation (GF_Matrix *mx, Fixed tx, Fixed ty, Fixed tz)
 matrix translation More...
 
void gf_mx_add_scale (GF_Matrix *mx, Fixed sx, Fixed sy, Fixed sz)
 matrix scaling More...
 
void gf_mx_add_rotation (GF_Matrix *mx, Fixed angle, Fixed x, Fixed y, Fixed z)
 matrix rotating More...
 
void gf_mx_add_matrix (GF_Matrix *mx, GF_Matrix *mul)
 matrices multiplication More...
 
void gf_mx_add_matrix_2d (GF_Matrix *mx, GF_Matrix2D *mat2D)
 2D matrix multiplication More...
 
void gf_mx_inverse (GF_Matrix *mx)
 affine matrix inversion More...
 
void gf_mx_transpose (GF_Matrix *mx)
 transpose 4x4 matrix More...
 
void gf_mx_apply_vec (GF_Matrix *mx, GF_Vec *pt)
 matrix point transformation More...
 
void gf_mx_apply_rect (GF_Matrix *_this, GF_Rect *rc)
 matrix rectangle transformation More...
 
void gf_mx_ortho (GF_Matrix *mx, Fixed left, Fixed right, Fixed bottom, Fixed top, Fixed z_near, Fixed z_far)
 ortho matrix construction More...
 
void gf_mx_ortho_reverse_z (GF_Matrix *mx, Fixed left, Fixed right, Fixed bottom, Fixed top, Fixed z_near, Fixed z_far)
 ortho matrix with reverse Z construction More...
 
void gf_mx_perspective (GF_Matrix *mx, Fixed fov, Fixed aspect_ratio, Fixed z_near, Fixed z_far)
 perspective matrix construction More...
 
void gf_mx_perspective_reverse_z (GF_Matrix *mx, Fixed fov, Fixed aspect_ratio, Fixed z_near, Fixed z_far)
 perspective matrix with reverse Z construction More...
 
void gf_mx_lookat (GF_Matrix *mx, GF_Vec position, GF_Vec target, GF_Vec up_vector)
 creates look matrix More...
 
void gf_mx_apply_bbox (GF_Matrix *mx, GF_BBox *b)
 matrix box transformation More...
 
void gf_mx_apply_bbox_sphere (GF_Matrix *mx, GF_BBox *box)
 matrix box sphere transformation More...
 
void gf_mx_add_matrix_4x4 (GF_Matrix *mat, GF_Matrix *mul)
 non-affine matrix multiplication More...
 
Bool gf_mx_inverse_4x4 (GF_Matrix *mx)
 non-affine matrix inversion More...
 
void gf_mx_apply_vec_4x4 (GF_Matrix *mx, GF_Vec4 *vec)
 matrix 4D vector transformation More...
 
void gf_mx_get_yaw_pitch_roll (GF_Matrix *mx, Fixed *yaw, Fixed *pitch, Fixed *roll)
 matrix yaw pitch roll decomposition More...
 
void gf_mx_decompose (GF_Matrix *mx, GF_Vec *translate, GF_Vec *scale, GF_Vec4 *rotate, GF_Vec *shear)
 matrix decomposition More...
 
void gf_mx_rotate_vector (GF_Matrix *mx, GF_Vec *pt)
 matrix vector rotation More...
 
void gf_mx_rotation_matrix_from_vectors (GF_Matrix *mx, GF_Vec x_axis, GF_Vec y_axis, GF_Vec z_axis)
 matrix initialization from vectors More...
 
void gf_mx2d_from_mx (GF_Matrix2D *mx2d, GF_Matrix *mx)
 matrix to 2D matrix More...
 
void gf_mx_apply_plane (GF_Matrix *mx, GF_Plane *plane)
 matrix plane transformation More...
 
Fixed gf_plane_get_distance (GF_Plane *plane, GF_Vec *p)
 point to plane distance More...
 
GF_Vec gf_closest_point_to_line (GF_Vec line_pt, GF_Vec line_vec, GF_Vec pt)
 closest point on a line More...
 
u32 gf_plane_get_p_vertex_idx (GF_Plane *p)
 box p-vertex index More...
 
Bool gf_plane_intersect_line (GF_Plane *plane, GF_Vec *linepoint, GF_Vec *linevec, GF_Vec *outPoint)
 plane line intersection More...
 
u32 gf_bbox_plane_relation (GF_BBox *box, GF_Plane *p)
 box-plane relation More...
 
GF_Ray gf_ray (GF_Vec start, GF_Vec end)
 ray constructor More...
 
void gf_mx_apply_ray (GF_Matrix *mx, GF_Ray *r)
 matrix ray transformation More...
 
Bool gf_ray_hit_box (GF_Ray *ray, GF_Vec min_edge, GF_Vec max_edge, GF_Vec *out_point)
 ray box intersection test More...
 
Bool gf_ray_hit_sphere (GF_Ray *ray, GF_Vec *center, Fixed radius, GF_Vec *out_point)
 ray sphere intersection test More...
 
Bool gf_ray_hit_triangle (GF_Ray *ray, GF_Vec *v0, GF_Vec *v1, GF_Vec *v2, Fixed *dist)
 ray triangle intersection test More...
 

Detailed Description

>