Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
PHYSICS: simple 3D movement simulation

Data Structures

struct  PHYSICS
 structure of the physics of an object More...

Macros

#define copy_point(__src_, __dst_)
 VECTOR3D copy wrapper.
#define MOVE_INTER   1
 PHYSICS object state for move interpolated between two position.
#define MOVE_SIMU   2
 PHYSICS object state for move simulated from latest update.
#define MOVE_STOPPED   0
 PHYSICS object state for STOPPED.
#define VECTOR3D_COLLINEAR   -1
 value when the two VECTOR3D are collinear
#define VECTOR3D_DO_INTERSECT   0
 value when the two VECTOR3D are intersecting
#define VECTOR3D_DONT_INTERSECT   -2
 value when the two VECTOR3D are not connected
#define VECTOR3D_SET(VECTOR, X, Y, Z)
 helper to set a VECTOR3D position

Typedefs

typedef double VECTOR3D[3]
 struct of a point

Functions

double distance (VECTOR3D *p1, VECTOR3D *p2)
 distance between two points
int update_physics_position (PHYSICS *object, double delta_t)
 update the position of an object, using the delta time T to update positions
int update_physics_position_nb (PHYSICS *object, int it, double delta_t)
 update component[ it ] of a VECTOR3D
int update_physics_position_reverse (PHYSICS *object, double delta_t)
 update the position of an object, using the delta time T to reverse update positions
int update_physics_position_reverse_nb (PHYSICS *object, int it, double delta_t)
 update component[ it ] of a VECTOR3D, reversed time
double vector_angle_between (VECTOR3D *vec1, VECTOR3D *vec2)
 vector angle with other vector
double vector_dot_product (VECTOR3D *vec1, VECTOR3D *vec2)
 dot product
int vector_intersect (VECTOR3D *p0, VECTOR3D *p1, VECTOR3D *p2, VECTOR3D *p3, VECTOR3D *px)
 compute if two vector are colliding, storing the resulting point in px
double vector_normalize (VECTOR3D *vec)
 vector normalize

Detailed Description


Data Structure Documentation

◆ PHYSICS

struct PHYSICS

structure of the physics of an object

Examples
ex_gui_particles.c, ex_iso_astar.c, and ex_trajectory.c.

Definition at line 70 of file n_3d.h.

Collaboration diagram for PHYSICS:
Data Fields
VECTOR3D acceleration ax,ay,az actual acceleration
VECTOR3D angular_acceleration rax,ray,raz actual angular acceleration
VECTOR3D angular_speed rvx,rvy,rvz actual angular speed
int can_jump ability
time_t delta_t last delta_t used
VECTOR3D gravity gx , gy , gz gravity
VECTOR3D orientation ax,ay,az actual rotation position
VECTOR3D position x,y,z actual position
VECTOR3D speed vx,vy,vz actual speed
int sz size
int type optionnal type id

Macro Definition Documentation

◆ copy_point

#define copy_point ( __src_,
__dst_ )
Value:
memcpy(__dst_, __src_, sizeof(VECTOR3D));
double VECTOR3D[3]
struct of a point
Definition n_3d.h:59

VECTOR3D copy wrapper.

Definition at line 115 of file n_3d.h.

◆ MOVE_INTER

#define MOVE_INTER   1

PHYSICS object state for move interpolated between two position.

Definition at line 47 of file n_3d.h.

◆ MOVE_SIMU

#define MOVE_SIMU   2

PHYSICS object state for move simulated from latest update.

Definition at line 49 of file n_3d.h.

◆ MOVE_STOPPED

#define MOVE_STOPPED   0

PHYSICS object state for STOPPED.

Definition at line 45 of file n_3d.h.

◆ VECTOR3D_COLLINEAR

#define VECTOR3D_COLLINEAR   -1

value when the two VECTOR3D are collinear

Definition at line 54 of file n_3d.h.

Referenced by vector_intersect().

◆ VECTOR3D_DO_INTERSECT

#define VECTOR3D_DO_INTERSECT   0

value when the two VECTOR3D are intersecting

Definition at line 56 of file n_3d.h.

Referenced by vector_intersect().

◆ VECTOR3D_DONT_INTERSECT

#define VECTOR3D_DONT_INTERSECT   -2

value when the two VECTOR3D are not connected

Definition at line 52 of file n_3d.h.

Referenced by vector_intersect().

◆ VECTOR3D_SET

#define VECTOR3D_SET ( VECTOR,
X,
Y,
Z )
Value:
do { \
VECTOR[0] = (X); \
VECTOR[1] = (Y); \
VECTOR[2] = (Z); \
} while (0)

helper to set a VECTOR3D position

Examples
ex_gui_particles.c, and ex_trajectory.c.

Definition at line 62 of file n_3d.h.

Referenced by add_particle_at(), add_particle_ex(), init_physics_2d(), init_physics_3d(), and main().

Typedef Documentation

◆ VECTOR3D

typedef double VECTOR3D[3]

struct of a point

Examples
ex_iso_astar.c, and ex_trajectory.c.

Definition at line 59 of file n_3d.h.

Function Documentation

◆ distance()

double distance ( VECTOR3D * p1,
VECTOR3D * p2 )

distance between two points

distance between two points

Parameters
p1The first point
p2The second point
Returns
The computed distance

Definition at line 37 of file n_3d.c.

◆ update_physics_position()

int update_physics_position ( PHYSICS * object,
double delta_t )

update the position of an object, using the delta time T to update positions

update the position of an object, using the delta time T to update positions

Wrapper of update_physics_position_nb to update each component.

Parameters
objectThe object physics to update
delta_tElapsed time since last call for component update computing
Returns
TRUE or FALSE

Definition at line 106 of file n_3d.c.

References __n_assert, and update_physics_position_nb().

Referenced by manage_particle_ex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_physics_position_nb()

int update_physics_position_nb ( PHYSICS * object,
int it,
double delta_t )

update component[ it ] of a VECTOR3D

update component[ it ] of a VECTOR3D

Parameters
objectThe object physics to update
itcomponent of VECTOR3D to update. it values : 0 -> x, 1 -> y , 2 -> z
delta_tElapsed time since last call for component update computing
Returns
TRUE or FALSE

Definition at line 50 of file n_3d.c.

References __n_assert, and PHYSICS::acceleration.

Referenced by update_physics_position(), and update_physics_position_reverse().

Here is the caller graph for this function:

◆ update_physics_position_reverse()

int update_physics_position_reverse ( PHYSICS * object,
double delta_t )

update the position of an object, using the delta time T to reverse update positions

update the position of an object, using the delta time T to reverse update positions

Wrapper of update_physics_position_reverse_nb to update each component.

Parameters
objectThe object physics to update
delta_tElapsed time since last call for component update computing
Returns
TRUE or FALSE

Definition at line 84 of file n_3d.c.

References __n_assert, and update_physics_position_nb().

Here is the call graph for this function:

◆ update_physics_position_reverse_nb()

int update_physics_position_reverse_nb ( PHYSICS * object,
int it,
double delta_t )

update component[ it ] of a VECTOR3D, reversed time

update component[ it ] of a VECTOR3D, reversed time

Parameters
objectThe object physics to update
itcomponent of VECTOR3D to update. it values : 0 -> x, 1 -> y , 2 -> z
delta_tElapsed time since last call for component update computing
Returns
TRUE or FALSE

Definition at line 68 of file n_3d.c.

References __n_assert.

◆ vector_angle_between()

double vector_angle_between ( VECTOR3D * vec1,
VECTOR3D * vec2 )

vector angle with other vector

vector angle with other vector

Parameters
vec1first VECTOR3D
vec2second VECTOR3D
Returns
angle between vectors in rad (todeg = returnval * 180/PI_2)

Definition at line 234 of file n_3d.c.

References vector_dot_product(), and vector_normalize().

Here is the call graph for this function:

◆ vector_dot_product()

double vector_dot_product ( VECTOR3D * vec1,
VECTOR3D * vec2 )

dot product

dot product

Parameters
vec1first VECTOR3D
vec2second VECTOR3D
Returns
dot product value

Definition at line 211 of file n_3d.c.

Referenced by vector_angle_between().

Here is the caller graph for this function:

◆ vector_intersect()

int vector_intersect ( VECTOR3D * p1,
VECTOR3D * p2,
VECTOR3D * p3,
VECTOR3D * p4,
VECTOR3D * px )

compute if two vector are colliding, storing the resulting point in px

compute if two vector are colliding, storing the resulting point in px

Parameters
p1First point of vector 1
p2Second point of vector 1
p3First point of vector 2
p4Second point of vector 2
pxStorage for the eventual point
Returns
VECTOR3D_DONT_INTERSECT , VECTOR3D_COLLINEAR or VECTOR3D_DO_INTERSECT

Definition at line 134 of file n_3d.c.

References same_sign(), VECTOR3D_COLLINEAR, VECTOR3D_DO_INTERSECT, and VECTOR3D_DONT_INTERSECT.

Here is the call graph for this function:

◆ vector_normalize()

double vector_normalize ( VECTOR3D * vec)

vector normalize

vector normalize

Parameters
vecVECTOR3D to normalize
Returns
normalized value of vec

Definition at line 220 of file n_3d.c.

Referenced by vector_angle_between().

Here is the caller graph for this function: