libgpac
Documentation of the core library of GPAC
math.c File Reference
#include <gpac/maths.h>
+ Include dependency graph for math.c:

Macros

#define DISABLE_MATHS
 
#define CHECK_MATRIX
 
#define SWAP_ROWS(a, b)   { Fixed *_tmp = a; (a)=(b); (b)=_tmp; }
 
#define XPLANE   0
 
#define YPLANE   1
 
#define ZPLANE   2
 

Functions

GF_EXPORT u32 gf_get_bit_size (u32 MaxVal)
 Field bit-size. More...
 
GF_EXPORT void gf_irect_union (GF_IRect *rc1, GF_IRect *rc2)
 
GF_EXPORT GF_Point2D gf_v2d_from_polar (Fixed length, Fixed angle)
 2D vector from polar coordinates More...
 
GF_EXPORT Fixed gf_v2d_len (GF_Point2D *vec)
 get 2D vector length More...
 
GF_EXPORT Fixed gf_v2d_distance (GF_Point2D *a, GF_Point2D *b)
 get distance between 2 points More...
 
GF_EXPORT Fixed gf_angle_diff (Fixed angle1, Fixed angle2)
 
GF_EXPORT void gf_mx2d_add_matrix (GF_Matrix2D *_this, GF_Matrix2D *from)
 2D matrix multiplication More...
 
GF_EXPORT void gf_mx2d_pre_multiply (GF_Matrix2D *_this, GF_Matrix2D *with)
 2D matrix pre-multiplication More...
 
GF_EXPORT void gf_mx2d_add_translation (GF_Matrix2D *_this, Fixed cx, Fixed cy)
 matrix translating More...
 
GF_EXPORT void gf_mx2d_add_rotation (GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle)
 matrix rotating More...
 
GF_EXPORT void gf_mx2d_add_scale (GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y)
 matrix scaling More...
 
GF_EXPORT 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...
 
GF_EXPORT void gf_mx2d_add_skew (GF_Matrix2D *_this, Fixed skew_x, Fixed skew_y)
 matrix skewing More...
 
GF_EXPORT void gf_mx2d_add_skew_x (GF_Matrix2D *_this, Fixed angle)
 matrix horizontal skewing More...
 
GF_EXPORT void gf_mx2d_add_skew_y (GF_Matrix2D *_this, Fixed angle)
 matrix vertical skewing More...
 
GF_EXPORT void gf_mx2d_inverse (GF_Matrix2D *_this)
 matrix inversing More...
 
GF_EXPORT Bool gf_mx2d_decompose (GF_Matrix2D *mx, GF_Point2D *scale, Fixed *rotate, GF_Point2D *translate)
 matrix decomposition More...
 
GF_EXPORT void gf_mx2d_apply_coords (GF_Matrix2D *_this, Fixed *x, Fixed *y)
 matrix coordinate transformation More...
 
GF_EXPORT void gf_mx2d_apply_point (GF_Matrix2D *_this, GF_Point2D *pt)
 matrix point transformation More...
 
GF_EXPORT void gf_mx2d_apply_rect (GF_Matrix2D *_this, GF_Rect *rc)
 matrix rectangle transformation More...
 
GF_EXPORT GF_IRect gf_rect_pixelize (GF_Rect *r)
 gets the pixelized version of a rectangle More...
 
GF_EXPORT void gf_rect_union (GF_Rect *rc1, GF_Rect *rc2)
 rectangle union More...
 
GF_EXPORT GF_Rect gf_rect_center (Fixed w, Fixed h)
 centers a rectangle More...
 
GF_EXPORT Bool gf_rect_overlaps (GF_Rect rc1, GF_Rect rc2)
 rectangle overlap test More...
 
GF_EXPORT Bool gf_rect_equal (GF_Rect *rc1, GF_Rect *rc2)
 rectangle identity test More...
 
GF_EXPORT void gf_rect_intersect (GF_Rect *rc1, GF_Rect *rc2)
 rectangle intersection More...
 
GF_EXPORT Fixed gf_vec_len_p (GF_Vec *v)
 get 3D vector length More...
 
GF_EXPORT Fixed gf_vec_len (GF_Vec v)
 get 3D vector length More...
 
GF_EXPORT Fixed gf_vec_lensq_p (GF_Vec *v)
 get 3D vector square length More...
 
GF_EXPORT Fixed gf_vec_lensq (GF_Vec v)
 get 3D vector square length More...
 
GF_EXPORT Fixed gf_vec_dot_p (GF_Vec *v1, GF_Vec *v2)
 get 3D vector dot product More...
 
GF_EXPORT Fixed gf_vec_dot (GF_Vec v1, GF_Vec v2)
 get 3D vector dot product More...
 
GF_EXPORT void gf_vec_norm (GF_Vec *v)
 vector normalization More...
 
GF_EXPORT GF_Vec gf_vec_scale_p (GF_Vec *v, Fixed f)
 vector scaling More...
 
GF_EXPORT GF_Vec gf_vec_scale (GF_Vec v, Fixed f)
 vector scaling More...
 
GF_EXPORT GF_Vec gf_vec_cross_p (GF_Vec *v1, GF_Vec *v2)
 vector cross product More...
 
GF_EXPORT GF_Vec gf_vec_cross (GF_Vec v1, GF_Vec v2)
 vector cross product More...
 
GF_EXPORT void gf_mx2d_from_mx (GF_Matrix2D *mat2D, GF_Matrix *mat)
 matrix to 2D matrix More...
 
GF_EXPORT void gf_mx_apply_rect (GF_Matrix *mat, GF_Rect *rc)
 matrix rectangle transformation More...
 
GF_EXPORT void gf_mx_add_matrix (GF_Matrix *mat, GF_Matrix *mul)
 matrices multiplication More...
 
GF_EXPORT void gf_mx_add_matrix_2d (GF_Matrix *mat, GF_Matrix2D *mat2D)
 2D matrix multiplication More...
 
GF_EXPORT void gf_mx_add_translation (GF_Matrix *mat, Fixed tx, Fixed ty, Fixed tz)
 matrix translation More...
 
GF_EXPORT void gf_mx_add_scale (GF_Matrix *mat, Fixed sx, Fixed sy, Fixed sz)
 matrix scaling More...
 
GF_EXPORT void gf_mx_add_rotation (GF_Matrix *mat, Fixed angle, Fixed x, Fixed y, Fixed z)
 matrix rotating More...
 
GF_EXPORT void gf_mx_from_mx2d (GF_Matrix *mat, GF_Matrix2D *mat2D)
 matrix constructor from 2D More...
 
GF_EXPORT Bool gf_mx_equal (GF_Matrix *mx1, GF_Matrix *mx2)
 matrix equality testing More...
 
GF_EXPORT void gf_mx_inverse (GF_Matrix *mx)
 affine matrix inversion More...
 
GF_EXPORT void gf_mx_transpose (GF_Matrix *mx)
 transpose 4x4 matrix More...
 
GF_EXPORT void gf_mx_apply_vec (GF_Matrix *mx, GF_Vec *pt)
 matrix point transformation More...
 
GF_EXPORT 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...
 
GF_EXPORT 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...
 
GF_EXPORT void gf_mx_perspective (GF_Matrix *mx, Fixed fieldOfView, Fixed aspectRatio, Fixed z_near, Fixed z_far)
 perspective matrix construction More...
 
GF_EXPORT void gf_mx_perspective_reverse_z (GF_Matrix *mx, Fixed fieldOfView, Fixed aspectRatio, Fixed z_near, Fixed z_far)
 perspective matrix with reverse Z construction More...
 
GF_EXPORT void gf_mx_lookat (GF_Matrix *mx, GF_Vec eye, GF_Vec center, GF_Vec upVector)
 creates look matrix More...
 
GF_Vec4 gf_quat_from_matrix (GF_Matrix *mx)
 
GF_EXPORT void gf_mx_get_yaw_pitch_roll (GF_Matrix *mx, Fixed *yaw, Fixed *pitch, Fixed *roll)
 matrix yaw pitch roll decomposition More...
 
GF_EXPORT void gf_mx_decompose (GF_Matrix *mx, GF_Vec *translate, GF_Vec *scale, GF_Vec4 *rotate, GF_Vec *shear)
 matrix decomposition More...
 
GF_EXPORT void gf_mx_apply_bbox_sphere (GF_Matrix *mx, GF_BBox *box)
 matrix box sphere transformation More...
 
GF_EXPORT void gf_mx_apply_bbox (GF_Matrix *mx, GF_BBox *box)
 matrix box transformation More...
 
GF_EXPORT void gf_mx_apply_bbox_4x4 (GF_Matrix *mx, GF_BBox *box)
 matrix box transformation More...
 
GF_EXPORT void gf_mx_rotate_vector (GF_Matrix *mx, GF_Vec *pt)
 matrix vector rotation More...
 
GF_EXPORT void gf_mx_rotation_matrix_from_vectors (GF_Matrix *mx, GF_Vec x, GF_Vec y, GF_Vec z)
 matrix initialization from vectors More...
 
GF_EXPORT void gf_mx_add_matrix_4x4 (GF_Matrix *mat, GF_Matrix *mul)
 non-affine matrix multiplication More...
 
GF_EXPORT void gf_mx_apply_vec_4x4 (GF_Matrix *mx, GF_Vec4 *vec)
 matrix 4D vector transformation More...
 
GF_EXPORT Bool gf_mx_inverse_4x4 (GF_Matrix *mx)
 non-affine matrix inversion More...
 
GF_EXPORT Bool gf_plane_intersect_line (GF_Plane *plane, GF_Vec *linepoint, GF_Vec *linevec, GF_Vec *outPoint)
 plane line intersection More...
 
GF_EXPORT GF_Ray gf_ray (GF_Vec start, GF_Vec end)
 ray constructor More...
 
GF_EXPORT void gf_mx_apply_ray (GF_Matrix *mx, GF_Ray *r)
 matrix ray transformation More...
 
GF_EXPORT Bool gf_ray_hit_box (GF_Ray *ray, GF_Vec box_min, GF_Vec box_max, GF_Vec *outPoint)
 ray box intersection test More...
 
GF_EXPORT Bool gf_ray_hit_sphere (GF_Ray *ray, GF_Vec *center, Fixed radius, GF_Vec *outPoint)
 ray sphere intersection test More...
 
GF_EXPORT Bool gf_ray_hit_triangle (GF_Ray *ray, GF_Vec *v0, GF_Vec *v1, GF_Vec *v2, Fixed *dist)
 ray triangle intersection test More...
 
GF_EXPORT GF_Vec gf_closest_point_to_line (GF_Vec line_pt, GF_Vec line_vec, GF_Vec pt)
 closest point on a line More...
 
GF_EXPORT GF_Vec4 gf_quat_to_rotation (GF_Vec4 *quat)
 quaternion to rotation More...
 
GF_EXPORT GF_Vec4 gf_quat_from_rotation (GF_Vec4 rot)
 quaternion from rotation More...
 
GF_EXPORT GF_Vec4 gf_quat_from_axis_cos (GF_Vec axis, Fixed cos_a)
 quaternion from axis and cos More...
 
static void gf_quat_conjugate (GF_Vec4 *quat)
 
GF_EXPORT GF_Vec4 gf_quat_get_inv (GF_Vec4 *quat)
 
GF_EXPORT GF_Vec4 gf_quat_multiply (GF_Vec4 *q1, GF_Vec4 *q2)
 quaternion multiplication More...
 
GF_EXPORT GF_Vec gf_quat_rotate (GF_Vec4 *quat, GF_Vec *vec)
 quaternion vector rotating More...
 
GF_EXPORT GF_Vec4 gf_quat_slerp (GF_Vec4 q1, GF_Vec4 q2, Fixed frac)
 quaternion interpolation More...
 
GF_EXPORT void gf_bbox_refresh (GF_BBox *b)
 
GF_EXPORT void gf_bbox_from_rect (GF_BBox *box, GF_Rect *rc)
 
GF_EXPORT void gf_rect_from_bbox (GF_Rect *rc, GF_BBox *box)
 
GF_EXPORT void gf_bbox_grow_point (GF_BBox *box, GF_Vec pt)
 bounding box expansion More...
 
GF_EXPORT void gf_bbox_union (GF_BBox *b1, GF_BBox *b2)
 
GF_EXPORT Bool gf_bbox_equal (GF_BBox *b1, GF_BBox *b2)
 
GF_EXPORT Bool gf_bbox_point_inside (GF_BBox *box, GF_Vec *p)
 
GF_EXPORT void gf_bbox_get_vertices (GF_Vec bmin, GF_Vec bmax, GF_Vec *vecs)
 get box vertices More...
 
GF_EXPORT void gf_mx_apply_plane (GF_Matrix *mx, GF_Plane *plane)
 matrix plane transformation More...
 
GF_EXPORT Fixed gf_plane_get_distance (GF_Plane *plane, GF_Vec *p)
 point to plane distance More...
 
GF_EXPORT u32 gf_plane_get_p_vertex_idx (GF_Plane *p)
 box p-vertex index More...
 
GF_EXPORT u32 gf_bbox_plane_relation (GF_BBox *box, GF_Plane *p)
 box-plane relation More...
 
GF_EXPORT u32 gf_get_next_pow2 (u32 s)
 Get power of 2. More...
 

Macro Definition Documentation

◆ DISABLE_MATHS

#define DISABLE_MATHS

◆ CHECK_MATRIX

#define CHECK_MATRIX

◆ SWAP_ROWS

#define SWAP_ROWS (   a,
 
)    { Fixed *_tmp = a; (a)=(b); (b)=_tmp; }

◆ XPLANE

#define XPLANE   0

◆ YPLANE

#define YPLANE   1

◆ ZPLANE

#define ZPLANE   2

Function Documentation

◆ gf_quat_from_matrix()

GF_EXPORT GF_Vec4 gf_quat_from_matrix ( GF_Matrix mx)
+ Here is the caller graph for this function:

◆ gf_quat_conjugate()

static void gf_quat_conjugate ( GF_Vec4 quat)
static
+ Here is the caller graph for this function: