Nilorea Library
C utilities for networking, threading, graphics
n_3d.h
Go to the documentation of this file.
1
8#ifndef _N_3D_HEADER
9#define _N_3D_HEADER
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
20#include "n_log.h"
21#include "n_common.h"
22#include <sys/time.h>
23
25#define MOVE_STOPPED 0
27#define MOVE_INTER 1
29#define MOVE_SIMU 2
30
32#define VECTOR3D_DONT_INTERSECT -2
34#define VECTOR3D_COLLINEAR -1
36#define VECTOR3D_DO_INTERSECT 0
37
39typedef double VECTOR3D[ 3 ]; /* x , y , z */
40
41
43#define VECTOR3D_SET( VECTOR , X , Y , Z ) \
44 VECTOR[ 0 ] = (X) ; \
45 VECTOR[ 1 ] = (Y) ; \
46 VECTOR[ 2 ] = (Z) ;
47
49typedef struct PHYSICS
50{
52 time_t delta_t ;
70 int sz ;
72 int type ;
73} PHYSICS ;
74
75/* distance between two points */
76double distance( VECTOR3D *p1, VECTOR3D *p2 );
77/* update componant[ it ] of a VECTOR3D */
78int update_physics_position_nb( PHYSICS *object, int it, double delta_t );
79/* update componant[ it ] of a VECTOR3D, reversed time */
80int update_physics_position_reverse_nb( PHYSICS *object, int it, double delta_t );
81/* update the position of an object, using the delta time T to update positions */
82int update_physics_position( PHYSICS *object, double delta_t );
83/* update the position of an object, using the delta time T to reverse update positions */
84int update_physics_position_reverse( PHYSICS *object, double delta_t );
85/* compute if two vector are colliding, storing the resulting point in px */
86int vector_intersect( VECTOR3D *p0, VECTOR3D *p1, VECTOR3D *p2, VECTOR3D *p3, VECTOR3D *px );
87/* dot product */
88double vector_dot_product( VECTOR3D *vec1, VECTOR3D *vec2 );
89/* vector normalize */
90double vector_normalize( VECTOR3D *vec );
91/* vector angle with other vector */
92double vector_angle_between( VECTOR3D *vec1, VECTOR3D *vec2 );
93
95#define copy_point( __src_ , __dst_ ) \
96 memcpy( __dst_ , __src_ , sizeof( VECTOR3D ) );
97
102#ifdef __cplusplus
103}
104#endif
105
106#endif // header guard
107
VECTOR3D gravity
gx , gy , gz gravity
Definition: n_3d.h:66
VECTOR3D speed
vx,vy,vz actual speed
Definition: n_3d.h:56
int can_jump
ability
Definition: n_3d.h:68
VECTOR3D orientation
ax,ay,az actual rotation position
Definition: n_3d.h:60
int sz
size
Definition: n_3d.h:70
VECTOR3D position
x,y,z actual position
Definition: n_3d.h:54
int type
optionnal type id
Definition: n_3d.h:72
VECTOR3D acceleration
ax,ay,az actual acceleration
Definition: n_3d.h:58
VECTOR3D angular_acceleration
rax,ray,raz actual angular acceleration
Definition: n_3d.h:64
VECTOR3D angular_speed
rvx,rvy,rvz actual angular speed
Definition: n_3d.h:62
time_t delta_t
last delta_t used
Definition: n_3d.h:52
double vector_dot_product(VECTOR3D *vec1, VECTOR3D *vec2)
Compute the dot product of two VECTOR3D.
Definition: n_3d.c:224
double distance(VECTOR3D *p1, VECTOR3D *p2)
compute the distance between two VECTOR3D points
Definition: n_3d.c:18
double VECTOR3D[3]
struct of a point
Definition: n_3d.h:39
double vector_angle_between(VECTOR3D *vec1, VECTOR3D *vec2)
Compute angle beteen two VECTOR3D.
Definition: n_3d.c:254
int update_physics_position_nb(PHYSICS *object, int it, double delta_t)
Update object position componant.
Definition: n_3d.c:34
int update_physics_position_reverse(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition: n_3d.c:73
int update_physics_position_reverse_nb(PHYSICS *object, int it, double delta_t)
Update object position componant, reversed.
Definition: n_3d.c:55
double vector_normalize(VECTOR3D *vec)
Return the normalized value of vec.
Definition: n_3d.c:236
int update_physics_position(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition: n_3d.c:98
int vector_intersect(VECTOR3D *p0, VECTOR3D *p1, VECTOR3D *p2, VECTOR3D *p3, VECTOR3D *px)
Compute if two vectors are intersecting or not.
Definition: n_3d.c:132
structure of the physics of an object
Definition: n_3d.h:50
Common headers and low-level hugly functions & define.
Generic log system.