Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
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
42#define VECTOR3D_SET(VECTOR, X, Y, Z) \
43 VECTOR[0] = (X); \
44 VECTOR[1] = (Y); \
45 VECTOR[2] = (Z);
46
72
73/* distance between two points */
74double distance(VECTOR3D* p1, VECTOR3D* p2);
75/* update component[ it ] of a VECTOR3D */
76int update_physics_position_nb(PHYSICS* object, int it, double delta_t);
77/* update component[ it ] of a VECTOR3D, reversed time */
78int update_physics_position_reverse_nb(PHYSICS* object, int it, double delta_t);
79/* update the position of an object, using the delta time T to update positions */
80int update_physics_position(PHYSICS* object, double delta_t);
81/* update the position of an object, using the delta time T to reverse update positions */
82int update_physics_position_reverse(PHYSICS* object, double delta_t);
83/* compute if two vector are colliding, storing the resulting point in px */
84int vector_intersect(VECTOR3D* p0, VECTOR3D* p1, VECTOR3D* p2, VECTOR3D* p3, VECTOR3D* px);
85/* dot product */
86double vector_dot_product(VECTOR3D* vec1, VECTOR3D* vec2);
87/* vector normalize */
88double vector_normalize(VECTOR3D* vec);
89/* vector angle with other vector */
90double vector_angle_between(VECTOR3D* vec1, VECTOR3D* vec2);
91
93#define copy_point(__src_, __dst_) \
94 memcpy(__dst_, __src_, sizeof(VECTOR3D));
95
100#ifdef __cplusplus
101}
102#endif
103
104#endif // header guard
VECTOR3D gravity
gx , gy , gz gravity
Definition n_3d.h:64
VECTOR3D speed
vx,vy,vz actual speed
Definition n_3d.h:54
int can_jump
ability
Definition n_3d.h:66
VECTOR3D orientation
ax,ay,az actual rotation position
Definition n_3d.h:58
int sz
size
Definition n_3d.h:68
VECTOR3D position
x,y,z actual position
Definition n_3d.h:52
int type
optionnal type id
Definition n_3d.h:70
VECTOR3D acceleration
ax,ay,az actual acceleration
Definition n_3d.h:56
VECTOR3D angular_acceleration
rax,ray,raz actual angular acceleration
Definition n_3d.h:62
VECTOR3D angular_speed
rvx,rvy,rvz actual angular speed
Definition n_3d.h:60
time_t delta_t
last delta_t used
Definition n_3d.h:50
double vector_dot_product(VECTOR3D *vec1, VECTOR3D *vec2)
Compute the dot product of two VECTOR3D.
Definition n_3d.c:189
double distance(VECTOR3D *p1, VECTOR3D *p2)
compute the distance between two VECTOR3D points
Definition n_3d.c:17
double VECTOR3D[3]
struct of a point
Definition n_3d.h:39
double vector_angle_between(VECTOR3D *vec1, VECTOR3D *vec2)
Compute angle between two VECTOR3D.
Definition n_3d.c:212
int update_physics_position_nb(PHYSICS *object, int it, double delta_t)
Update object position component.
Definition n_3d.c:30
int update_physics_position_reverse(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition n_3d.c:64
int update_physics_position_reverse_nb(PHYSICS *object, int it, double delta_t)
Update object position component, reversed.
Definition n_3d.c:48
double vector_normalize(VECTOR3D *vec)
Return the normalized value of vec.
Definition n_3d.c:198
int update_physics_position(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition n_3d.c:85
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:112
structure of the physics of an object
Definition n_3d.h:48
Common headers and low-level functions & define.
Generic log system.