51# define JO_PI (3.1415927f)
54# define JO_PI_2 (1.5707963f)
69# define JO_MULT_BY_2(X) ((X) << 1)
75# define JO_MULT_BY_4(X) ((X) << 2)
81# define JO_MULT_BY_8(X) ((X) << 3)
87# define JO_MULT_BY_16(X) ((X) << 4)
93# define JO_MULT_BY_32(X) ((X) << 5)
99# define JO_MULT_BY_64(X) ((X) << 6)
105# define JO_MULT_BY_128(X) ((X) << 7)
111# define JO_MULT_BY_256(X) ((X) << 8)
117# define JO_MULT_BY_512(X) ((X) << 9)
123# define JO_MULT_BY_1024(X) ((X) << 10)
129# define JO_MULT_BY_2048(X) ((X) << 11)
135# define JO_MULT_BY_4096(X) ((X) << 12)
141# define JO_MULT_BY_32768(X) ((X) << 15)
147# define JO_MULT_BY_65536(X) ((X) << 16)
153# define JO_DIV_BY_2(X) ((X) >> 1)
159# define JO_DIV_BY_4(X) ((X) >> 2)
165# define JO_DIV_BY_8(X) ((X) >> 3)
171# define JO_DIV_BY_16(X) ((X) >> 4)
177# define JO_DIV_BY_32(X) ((X) >> 5)
183# define JO_DIV_BY_64(X) ((X) >> 6)
189# define JO_DIV_BY_128(X) ((X) >> 7)
195# define JO_DIV_BY_256(X) ((X) >> 8)
201# define JO_DIV_BY_512(X) ((X) >> 9)
207# define JO_DIV_BY_1024(X) ((X) >> 10)
213# define JO_DIV_BY_32768(X) ((X) >> 15)
219# define JO_DIV_BY_65536(X) ((X) >> 16)
225# define JO_DIV_BY_2147483648(X) ((X) >> 31)
240# define JO_ZERO(X) X ^= X
247# define JO_MOD_POW2(N, M) ((N) & ((M) - 1))
252# define JO_IS_POW2(N) ((N) != 0 && (((N) & ((N) - 1)) == 0))
257# define JO_ABS(X) ((X) < 0 ? -(X) : (X))
262# define JO_FABS(X) ((X) < 0.0f ? -(X) : (X))
268# define JO_MIN(A, B) (((A) < (B)) ? (A) : (B))
274# define JO_MAX(A, B) (((A) > (B)) ? (A) : (B))
283# define JO_CLAMP(X, MIN, MAX) JO_MAX((MIN), JO_MIN((MAX), (X)))
288# define JO_CHANGE_SIGN(X) (-(X))
291# define JO_FLOAT_EPSILON (0.00001f)
297# define JO_FLOAT_NEARLY_EQUALS(A, B) ((A) <= ((B) + JO_FLOAT_EPSILON) && (A) >= ((B) - JO_FLOAT_EPSILON))
302# define JO_IS_FLOAT_NULL(A) ((A) <= JO_FLOAT_EPSILON && (A) >= (-JO_FLOAT_EPSILON))
307# define JO_RAD_TO_DEG(A) ((A) * 57.295780f)
312# define JO_DEG_TO_RAD(A) ((A) * 0.017453292f)
317# define JO_IS_ODD(A) ((A) & 1)
324# define JO_SWAP(A, B) { __typeof__((A) + 0) __jo_swap_tmp = (A); (A) = (B); (B) = __jo_swap_tmp; }
332# define JO_OPAQUE(VAR) __asm__ ("" : "+r" (VAR))
339# define JO_PERCENT_USED(TOTAL, FREE) ((TOTAL) == 0 ? 0 : (int)((unsigned int)((TOTAL) - (FREE)) * 100u / (unsigned int)(TOTAL)))
344# define JO_SQUARE(A) ((A) * (A))
349# define JO_BCD_INT(BCD) (((((BCD) & 0xF0) >> 4) * 10) + ((BCD) & 0x0F))
364# define JO_SET_FLAGS(BYTEFIELD, FLAGS) BYTEFIELD = (FLAGS)
369# define JO_SET_ALL_FLAGS(BYTEFIELD) BYTEFIELD = (~0)
375# define JO_ADD_FLAG(BYTEFIELD, FLAG) BYTEFIELD |= (FLAG)
381# define JO_REMOVE_FLAG(BYTEFIELD, FLAG) BYTEFIELD &= ~(FLAG)
386# define JO_REMOVE_ALL_FLAGS(BYTEFIELD) BYTEFIELD = 0
392# define JO_HAS_FLAG(BYTEFIELD, FLAG) (((BYTEFIELD) & (FLAG)) == (FLAG))
408# define JO_FIXED_0 (0)
410# define JO_FIXED_1_DIV_2 (32768)
412# define JO_FIXED_ALMOST_1 (65470)
414# define JO_FIXED_1 (65536)
416# define JO_FIXED_2 JO_INT_TO_FIXED(2)
418# define JO_FIXED_3 JO_INT_TO_FIXED(3)
420# define JO_FIXED_4 JO_INT_TO_FIXED(4)
422# define JO_FIXED_8 JO_INT_TO_FIXED(8)
424# define JO_FIXED_16 JO_INT_TO_FIXED(16)
426# define JO_FIXED_32 JO_INT_TO_FIXED(32)
428# define JO_FIXED_120 JO_INT_TO_FIXED(120)
430# define JO_FIXED_150 JO_INT_TO_FIXED(150)
432# define JO_FIXED_180 JO_INT_TO_FIXED(180)
434# define JO_FIXED_360 JO_INT_TO_FIXED(360)
437# define JO_FIXED_MIN (-2147483647)
439# define JO_FIXED_MAX (2147483647)
441# define JO_FIXED_EPSILON (1)
443# define JO_FIXED_OVERFLOW (0x80000000)
445# define JO_FIXED_PI (205887)
447# define JO_FIXED_PI_2 (411775)
449# define JO_FIXED_180_DIV_PI (3754936)
451# define JO_FIXED_PI_DIV_180 (1144)
453# define JO_FIXED_PI_DIV_2 (102944)
455# define JO_FIXED_PI_OVER_2 JO_FIXED_PI_DIV_2
457# define JO_FIXED_3_PI_OVER_2 (308831)
459# define JO_FIXED_1_DIV (1.0f / 65536.0f)
464# define JO_INT_TO_FIXED(X) JO_MULT_BY_65536(X)
468# define JO_FIXED_TO_INT(X) JO_DIV_BY_65536(X)
470# define JO_FIXED_DECIMAL_MASK (0xFFFF)
475# define JO_FLOAT_TO_FIXED(X) ((jo_fixed)(65536.0f * (X)))
481# define JO_DEG_TO_ANGLE(X) ((jo_angle)(int)((X) * 8192 / 45))
486# define JO_RAD_TO_ANGLE(X) ((jo_angle)(int)((65536.0 * (X)) / (2.0 * 3.14159265358979)))
563 if (__builtin_constant_p(x))
575 if (__builtin_constant_p(x))
596 if ((bits & 0x7FFFFFFFu) == 0)
598 return ((bits & 0x80000000u) ? -1 : 1);
637 rad -= (int)(((
long long)rad * 10430) >> 32) *
JO_FIXED_PI_2;
652 deg -= (int)(((
long long)deg * 182) >> 32) *
JO_FIXED_360;
673 return ((
jo_fixed)(((
long long)x * y) >> 16));
686 __asm__ (
"dmuls.l %1, %2\n\t"
710 __asm__ (
"clrmac\n\t"
711 "mac.l @%2+, @%3+\n\t"
712 "mac.l @%2+, @%3+\n\t"
713 "mac.l @%2+, @%3+\n\t"
717 :
"=&r" (high),
"=&r" (low),
"+r" (a),
"+r" (b)
765 return (x < 0 ? (
int)~(~(
unsigned int)x >> 8) : (
int)((
unsigned int)x >> 8));
776 return ((
int)(((
unsigned int)x + (1u << 23)) >> 8) - (1 << 15));
825 return (x & 0xFFFF0000UL) + (x & 0x0000FFFFUL ?
JO_FIXED_1 : 0);
834 return (x & 0xFFFF0000ul);
867 return (max < multiple ? multiple :
jo_random(max / multiple) * multiple);
879 *seed = *seed * 1103515245u + 12345u;
880 return ((
int)(*seed >> 16));
995# define __JO_DEG_TO_ANGLE_MAGIC (182)
1019 n = deg < 0 ? 0u - (
unsigned int)deg : (
unsigned int)deg;
1022 a = (int)(((
long long)(n * 8192) * 95443718LL) >> 32);
1023 return ((
jo_angle)(deg < 0 ? -a : a));
1034 return ((
jo_angle)(((
long long)rad * 683565276LL) >> 32));
1062 return (((((
unsigned short)angle) + 8) >> 4) & 0xfff);
1106 return ((
jo_angle)(((
long long)deg * 11930465LL) >> 32));
1472 if (d >= 360 || d <= -360)
1480 else if (d < -max_step)
1483 if (d >= 360 || d <= -360)
1485 return (d < 0 ? d + 360 : d);
1524 result->x = a->x + b->x;
1525 result->y = a->y + b->y;
1526 result->z = a->z + b->z;
1550 result->x = a->x - b->x;
1551 result->y = a->y - b->y;
1552 result->z = a->z - b->z;
1601 result->x = a->x + b->x;
1602 result->y = a->y + b->y;
1603 result->z = a->z + b->z;
1615 result->x = a->x - b->x;
1616 result->y = a->y - b->y;
1617 result->z = a->z - b->z;
1806 for (i = 1; i < 15; ++i)
1821 for (i = 1; i < 15; ++i)
1822 result->
table[i] = 0;
1836 result->m30 = offset->x;
1837 result->m31 = offset->y;
1838 result->m32 = offset->z;
1848 result->m30 = offset->
x;
1849 result->m31 = offset->
y;
1850 result->m32 = offset->
z;
1860 result->m00 = scale->x;
1861 result->m11 = scale->y;
1862 result->m22 = scale->z;
1872 result->m00 = scale->
x;
1873 result->m11 = scale->
y;
1874 result->m22 = scale->
z;
1885 result->m21 = -result->m12;
1886 result->m22 = result->m11;
1907 result->m21 = -result->m12;
1908 result->m22 = result->m11;
1919 result->m02 = -result->m20;
1920 result->m22 = result->m00;
1941 result->m02 = -result->m20;
1942 result->m22 = result->m00;
1953 result->m10 = -result->m01;
1954 result->m11 = result->m00;
1975 result->m10 = -result->m01;
1976 result->m11 = result->m00;
1986 result->m00 = matrix->m00;
1987 result->m10 = matrix->m01;
1988 result->m20 = matrix->m02;
1989 result->m30 = matrix->m03;
1990 result->m01 = matrix->m10;
1991 result->m11 = matrix->m11;
1992 result->m21 = matrix->m12;
1993 result->m31 = matrix->m13;
1994 result->m02 = matrix->m20;
1995 result->m12 = matrix->m21;
1996 result->m22 = matrix->m22;
1997 result->m32 = matrix->m23;
1998 result->m03 = matrix->m30;
1999 result->m13 = matrix->m31;
2000 result->m23 = matrix->m32;
2001 result->m33 = matrix->m33;
2011 result->m00 = matrix->m00;
2012 result->m10 = matrix->m01;
2013 result->m20 = matrix->m02;
2014 result->m30 = matrix->m03;
2015 result->m01 = matrix->m10;
2016 result->m11 = matrix->m11;
2017 result->m21 = matrix->m12;
2018 result->m31 = matrix->m13;
2019 result->m02 = matrix->m20;
2020 result->m12 = matrix->m21;
2021 result->m22 = matrix->m22;
2022 result->m32 = matrix->m23;
2023 result->m03 = matrix->m30;
2024 result->m13 = matrix->m31;
2025 result->m23 = matrix->m32;
2026 result->m33 = matrix->m33;
2044 __asm__ (
"clrmac\n\t"
2045 "mac.l @%2+, @%3+\n\t"
2046 "mac.l @%2+, @%3+\n\t"
2047 "mac.l @%2+, @%3+\n\t"
2048 "mac.l @%2+, @%3+\n\t"
2052 :
"=&r" (high),
"=&r" (low),
"+r" (a),
"+r" (b)
2077 for (i = 0; i < 4; ++i)
2079 columns[i][0] = m->
m[0][i];
2080 columns[i][1] = m->
m[1][i];
2081 columns[i][2] = m->
m[2][i];
2082 columns[i][3] = m->
m[3][i];
2106 for (i = 0; i < 4; ++i)
2107 for (j = 0; j < 4; ++j)
2137 const float back,
const float front,
jo_matrixf *
const result);
2148 const float near_view_distance,
const float far_view_distance,
jo_matrixf *
const result);
2226 const int x2,
const int y2,
const int w2,
const int h2)
2228 return ((x1 < x2 + w2) && (x2 < x1 + w1)) && ((y1 < y2 + h2) && (y2 < y1 + h1));
jo_pos3D_fixed position
Definition entity.h:2
jo_fixed jo_vector_fixed_length(const jo_vector_fixed *const a)
Length of a vector (using fixed numbers).
void jo_vectorf_sub(const jo_vectorf *const a, const jo_vectorf *const b, jo_vectorf *const result)
Subtract 2 vectors (using floating numbers).
static __jo_force_inline void jo_matrixf_transpose(const jo_matrixf *const matrix, jo_matrixf *const result)
Creates transpose matrix (using floating numbers).
Definition math.h:2009
static __jo_force_inline jo_fixed jo_int2fixed(const int x)
Convert int to jo engine fixed.
Definition math.h:492
static __jo_force_inline void jo_matrix_rotation_y_rad(const float angle_in_rad, jo_matrix *const result)
Rotation matrix around the Y axis (radian, using floating numbers: converted, then jo_matrix_rotation...
Definition math.h:1927
static __jo_force_inline jo_angle jo_DEGtoANG(const float deg)
Convert a degree to jo_angle using floating number.
Definition math.h:1001
static __jo_force_inline void jo_matrix_mul(const jo_matrix *const a, const jo_matrix *const b, jo_matrix *const result)
Multiply 2 matrix (using fixed numbers).
Definition math.h:2098
static __jo_force_inline float __jo_float_from_bits(const unsigned int i)
A float from its bits (Internal usage).
Definition math.h:532
static __jo_force_inline void jo_matrixf_rotation_z_rad(const float angle_in_rad, jo_matrixf *const result)
Creates rotating matrix (Z axis) (using floating numbers).
Definition math.h:1970
static __jo_force_inline void jo_vector4_fixed_cross(const jo_vector4_fixed *const a, const jo_vector4_fixed *const b, jo_vector4_fixed *const result)
Cross product of 2 vectors4 (using fixed numbers).
Definition math.h:1626
void jo_vectorf_cross(const jo_vectorf *const a, const jo_vectorf *const b, jo_vectorf *const result)
Cross 2 vectors (using floating numbers).
static __jo_force_inline void jo_matrix_rotation_z_rad(const float angle_in_rad, jo_matrix *const result)
Rotation matrix around the Z axis (radian, using floating numbers: converted, then jo_matrix_rotation...
Definition math.h:1961
void jo_planar_rotate(const jo_pos2D *const point, const jo_pos2D *const origin, const int angle, jo_pos2D *const result)
Rotate a point on the plan with a specific origin.
static __jo_force_inline jo_angle jo_DEGtoANG_int(const int deg)
Convert a degree to jo_angle using interger.
Definition math.h:1011
void jo_vector_fixed_compute_bezier_point(const jo_fixed t, jo_vector_fixed p0, jo_vector_fixed p1, jo_vector_fixed p2, jo_vector_fixed p3, jo_vector_fixed *result)
Compute cubic bezier curve point for vectors (using fixed numbers).
static __jo_force_inline jo_fixed jo_sin_rad(const float rad)
Sinus computation.
Definition math.h:1153
static __jo_force_inline jo_fixed __jo_sin_index(const unsigned int index)
Sinus of a table index (Internal usage).
Definition math.h:1045
static __jo_force_inline int __jo_wrap_360(const int deg)
An angle in degree brought in 0 to 359 (Internal usage).
Definition math.h:1448
float __jo_fixed_to_float(const jo_fixed x)
Convert jo engine fixed to float at run time (Internal usage, see jo_fixed2float()).
float jo_vectorf_dot(const jo_vectorf *const a, const jo_vectorf *const b)
Get the dot product of 2 vectors (using floating numbers).
unsigned int jo_sqrt(unsigned int value)
Fast square root.
jo_angle jo_atan2_fixed(const jo_fixed y, const jo_fixed x)
ATAN2 as a jo_angle without floating point (fixed numbers).
static __jo_force_inline jo_fixed jo_fixed_div_result(void)
Get the result of the division started by jo_fixed_div_start().
Definition math.h:796
static __jo_force_inline void jo_matrixf_translation(const jo_vectorf *const offset, jo_matrixf *const result)
Creates translation matrix (using floating numbers).
Definition math.h:1845
static __jo_force_inline float jo_cosf_mult(const float value, const int deg)
Fast cosinus multiplication.
Definition math.h:1276
void jo_vectorf_compute_bezier_point(const float t, jo_vectorf p0, jo_vectorf p1, jo_vectorf p2, jo_vectorf p3, jo_vectorf *result)
Compute cubic bezier curve point for vectors (using floating numbers).
void jo_vectorf_subs(const jo_vectorf *const a, const float s, jo_vectorf *const result)
Subtract value to vector (using floating numbers).
float jo_rsqrt(float value)
Fast Reciprocal Square root using floating number.
#define JO_FIXED_PI_DIV_180
Fixed value of PI/180.
Definition math.h:451
void jo_vector_fixed_normalize(const jo_vector_fixed *const a, jo_vector_fixed *const result)
Normalize a vector (using fixed numbers).
static __jo_force_inline jo_fixed __jo_angle_to_fixed_rad(const jo_angle angle)
Convert jo_angle to fixed radian (Internal usage).
Definition math.h:622
void jo_vectorf_adds(const jo_vectorf *const a, const float s, jo_vectorf *const result)
Add value to vector (using floating numbers).
static __jo_force_inline jo_fixed __jo_fixed_dot4(const jo_fixed ptA[4], const jo_fixed ptB[4])
Dot product of 2 vectors of 4 fixed numbers (Internal usage).
Definition math.h:2035
static __jo_force_inline float jo_sin_radf(const float rad)
Sinus computation.
Definition math.h:1163
static __jo_force_inline void jo_matrixf_rotation_y_rad(const float angle_in_rad, jo_matrixf *const result)
Creates rotating matrix (Y axis) (using floating numbers).
Definition math.h:1936
float jo_vectorf_length(const jo_vectorf *const a)
Get the length of a vector (using floating numbers).
static __jo_force_inline float jo_sinf(const int deg)
Sinus computation.
Definition math.h:1143
int jo_random(int max)
Get a random number.
static __jo_force_inline int jo_atan2f(const float y, const float x)
Fast ATAN2 computation in degree.
Definition math.h:1405
static __jo_force_inline void jo_matrix_mul_vector4(const jo_matrix *const m, const jo_vector4_fixed *const v, jo_vector4_fixed *const result)
Multiply a matrix by a vector4 (using fixed numbers).
Definition math.h:2066
static __jo_force_inline int jo_random_seeded(unsigned int *const seed)
Get a random number of a sequence of its own (the effects of a game: the same at each run,...
Definition math.h:877
static __jo_force_inline void jo_vector_fixed_sub(const jo_vector_fixed *const a, const jo_vector_fixed *const b, jo_vector_fixed *const result)
Substract 2 vectors (using fixed numbers).
Definition math.h:1548
static __jo_force_inline unsigned int __jo_float_bits(const float f)
The bits of a float (Internal usage).
Definition math.h:516
static __jo_force_inline jo_fixed jo_fixed_floor(const jo_fixed x)
Returns the largest (fixed) integer value less than or equal to x.
Definition math.h:832
static __jo_force_inline void jo_matrix_translation(const jo_vector_fixed *const offset, jo_matrix *const result)
Creates translation matrix (using fixed numbers).
Definition math.h:1833
static __jo_force_inline jo_fixed jo_fixed_dot(const jo_fixed ptA[3], const jo_fixed ptB[3])
Dot product two fixed 3D points.
Definition math.h:701
int jo_gcd(int a, int b)
Get the greatest common divisor.
static __jo_force_inline int __jo_float_sign(const float x)
The sign of a float, in integers on its bits (Internal usage).
Definition math.h:591
static __jo_force_inline void jo_vector_fixed_cross(const jo_vector_fixed *const a, const jo_vector_fixed *const b, jo_vector_fixed *const result)
Cross product of 2 vectors (using fixed numbers).
Definition math.h:1572
static __jo_force_inline unsigned int jo_highest_bit(unsigned int x)
Index of the highest bit set in a value (31 - number of leading zeros).
Definition math.h:897
static __jo_force_inline void jo_sincos(const int deg, jo_fixed *const sin_value, jo_fixed *const cos_value)
Sinus and cosinus of the same angle in degree (table lookup, fast).
Definition math.h:1225
void jo_matrixf_invert_affine(const jo_matrixf *const matrix, jo_matrixf *const result)
Inverts an affine transformation matrix (using floating numbers).
static __jo_force_inline void jo_sincos_angle(const jo_angle angle, jo_fixed *const sin_value, jo_fixed *const cos_value)
Sinus and cosinus of the same angle (table lookup, fast).
Definition math.h:1090
static __jo_force_inline void jo_matrixf_scaling(const jo_vectorf *const scale, jo_matrixf *const result)
Creates scaling matrix (using floating numbers).
Definition math.h:1869
const jo_fixed __jo_sin_table[1025]
Sinus table: sin(x) for x in [0, pi/2] (1024 steps, Q16.16) (Internal usage, see math....
static __jo_force_inline jo_fixed jo_cos_angle(const jo_angle angle)
Cosinus of an angle (table lookup, fast).
Definition math.h:1079
static __jo_force_inline int jo_turn_toward(const int angle, const int target, const int max_step)
Turn an angle toward another angle, by the shortest way.
Definition math.h:1466
static __jo_force_inline int jo_fixed_mult_to_int(const jo_fixed x, const jo_fixed y)
Multiply to fixed number and keep the integer part: jo_fixed2int(jo_fixed_mult(x, y)),...
Definition math.h:682
float jo_vectorf_angle_between_radf(const jo_vectorf *const a, const jo_vectorf *const b)
Get the angle between 2 vectors (using floating numbers).
static __jo_force_inline jo_angle jo_atan2_angle(const float y, const float x)
ATAN2 as a jo_angle (65536 per turn, like jo_sin_angle() and the rotations of the 3D).
Definition math.h:1417
void jo_matrixf_mul_dir(const jo_matrixf *const matrix, const jo_vectorf *const direction, jo_vectorf *const result)
Multiplies a 4x4 matrix with a 3D vector representing a direction in 3D space (using floating numbers...
void jo_vectorf_div(const jo_vectorf *const a, const jo_vectorf *const b, jo_vectorf *const result)
Divide 2 vectors (using floating numbers).
static __jo_force_inline void jo_matrix_rotation_z_angle(const jo_angle angle, jo_matrix *const result)
Rotation matrix around the Z axis (using fixed numbers).
Definition math.h:1949
static __jo_force_inline float jo_tan_radf(const float rad)
Tangent computation.
Definition math.h:1349
static __jo_force_inline jo_fixed jo_sin_angle(const jo_angle angle)
Sinus of an angle (table lookup, fast).
Definition math.h:1070
void jo_vectorf_mul(const jo_vectorf *const a, const jo_vectorf *const b, jo_vectorf *const result)
Multiply 2 vectors (using floating numbers).
static __jo_force_inline jo_fixed jo_tan(const int deg)
Fast tangent computation.
Definition math.h:1295
static __jo_force_inline void jo_vector4_fixed_sub(const jo_vector4_fixed *const a, const jo_vector4_fixed *const b, jo_vector4_fixed *const result)
Substract 2 vectors4 (using fixed numbers).
Definition math.h:1613
void jo_vectorf_add(const jo_vectorf *const a, const jo_vectorf *const b, jo_vectorf *const result)
Add 2 vectors (using floating numbers).
static __jo_force_inline void jo_vector4_fixed_add(const jo_vector4_fixed *const a, const jo_vector4_fixed *const b, jo_vector4_fixed *const result)
Add 2 vectors4 (using fixed numbers).
Definition math.h:1599
static __jo_force_inline jo_angle jo_fixed_deg2ANGLE(const jo_fixed deg)
Convert fixed degree to jo_angle.
Definition math.h:1103
void jo_vectorf_muls(const jo_vectorf *const a, const float s, jo_vectorf *const result)
Multiply value to vector (using floating numbers).
#define JO_SWAP(A, B)
Swap A and B values.
Definition math.h:324
#define JO_FIXED_TO_INT(X)
Convert jo_fixed to int.
Definition math.h:468
static __jo_force_inline bool jo_square_intersect(const int x1, const int y1, const int w1, const int h1, const int x2, const int y2, const int w2, const int h2)
Fast method to get if two square intersects (HitBox processing).
Definition math.h:2225
int jo_random_seed
Get or set current random seed.
static __jo_force_inline void jo_matrix_rotation_x_angle(const jo_angle angle, jo_matrix *const result)
Rotation matrix around the X axis (using fixed numbers).
Definition math.h:1881
static __jo_force_inline float jo_fixed2float(const jo_fixed x)
Convert jo engine fixed to float.
Definition math.h:573
static __jo_force_inline float jo_acos_radf(const float angle)
Fast Arc Cosinus computation.
Definition math.h:1376
static __jo_force_inline void jo_vector_fixed_add(const jo_vector_fixed *const a, const jo_vector_fixed *const b, jo_vector_fixed *const result)
Add 2 vectors (using fixed numbers).
Definition math.h:1522
static __jo_force_inline int jo_shift_right8_small(const int x)
Arithmetic right shift by 8 bits (x >> 8) of a value in [-2^23, 2^23) (a 16 bits value x 0 to 256 for...
Definition math.h:774
static __jo_force_inline jo_fixed jo_lerp(const jo_fixed v0, const jo_fixed v1, const jo_fixed t)
Linear interpolation which guarantees v = v1 when t = 1.
Definition math.h:2199
static __jo_force_inline void jo_vector_fixed_muls(const jo_vector_fixed *const a, const jo_fixed s, jo_vector_fixed *const result)
Multiply value to vector (using fixed numbers).
Definition math.h:1535
static __jo_force_inline int jo_shift_right8(const int x)
Arithmetic right shift by 8 bits (x >> 8, rounded toward minus infinity) of any value.
Definition math.h:763
static __jo_force_inline float jo_sinf_mult(const float value, const int deg)
Fast sinus multiplication.
Definition math.h:1184
static __jo_force_inline short jo_direction_to_angle(const jo_8_directions direction)
Convert jo_8_directions to angle in degree.
Definition math.h:2252
jo_fixed jo_fixed_rsqrt(jo_fixed value)
Fast Reciprocal Square root using fixed number.
static __jo_force_inline float jo_cos_radf(const float rad)
Cosinus computation.
Definition math.h:1255
static __jo_force_inline void jo_matrix_rotation_y_angle(const jo_angle angle, jo_matrix *const result)
Rotation matrix around the Y axis (using fixed numbers).
Definition math.h:1915
jo_fixed jo_fixed_pow(jo_fixed x, jo_fixed y)
x raised to the power of the integer part of y
static __jo_force_inline jo_fixed jo_tan_rad(const float rad)
Tangent computation.
Definition math.h:1335
static __jo_force_inline jo_fixed jo_fixed_rad2deg(const jo_fixed rad)
Convert fixed radian to fixed degree.
Definition math.h:814
void jo_matrixf_mul_pos(const jo_matrixf *const matrix, const jo_vectorf *const position, jo_vectorf *const result)
Multiplies a 4x4 matrix with a 3D vector representing a point in 3D space (using floating numbers).
static __jo_force_inline jo_fixed jo_float2fixed(const float x)
Convert float to jo engine fixed (avoid usage of GCC Soft Float).
Definition math.h:561
static __jo_force_inline int jo_random_using_multiple(int max, int multiple)
Get a random number with a specific multiple.
Definition math.h:864
static __jo_force_inline void jo_vector4_swap(jo_vector4_fixed *const a, jo_vector4_fixed *const b)
Swap 2 vectors4 (using fixed numbers).
Definition math.h:1649
static __jo_force_inline int jo_fixed2int(const jo_fixed x)
Convert jo engine fixed to int.
Definition math.h:501
jo_fixed jo_fixed_sqrt(jo_fixed value)
Fast Square root using fixed number.
void jo_matrixf_mul(const jo_matrixf *const a, const jo_matrixf *const b, jo_matrixf *const result)
Multiply 2 matrix (using floating numbers).
void jo_matrixf_ortho(const float left, const float right, const float bottom, const float top, const float back, const float front, jo_matrixf *const result)
Creates an orthographic projection matrix (using floating numbers).
static __jo_force_inline float jo_cosf(const int deg)
Cosinus computation.
Definition math.h:1235
#define JO_FIXED_360
Fixed floating point value for 360.
Definition math.h:434
static __jo_force_inline jo_fixed jo_cos_rad(const float rad)
Cosinus computation.
Definition math.h:1245
static __jo_force_inline void jo_matrix_scaling(const jo_vector_fixed *const scale, jo_matrix *const result)
Creates scaling matrix (using fixed numbers).
Definition math.h:1857
static __jo_force_inline jo_fixed jo_fixed_wrap_to_180(jo_fixed deg)
Wrap deg in [-180 180].
Definition math.h:647
static __jo_force_inline void jo_matrix_transpose(const jo_matrix *const matrix, jo_matrix *const result)
Creates transpose matrix (using fixed numbers).
Definition math.h:1984
#define JO_FIXED_MIN
Fixed floating point value for -32767.99998.
Definition math.h:437
static __jo_force_inline void jo_fixed_div_start(const jo_fixed dividend, const jo_fixed divisor)
Start a fixed-point division in the background (see jo_fixed_div_result()).
Definition math.h:785
static __jo_force_inline jo_fixed jo_fixed_cos(const jo_fixed rad)
Fast cosinus computation using fixed number.
Definition math.h:1204
int jo_atan2_degrees(const jo_fixed y, const jo_fixed x)
ATAN2 in degree without floating point (fixed numbers).
#define JO_INT_TO_FIXED(X)
Convert int to jo_fixed.
Definition math.h:464
#define JO_FIXED_MAX
Fixed floating point value for +32767.99998.
Definition math.h:439
static __jo_force_inline jo_fixed jo_fixed_sin(const jo_fixed rad)
Fast sinus computation using fixed number.
Definition math.h:1123
static __jo_force_inline jo_fixed jo_tan_angle(const jo_angle angle)
Fast tangent of a jo_angle (table lookup and the division unit).
Definition math.h:1309
float __jo_float_scale2(const float x, const int shift)
A float times 2^shift, in integers on its bits (Internal usage).
void jo_vectorf_proj(const jo_vectorf *const v, const jo_vectorf *const onto, jo_vectorf *const result)
Compute projection vector (using floating numbers).
static __jo_force_inline jo_fixed jo_fixed_mult(const jo_fixed x, const jo_fixed y)
Multiply to fixed number.
Definition math.h:671
#define JO_FIXED_180
Fixed floating point value for 180.
Definition math.h:432
static __jo_force_inline int jo_int_div(const int dividend, const int divisor)
Divide 2 integers (dividend / divisor, rounded toward 0 as in C).
Definition math.h:748
static __jo_force_inline void jo_matrixf_rotation_x_rad(const float angle_in_rad, jo_matrixf *const result)
Creates rotating matrix (X axis) (using floating numbers).
Definition math.h:1902
#define JO_FIXED_180_DIV_PI
Fixed value of 180/PI.
Definition math.h:449
static __jo_force_inline void jo_matrixf_identity(jo_matrixf *const result)
Creates the identity matrix (using floating numbers).
Definition math.h:1817
static __jo_force_inline unsigned int __jo_angle_to_sin_index(const jo_angle angle)
Table index of an angle (Internal usage).
Definition math.h:1060
static __jo_force_inline jo_fixed jo_vector4_fixed_dot(const jo_vector4_fixed *const a, const jo_vector4_fixed *const b)
Dot product of 2 vectors4 (using fixed numbers).
Definition math.h:1639
static __jo_force_inline jo_angle jo_fixed_rad2ANGLE(const jo_fixed rad)
Convert fixed radian to jo_angle.
Definition math.h:1031
#define JO_FIXED_PI
Fixed value of PI.
Definition math.h:445
static __jo_force_inline jo_fixed jo_fixed_ceil(const jo_fixed x)
Returns the smallest (fixed) integer value greater than or equal to x.
Definition math.h:823
static __jo_force_inline jo_fixed jo_fixed_deg2rad(const jo_fixed deg)
Convert fixed degree to fixed radian.
Definition math.h:805
jo_angle __jo_atan2_floats(const float y, const float x)
The angle of a vector of 2 floats (Internal usage, see jo_atan2f_rad()).
void jo_vectorf_normalize(const jo_vectorf *const a, jo_vectorf *const result)
Normalize a vector (using floating numbers).
void jo_matrixf_rotation(const float angle_in_rad, const jo_vectorf *const axis, jo_matrixf *const result)
Creates a matrix to rotate around an axis by a given angle in radiant (using floating numbers).
float jo_atan2f_rad(const float y, const float x)
Fast ATAN2 computation in radian.
static __jo_force_inline jo_fixed jo_fixed_wrap_to_pi(jo_fixed rad)
Wrap rad in [−pi pi].
Definition math.h:632
static __jo_force_inline bool jo_is_float_equals_zero(const float f)
Check if float almost equals 0.
Definition math.h:2208
#define JO_FIXED_PI_2
Fixed value of 2 PI.
Definition math.h:447
static __jo_force_inline jo_fixed jo_sin(const int deg)
Fast sinus computation.
Definition math.h:1132
static __jo_force_inline int jo_cos_mult(const int value, const int deg)
Fast cosinus multiplication.
Definition math.h:1266
static __jo_force_inline jo_fixed jo_cos(const int deg)
Fast cosinus computation.
Definition math.h:1213
void jo_matrixf_perspective(const float vertical_field_of_view_in_deg, const float aspect_ratio, const float near_view_distance, const float far_view_distance, jo_matrixf *const result)
Creates a perspective projection matrix for a camera (using floating numbers).
void jo_vectorf_divs(const jo_vectorf *const a, const float s, jo_vectorf *const result)
Divide value to vector (using floating numbers).
void jo_matrixf_look_at(const jo_vectorf *const from, const jo_vectorf *const to, const jo_vectorf *const up, jo_matrixf *const result)
Builds a transformation matrix for a camera (using floating numbers).
int __jo_floats_to_fixed_scaled(const float *const in, jo_fixed *const out, const int count, const int top)
Convert floats to fixed numbers with the same power of 2 for all, in integers (Internal usage).
static __jo_force_inline void jo_matrix_rotation_x_rad(const float angle_in_rad, jo_matrix *const result)
Rotation matrix around the X axis (radian, using floating numbers: converted, then jo_matrix_rotation...
Definition math.h:1893
static __jo_force_inline int jo_sin_mult(const int value, const int deg)
Fast sinus multiplication.
Definition math.h:1174
jo_fixed __jo_float_to_fixed(const float x)
Convert float to jo engine fixed at run time (Internal usage, see jo_float2fixed()).
#define JO_FIXED_1_DIV
Fixed value of 1/65536.
Definition math.h:459
static __jo_force_inline float jo_sqrtf(float value)
Fast Square root using floating number.
Definition math.h:946
static __jo_force_inline void jo_matrix_identity(jo_matrix *const result)
Creates the identity matrix (using fixed numbers).
Definition math.h:1802
#define JO_FIXED_1
Fixed floating point value for 1.
Definition math.h:414
static __jo_force_inline float jo_tanf(const float deg)
Tangent computation.
Definition math.h:1325
static __jo_force_inline jo_fixed jo_fixed_div(const jo_fixed dividend, const jo_fixed divisor)
Divide fixed-point numbers (expresses dividend / divisor).
Definition math.h:730
jo_fixed __jo_acos_fixed_rad(jo_fixed cosinus)
Arc cosinus in fixed numbers (Internal usage, see jo_acos_radf()).
static __jo_force_inline jo_fixed jo_vector_fixed_dot(const jo_vector_fixed *const a, const jo_vector_fixed *const b)
Dot product of 2 vectors (using fixed numbers).
Definition math.h:1561
#define JO_ZERO(X)
Set a variable to zero.
Definition math.h:240
#define JO_SH2_DVDNTL
Division unit: dividend register low (64 bits division, writing starts the division,...
Definition sega_saturn.h:629
#define JO_SH2_DVDNT
Division unit: dividend register (32 bits division).
Definition sega_saturn.h:625
#define JO_SH2_DVSR
Division unit: divisor register.
Definition sega_saturn.h:623
#define JO_SH2_DVDNTH
Division unit: dividend register high (64 bits division).
Definition sega_saturn.h:627
float y
Definition types.h:150
jo_fixed w
Definition types.h:183
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39
short jo_angle
Angle.
Definition types.h:65
float x
Definition types.h:149
float z
Definition types.h:151
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59
jo_8_directions
8 directions definition
Definition types.h:326
@ DOWN_LEFT
Definition types.h:334
@ DOWN_RIGHT
Definition types.h:335
@ UP_RIGHT
Definition types.h:333
@ DOWN
Definition types.h:331
@ UP_LEFT
Definition types.h:332
@ UP
Definition types.h:330
@ LEFT
Definition types.h:328
@ RIGHT
Definition types.h:329
2D position
Definition types.h:69
Vector4 for 3D computation using fixed number.
Definition types.h:181
Vector for 3D computation using fixed number.
Definition types.h:166
Vector for 3D computation using floating numbers.
Definition types.h:148
4x4 MATRIX for 3D computation using fixed number
Definition types.h:202
jo_fixed table[16]
Definition types.h:204
jo_fixed m[4][4]
Definition types.h:203
4x4 MATRIX for 3D computation using floating numbers
Definition types.h:188
float table[16]
Definition types.h:190