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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
28#ifndef _N_3D_HEADER
29#define _N_3D_HEADER
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
40#include "n_log.h"
41#include "n_common.h"
42#include <sys/time.h>
43
45#define MOVE_STOPPED 0
47#define MOVE_INTER 1
49#define MOVE_SIMU 2
50
52#define VECTOR3D_DONT_INTERSECT -2
54#define VECTOR3D_COLLINEAR -1
56#define VECTOR3D_DO_INTERSECT 0
57
59typedef double VECTOR3D[3]; /* x , y , z */
60
62#define VECTOR3D_SET(VECTOR, X, Y, Z) \
63 do { \
64 VECTOR[0] = (X); \
65 VECTOR[1] = (Y); \
66 VECTOR[2] = (Z); \
67 } while (0)
68
94
96double distance(VECTOR3D* p1, VECTOR3D* p2);
98int update_physics_position_nb(PHYSICS* object, int it, double delta_t);
100int update_physics_position_reverse_nb(PHYSICS* object, int it, double delta_t);
102int update_physics_position(PHYSICS* object, double delta_t);
104int update_physics_position_reverse(PHYSICS* object, double delta_t);
106int vector_intersect(VECTOR3D* p0, VECTOR3D* p1, VECTOR3D* p2, VECTOR3D* p3, VECTOR3D* px);
108double vector_dot_product(VECTOR3D* vec1, VECTOR3D* vec2);
110double vector_normalize(VECTOR3D* vec);
112double vector_angle_between(VECTOR3D* vec1, VECTOR3D* vec2);
113
115#define copy_point(__src_, __dst_) \
116 memcpy(__dst_, __src_, sizeof(VECTOR3D));
117
122#ifdef __cplusplus
123}
124#endif
125
126#endif // header guard
VECTOR3D gravity
gx , gy , gz gravity
Definition n_3d.h:86
VECTOR3D speed
vx,vy,vz actual speed
Definition n_3d.h:76
int can_jump
ability
Definition n_3d.h:88
VECTOR3D orientation
ax,ay,az actual rotation position
Definition n_3d.h:80
int sz
size
Definition n_3d.h:90
VECTOR3D position
x,y,z actual position
Definition n_3d.h:74
int type
optionnal type id
Definition n_3d.h:92
VECTOR3D acceleration
ax,ay,az actual acceleration
Definition n_3d.h:78
VECTOR3D angular_acceleration
rax,ray,raz actual angular acceleration
Definition n_3d.h:84
VECTOR3D angular_speed
rvx,rvy,rvz actual angular speed
Definition n_3d.h:82
time_t delta_t
last delta_t used
Definition n_3d.h:72
double vector_dot_product(VECTOR3D *vec1, VECTOR3D *vec2)
dot product
Definition n_3d.c:211
double distance(VECTOR3D *p1, VECTOR3D *p2)
distance between two points
Definition n_3d.c:37
double VECTOR3D[3]
struct of a point
Definition n_3d.h:59
double vector_angle_between(VECTOR3D *vec1, VECTOR3D *vec2)
vector angle with other vector
Definition n_3d.c:234
int update_physics_position_nb(PHYSICS *object, int it, double delta_t)
update component[ it ] of a VECTOR3D
Definition n_3d.c:50
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:84
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:68
double vector_normalize(VECTOR3D *vec)
vector normalize
Definition n_3d.c:220
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:106
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:134
structure of the physics of an object
Definition n_3d.h:70
Common headers and low-level functions & define.
Generic log system.