Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_3d.h
Go to the documentation of this file.
1
9#ifndef _N_3D_HEADER
10#define _N_3D_HEADER
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
21#include "n_log.h"
22#include "n_common.h"
23#include <sys/time.h>
24
26#define MOVE_STOPPED 0
28#define MOVE_INTER 1
30#define MOVE_SIMU 2
31
33#define VECTOR3D_DONT_INTERSECT -2
35#define VECTOR3D_COLLINEAR -1
37#define VECTOR3D_DO_INTERSECT 0
38
40typedef double VECTOR3D[3]; /* x , y , z */
41
43#define VECTOR3D_SET(VECTOR, X, Y, Z) \
44 VECTOR[0] = (X); \
45 VECTOR[1] = (Y); \
46 VECTOR[2] = (Z);
47
73
74/* distance between two points */
75double distance(VECTOR3D* p1, VECTOR3D* p2);
76/* update component[ it ] of a VECTOR3D */
77int update_physics_position_nb(PHYSICS* object, int it, double delta_t);
78/* update component[ it ] of a VECTOR3D, reversed time */
79int update_physics_position_reverse_nb(PHYSICS* object, int it, double delta_t);
80/* update the position of an object, using the delta time T to update positions */
81int update_physics_position(PHYSICS* object, double delta_t);
82/* update the position of an object, using the delta time T to reverse update positions */
83int update_physics_position_reverse(PHYSICS* object, double delta_t);
84/* compute if two vector are colliding, storing the resulting point in px */
85int vector_intersect(VECTOR3D* p0, VECTOR3D* p1, VECTOR3D* p2, VECTOR3D* p3, VECTOR3D* px);
86/* dot product */
87double vector_dot_product(VECTOR3D* vec1, VECTOR3D* vec2);
88/* vector normalize */
89double vector_normalize(VECTOR3D* vec);
90/* vector angle with other vector */
91double vector_angle_between(VECTOR3D* vec1, VECTOR3D* vec2);
92
94#define copy_point(__src_, __dst_) \
95 memcpy(__dst_, __src_, sizeof(VECTOR3D));
96
101#ifdef __cplusplus
102}
103#endif
104
105#endif // header guard
VECTOR3D gravity
gx , gy , gz gravity
Definition n_3d.h:65
VECTOR3D speed
vx,vy,vz actual speed
Definition n_3d.h:55
int can_jump
ability
Definition n_3d.h:67
VECTOR3D orientation
ax,ay,az actual rotation position
Definition n_3d.h:59
int sz
size
Definition n_3d.h:69
VECTOR3D position
x,y,z actual position
Definition n_3d.h:53
int type
optionnal type id
Definition n_3d.h:71
VECTOR3D acceleration
ax,ay,az actual acceleration
Definition n_3d.h:57
VECTOR3D angular_acceleration
rax,ray,raz actual angular acceleration
Definition n_3d.h:63
VECTOR3D angular_speed
rvx,rvy,rvz actual angular speed
Definition n_3d.h:61
time_t delta_t
last delta_t used
Definition n_3d.h:51
double vector_dot_product(VECTOR3D *vec1, VECTOR3D *vec2)
Compute the dot product of two VECTOR3D.
Definition n_3d.c:190
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:40
double vector_angle_between(VECTOR3D *vec1, VECTOR3D *vec2)
Compute angle between two VECTOR3D.
Definition n_3d.c:213
int update_physics_position_nb(PHYSICS *object, int it, double delta_t)
Update object position component.
Definition n_3d.c:31
int update_physics_position_reverse(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition n_3d.c:65
int update_physics_position_reverse_nb(PHYSICS *object, int it, double delta_t)
Update object position component, reversed.
Definition n_3d.c:49
double vector_normalize(VECTOR3D *vec)
Return the normalized value of vec.
Definition n_3d.c:199
int update_physics_position(PHYSICS *object, double delta_t)
Update object position, reversed.
Definition n_3d.c:86
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:113
structure of the physics of an object
Definition n_3d.h:49
Common headers and low-level functions & define.
Generic log system.