Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_3d.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#ifndef _N_3D_HEADER
28#define _N_3D_HEADER
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
39#include "n_log.h"
40#include "n_common.h"
41#include <sys/time.h>
42
44#define MOVE_STOPPED 0
46#define MOVE_INTER 1
48#define MOVE_SIMU 2
49
51#define VECTOR3D_DONT_INTERSECT -2
53#define VECTOR3D_COLLINEAR -1
55#define VECTOR3D_DO_INTERSECT 0
56
58typedef double VECTOR3D[3]; /* x , y , z */
59
61#define VECTOR3D_SET(VECTOR, X, Y, Z) \
62 do { \
63 VECTOR[0] = (X); \
64 VECTOR[1] = (Y); \
65 VECTOR[2] = (Z); \
66 } while (0)
67
93
95double distance(VECTOR3D* p1, VECTOR3D* p2);
97int update_physics_position_nb(PHYSICS* object, int it, double delta_t);
99int update_physics_position_reverse_nb(PHYSICS* object, int it, double delta_t);
101int update_physics_position(PHYSICS* object, double delta_t);
103int update_physics_position_reverse(PHYSICS* object, double delta_t);
105int vector_intersect(VECTOR3D* p0, VECTOR3D* p1, VECTOR3D* p2, VECTOR3D* p3, VECTOR3D* px);
107double vector_dot_product(VECTOR3D* vec1, VECTOR3D* vec2);
109double vector_normalize(VECTOR3D* vec);
111double vector_angle_between(VECTOR3D* vec1, VECTOR3D* vec2);
112
114#define copy_point(__src_, __dst_) \
115 memcpy(__dst_, __src_, sizeof(VECTOR3D));
116
121#ifdef __cplusplus
122}
123#endif
124
125#endif // header guard
VECTOR3D gravity
gx , gy , gz gravity
Definition n_3d.h:85
VECTOR3D speed
vx,vy,vz actual speed
Definition n_3d.h:75
int can_jump
ability
Definition n_3d.h:87
VECTOR3D orientation
ax,ay,az actual rotation position
Definition n_3d.h:79
int sz
size
Definition n_3d.h:89
VECTOR3D position
x,y,z actual position
Definition n_3d.h:73
int type
optionnal type id
Definition n_3d.h:91
VECTOR3D acceleration
ax,ay,az actual acceleration
Definition n_3d.h:77
VECTOR3D angular_acceleration
rax,ray,raz actual angular acceleration
Definition n_3d.h:83
VECTOR3D angular_speed
rvx,rvy,rvz actual angular speed
Definition n_3d.h:81
time_t delta_t
last delta_t used
Definition n_3d.h:71
double vector_dot_product(VECTOR3D *vec1, VECTOR3D *vec2)
dot product
Definition n_3d.c:210
double distance(VECTOR3D *p1, VECTOR3D *p2)
distance between two points
Definition n_3d.c:36
double VECTOR3D[3]
struct of a point
Definition n_3d.h:58
double vector_angle_between(VECTOR3D *vec1, VECTOR3D *vec2)
vector angle with other vector
Definition n_3d.c:233
int update_physics_position_nb(PHYSICS *object, int it, double delta_t)
update component[ it ] of a VECTOR3D
Definition n_3d.c:49
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
Definition n_3d.c:83
int update_physics_position_reverse_nb(PHYSICS *object, int it, double delta_t)
update component[ it ] of a VECTOR3D, reversed time
Definition n_3d.c:67
double vector_normalize(VECTOR3D *vec)
vector normalize
Definition n_3d.c:219
int update_physics_position(PHYSICS *object, double delta_t)
update the position of an object, using the delta time T to update positions
Definition n_3d.c:105
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
Definition n_3d.c:133
structure of the physics of an object
Definition n_3d.h:69
Common headers and low-level functions & define.
Generic log system.