LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
lg_math_extra.c File Reference

Functions

zboolean lg_raycast_bsphere (LG_Camera *cam, LG_BSphere bsphere, float *inters_dist, int *click_type, zboolean flush_clicks)
 
vec4_t vec4 (float x, float y, float z, float w)
 
vec4_t m4_mul_v4 (mat4_t m, vec4_t v)
 
float m4_det (mat4_t mat)
 
mat4_t m4_invert (mat4_t mat)
 

Detailed Description

Function Documentation

◆ lg_raycast_bsphere()

zboolean lg_raycast_bsphere ( LG_Camera cam,
LG_BSphere  bsphere,
float *  inters_dist,
int *  click_type,
zboolean  flush_clicks 
)

Ray casting

Check intersection of ray (emitted from mouse pointer location on left/right-click) with sphere

Parameters
cam
bsphere
inters_distIntersection distance, set if intersection occurs
click_typeSet to RAYCAST_LEFT_CLICK, RAYCAST_RIGHT_CLICK, or RAYCAST_NO_CLICK
flush_clicksIf TRUE, call lg_flush_in_clicks() after intersection occurs and before returning
Returns
TRUE if intersection occurs, FALSE otherwise

◆ vec4()

vec4_t vec4 ( float  x,
float  y,
float  z,
float  w 
)

Create a vec4_t

Parameters
x
y
z
w
Returns
A new vec4_t

◆ m4_mul_v4()

vec4_t m4_mul_v4 ( mat4_t  m,
vec4_t  v 
)

Multiply 4x4 matrix by vec4 ("apply" mat4 to vec4)

Parameters
m4x4 matrix
vVec4
Returns
Result as a vec4_t

◆ m4_det()

float m4_det ( mat4_t  mat)

Get determinant of a 4x4 matrix

Source: http://www.euclideanspace.com/maths/algebra/matrix/functions/determinant/fourD/index.htm

Parameters
mMatrix
Returns
Determinant of matrix

◆ m4_invert()

mat4_t m4_invert ( mat4_t  mat)

Invert a 4x4 matrix if invertible, ie if its determinant is != 0

Source: http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm

Parameters
mMatrix
Returns
Inverted matrix if OK, unchanged matrix if not invertible