Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
math.h File Reference

Jo Engine Math tools. More...

Go to the source code of this file.

Macros

#define JO_PI
 PI value.
#define JO_PI_2
 PI/2 value.
#define JO_MULT_BY_2(X)
 Multiply a variable by 2.
#define JO_MULT_BY_4(X)
 Multiply a variable by 4.
#define JO_MULT_BY_8(X)
 Multiply a variable by 8.
#define JO_MULT_BY_16(X)
 Multiply a variable by 16.
#define JO_MULT_BY_32(X)
 Multiply a variable by 32.
#define JO_MULT_BY_64(X)
 Multiply a variable by 64.
#define JO_MULT_BY_128(X)
 Multiply a variable by 128.
#define JO_MULT_BY_256(X)
 Multiply a variable by 256.
#define JO_MULT_BY_512(X)
 Multiply a variable by 512.
#define JO_MULT_BY_1024(X)
 Multiply a variable by 1024.
#define JO_MULT_BY_2048(X)
 Multiply a variable by 2048.
#define JO_MULT_BY_4096(X)
 Multiply a variable by 4096.
#define JO_MULT_BY_32768(X)
 Multiply a variable by 32768.
#define JO_MULT_BY_65536(X)
 Multiply a variable by 65536.
#define JO_DIV_BY_2(X)
 Devide a variable by 2.
#define JO_DIV_BY_4(X)
 Devide a variable by 4.
#define JO_DIV_BY_8(X)
 Devide a variable by 8.
#define JO_DIV_BY_16(X)
 Devide a variable by 16.
#define JO_DIV_BY_32(X)
 Devide a variable by 32.
#define JO_DIV_BY_64(X)
 Devide a variable by 64.
#define JO_DIV_BY_128(X)
 Devide a variable by 128.
#define JO_DIV_BY_256(X)
 Devide a variable by 256.
#define JO_DIV_BY_512(X)
 Devide a variable by 512.
#define JO_DIV_BY_1024(X)
 Devide a variable by 1024.
#define JO_DIV_BY_32768(X)
 Devide a variable by 32768.
#define JO_DIV_BY_65536(X)
 Devide a variable by 65536.
#define JO_DIV_BY_2147483648(X)
 Devide a variable by 2147483648.
#define JO_ZERO(X)
 Set a variable to zero.
#define JO_MOD_POW2(N, M)
 Fast modulo of a power of 2.
#define JO_IS_POW2(N)
 Fast check if N of a power of 2.
#define JO_ABS(X)
 Get the absolute value of X.
#define JO_FABS(X)
 Get the absolute value of X.
#define JO_MIN(A, B)
 Get the smaller value between A and B.
#define JO_MAX(A, B)
 Get the bigger value between A and B.
#define JO_CHANGE_SIGN(X)
 Change the sign of X.
#define JO_FLOAT_EPSILON
 Float minimum positive value.
#define JO_FLOAT_NEARLY_EQUALS(A, B)
 Check if A and B is nearly the same value.
#define JO_IS_FLOAT_NULL(A)
 Check if A nearly equals zero.
#define JO_RAD_TO_DEG(A)
 Convert radians to degrees.
#define JO_DEG_TO_RAD(A)
 Convert degrees to radians.
#define JO_IS_ODD(A)
 Check if A is odd.
#define JO_SWAP(A, B)
 Swap A and B values.
#define JO_OPAQUE(VAR)
 Hide the value of a variable from the optimizer of the compiler (no instruction).
#define JO_PERCENT_USED(TOTAL, FREE)
 Compute percent ((TOTAL - FREE) x 100 / TOTAL, rounded down).
#define JO_SQUARE(A)
 Square computation (x²).
#define JO_BCD_INT(BCD)
 BCD to integer.
#define JO_SET_FLAGS(BYTEFIELD, FLAGS)
 Set flags in bytefield.
#define JO_SET_ALL_FLAGS(BYTEFIELD)
 Set all flags in bytefield.
#define JO_ADD_FLAG(BYTEFIELD, FLAG)
 Add flag in bytefield.
#define JO_REMOVE_FLAG(BYTEFIELD, FLAG)
 Remove flag in bytefield.
#define JO_REMOVE_ALL_FLAGS(BYTEFIELD)
 Remove all flags in bytefield.
#define JO_HAS_FLAG(BYTEFIELD, FLAG)
 Check if flag is checked in bytefield.
#define JO_FIXED_0
 Fixed floating point value for 0.
#define JO_FIXED_1_DIV_2
 Fixed floating point value for 0.5.
#define JO_FIXED_ALMOST_1
 Fixed floating point value for 0.999.
#define JO_FIXED_1
 Fixed floating point value for 1.
#define JO_FIXED_2
 Fixed floating point value for 2.
#define JO_FIXED_3
 Fixed floating point value for 3.
#define JO_FIXED_4
 Fixed floating point value for 4.
#define JO_FIXED_8
 Fixed floating point value for 8.
#define JO_FIXED_16
 Fixed floating point value for 16.
#define JO_FIXED_32
 Fixed floating point value for 32.
#define JO_FIXED_120
 Fixed floating point value for 120.
#define JO_FIXED_150
 Fixed floating point value for 150.
#define JO_FIXED_180
 Fixed floating point value for 180.
#define JO_FIXED_360
 Fixed floating point value for 360.
#define JO_FIXED_MIN
 Fixed floating point value for -32767.99998.
#define JO_FIXED_MAX
 Fixed floating point value for +32767.99998.
#define JO_FIXED_EPSILON
 Jo Fixed minimum positive value.
#define JO_FIXED_OVERFLOW
 Indicate an overflow error.
#define JO_FIXED_PI
 Fixed value of PI.
#define JO_FIXED_PI_2
 Fixed value of 2 PI.
#define JO_FIXED_180_DIV_PI
 Fixed value of 180/PI.
#define JO_FIXED_PI_DIV_180
 Fixed value of PI/180.
#define JO_FIXED_PI_DIV_2
 Fixed value of PI/2.
#define JO_FIXED_PI_OVER_2
 Fixed value of PI/2.
#define JO_FIXED_3_PI_OVER_2
 Fixed value of 3 PI / 2.
#define JO_FIXED_1_DIV
 Fixed value of 1/65536.
#define JO_INT_TO_FIXED(X)
 Convert int to jo_fixed.
#define JO_FIXED_TO_INT(X)
 Convert jo_fixed to int.
#define JO_FIXED_DECIMAL_MASK
 Decimal part mask of a jo_fixed.
#define JO_FLOAT_TO_FIXED(X)
 Convert a float to jo_fixed.
#define JO_DEG_TO_ANGLE(X)
 Convert a degree to jo_angle.
#define JO_RAD_TO_ANGLE(X)
 Convert a radian to jo_angle.
#define __JO_DEG_TO_ANGLE_MAGIC
 See https://github.com/johannes-fetz/joengine/issues/42.

Functions

static __jo_force_inline jo_fixed jo_int2fixed (const int x)
 Convert int to jo engine fixed.
static __jo_force_inline int jo_fixed2int (const jo_fixed x)
 Convert jo engine fixed to int.
static __jo_force_inline jo_fixed jo_float2fixed (const float x)
 Convert float to jo engine fixed (avoid usage of GCC Soft Float).
static __jo_force_inline float jo_fixed2float (const jo_fixed x)
 Convert jo engine fixed to float.
static __jo_force_inline jo_fixed jo_fixed_wrap_to_pi (jo_fixed rad)
 Wrap rad in [−pi pi].
static __jo_force_inline jo_fixed jo_fixed_wrap_to_180 (jo_fixed deg)
 Wrap deg in [-180 180].
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_fixed_mult (const jo_fixed x, const jo_fixed y)
 Multiply to fixed number.
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)), without overflow.
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.
static __jo_force_inline jo_fixed jo_fixed_div (const jo_fixed dividend, const jo_fixed divisor)
 Divide fixed-point numbers (expresses dividend / divisor).
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).
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.
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 example).
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()).
static __jo_force_inline jo_fixed jo_fixed_div_result (void)
 Get the result of the division started by jo_fixed_div_start().
static __jo_force_inline jo_fixed jo_fixed_deg2rad (const jo_fixed deg)
 Convert fixed degree to fixed radian.
static __jo_force_inline jo_fixed jo_fixed_rad2deg (const jo_fixed rad)
 Convert fixed radian to fixed degree.
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.
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.
int jo_random (int max)
 Get a random number.
static __jo_force_inline int jo_random_using_multiple (int max, int multiple)
 Get a random number with a specific multiple.
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).
jo_fixed jo_fixed_sqrt (jo_fixed value)
 Fast Square root using fixed number.
unsigned int jo_sqrt (unsigned int value)
 Fast square root.
static __jo_force_inline float jo_sqrtf (float value)
 Fast Square root using floating number.
jo_fixed jo_fixed_rsqrt (jo_fixed value)
 Fast Reciprocal Square root using fixed number.
float jo_rsqrt (float value)
 Fast Reciprocal Square root using floating number.
static __jo_force_inline jo_angle jo_DEGtoANG (const float deg)
 Convert a degree to jo_angle using floating number.
static __jo_force_inline jo_angle jo_DEGtoANG_int (const int deg)
 Convert a degree to jo_angle using interger.
static __jo_force_inline jo_angle jo_fixed_rad2ANGLE (const jo_fixed rad)
 Convert fixed radian to jo_angle.
static __jo_force_inline jo_fixed __jo_sin_index (const unsigned int index)
 Sinus of a table index (Internal usage).
static __jo_force_inline unsigned int __jo_angle_to_sin_index (const jo_angle angle)
 Table index of an angle (Internal usage).
static __jo_force_inline jo_fixed jo_sin_angle (const jo_angle angle)
 Sinus of an angle (table lookup, fast).
static __jo_force_inline jo_fixed jo_cos_angle (const jo_angle angle)
 Cosinus of an angle (table lookup, fast).
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).
static __jo_force_inline jo_angle jo_fixed_deg2ANGLE (const jo_fixed deg)
 Convert fixed degree to jo_angle.
static __jo_force_inline jo_fixed jo_fixed_sin (const jo_fixed rad)
 Fast sinus computation using fixed number.
static __jo_force_inline jo_fixed jo_sin (const int deg)
 Fast sinus computation.
static __jo_force_inline float jo_sinf (const int deg)
 Sinus computation.
static __jo_force_inline jo_fixed jo_sin_rad (const float rad)
 Sinus computation.
static __jo_force_inline float jo_sin_radf (const float rad)
 Sinus computation.
static __jo_force_inline int jo_sin_mult (const int value, const int deg)
 Fast sinus multiplication.
static __jo_force_inline float jo_sinf_mult (const float value, const int deg)
 Fast sinus multiplication.
static __jo_force_inline jo_fixed jo_fixed_cos (const jo_fixed rad)
 Fast cosinus computation using fixed number.
static __jo_force_inline jo_fixed jo_cos (const int deg)
 Fast cosinus computation.
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).
static __jo_force_inline float jo_cosf (const int deg)
 Cosinus computation.
static __jo_force_inline jo_fixed jo_cos_rad (const float rad)
 Cosinus computation.
static __jo_force_inline float jo_cos_radf (const float rad)
 Cosinus computation.
static __jo_force_inline int jo_cos_mult (const int value, const int deg)
 Fast cosinus multiplication.
static __jo_force_inline float jo_cosf_mult (const float value, const int deg)
 Fast cosinus multiplication.
static __jo_force_inline jo_fixed jo_tan (const int deg)
 Fast tangent computation.
static __jo_force_inline float jo_tanf (const float deg)
 Tangent computation.
static __jo_force_inline jo_fixed jo_tan_rad (const float rad)
 Tangent computation.
static __jo_force_inline float jo_tan_radf (const float rad)
 Tangent computation.
static __jo_force_inline float jo_acos_radf (const float angle)
 Fast Arc Cosinus computation (linear approximation).
float jo_atan2f_rad (const float y, const float x)
 Fast ATAN2 computation in radian.
static __jo_force_inline int jo_atan2f (const float y, const float x)
 Fast ATAN2 computation in degree.
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).
jo_angle jo_atan2_fixed (const jo_fixed y, const jo_fixed x)
 ATAN2 as a jo_angle without floating point (fixed numbers).
int jo_atan2_degrees (const jo_fixed y, const jo_fixed x)
 ATAN2 in degree without floating point (fixed numbers).
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.
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 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).
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).
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).
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).
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).
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).
static __jo_force_inline void jo_vector4_swap (jo_vector4_fixed *const a, jo_vector4_fixed *const b)
 Swap 2 vectors4 (using fixed numbers).
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).
static __jo_force_inline 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_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 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_vectorf_subs (const jo_vectorf *const a, const float s, jo_vectorf *const result)
 Subtract value to vector (using floating numbers).
static __jo_force_inline 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 void jo_vectorf_muls (const jo_vectorf *const a, const float s, jo_vectorf *const result)
 Multiply value to vector (using floating numbers).
static __jo_force_inline 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_vectorf_divs (const jo_vectorf *const a, const float s, jo_vectorf *const result)
 Divide value to vector (using floating numbers).
static __jo_force_inline float jo_vectorf_length (const jo_vectorf *const a)
 Get the length of a vector (using floating numbers).
static __jo_force_inline float jo_vectorf_dot (const jo_vectorf *const a, const jo_vectorf *const b)
 Get the dot product of 2 vectors (using floating numbers).
static __jo_force_inline void jo_vectorf_normalize (const jo_vectorf *const a, jo_vectorf *const result)
 Normalize a vector (using floating numbers).
static __jo_force_inline 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 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 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 void jo_matrix_identity (jo_matrix *const result)
 Creates the identity matrix (using fixed numbers).
static __jo_force_inline void jo_matrixf_identity (jo_matrixf *const result)
 Creates the identity matrix (using floating numbers).
static __jo_force_inline void jo_matrix_translation (const jo_vector_fixed *const offset, jo_matrix *const result)
 Creates translation matrix (using fixed numbers).
static __jo_force_inline void jo_matrixf_translation (const jo_vectorf *const offset, jo_matrixf *const result)
 Creates translation matrix (using floating numbers).
static __jo_force_inline void jo_matrix_scaling (const jo_vector_fixed *const scale, jo_matrix *const result)
 Creates scaling matrix (using fixed numbers).
static __jo_force_inline void jo_matrixf_scaling (const jo_vectorf *const scale, jo_matrixf *const result)
 Creates scaling matrix (using floating numbers).
static __jo_force_inline void jo_matrix_rotation_x_rad (const float angle_in_rad, jo_matrix *const result)
 Creates rotating matrix (X axis) (using fixed numbers).
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).
static __jo_force_inline void jo_matrix_rotation_y_rad (const float angle_in_rad, jo_matrix *const result)
 Creates rotating matrix (Y axis) (using fixed numbers).
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).
static __jo_force_inline void jo_matrix_rotation_z_rad (const float angle_in_rad, jo_matrix *const result)
 Creates rotating matrix (Z axis) (using fixed numbers).
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).
static __jo_force_inline void jo_matrix_transpose (const jo_matrix *const matrix, jo_matrix *const result)
 Creates transpose matrix (using fixed numbers).
static __jo_force_inline void jo_matrixf_transpose (const jo_matrixf *const matrix, jo_matrixf *const result)
 Creates transpose matrix (using floating numbers).
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).
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).
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).
static __jo_force_inline void jo_matrixf_mul (const jo_matrixf *const a, const jo_matrixf *const b, jo_matrixf *const result)
 Multiply 2 matrix (using floating numbers).
static __jo_force_inline 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).
static __jo_force_inline 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 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).
static __jo_force_inline 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).
static __jo_force_inline 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_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 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).
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.
static __jo_force_inline bool jo_is_float_equals_zero (const float f)
 Check if float almost equals 0.
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).
int jo_gcd (int a, int b)
 Get the greatest common divisor.
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 short jo_direction_to_angle (const jo_8_directions direction)
 Convert jo_8_directions to angle in degree.

Variables

int jo_random_seed
 Get or set current random seed.
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.c).

Detailed Description

Jo Engine Math tools.

Author
Johannes Fetz
Bug
Possible issue with jo_sin() and jo_cos() with some angle.

Macro Definition Documentation

◆ __JO_DEG_TO_ANGLE_MAGIC

#define __JO_DEG_TO_ANGLE_MAGIC

◆ JO_ABS

#define JO_ABS ( X)

Get the absolute value of X.

Parameters
XVariable name

◆ JO_ADD_FLAG

#define JO_ADD_FLAG ( BYTEFIELD,
FLAG )

Add flag in bytefield.

Parameters
BYTEFIELDBytefield
FLAGFlag

◆ JO_BCD_INT

#define JO_BCD_INT ( BCD)

BCD to integer.

Parameters
BCDBCD

◆ JO_CHANGE_SIGN

#define JO_CHANGE_SIGN ( X)

Change the sign of X.

Parameters
XVariable name

◆ JO_DEG_TO_ANGLE

#define JO_DEG_TO_ANGLE ( X)

Convert a degree to jo_angle.

Parameters
XDegree (constant expression friendly, usable in static initializers)

◆ JO_DEG_TO_RAD

#define JO_DEG_TO_RAD ( A)

Convert degrees to radians.

Parameters
Aoperand

◆ JO_DIV_BY_1024

#define JO_DIV_BY_1024 ( X)

Devide a variable by 1024.

Remarks
faster than X / 1024
Parameters
XVariable name

◆ JO_DIV_BY_128

#define JO_DIV_BY_128 ( X)

Devide a variable by 128.

Remarks
faster than X / 128
Parameters
XVariable name

◆ JO_DIV_BY_16

#define JO_DIV_BY_16 ( X)

Devide a variable by 16.

Remarks
faster than X / 16
Parameters
XVariable name

◆ JO_DIV_BY_2

#define JO_DIV_BY_2 ( X)

Devide a variable by 2.

Remarks
faster than X / 2
Parameters
XVariable name

◆ JO_DIV_BY_2147483648

#define JO_DIV_BY_2147483648 ( X)

Devide a variable by 2147483648.

Remarks
faster than X / 2147483648
Parameters
XVariable name

◆ JO_DIV_BY_256

#define JO_DIV_BY_256 ( X)

Devide a variable by 256.

Remarks
faster than X / 256
Parameters
XVariable name

◆ JO_DIV_BY_32

#define JO_DIV_BY_32 ( X)

Devide a variable by 32.

Remarks
faster than X / 32
Parameters
XVariable name

◆ JO_DIV_BY_32768

#define JO_DIV_BY_32768 ( X)

Devide a variable by 32768.

Remarks
faster than X / 32768
Parameters
XVariable name

◆ JO_DIV_BY_4

#define JO_DIV_BY_4 ( X)

Devide a variable by 4.

Remarks
faster than X / 4
Parameters
XVariable name

◆ JO_DIV_BY_512

#define JO_DIV_BY_512 ( X)

Devide a variable by 512.

Remarks
faster than X / 512
Parameters
XVariable name

◆ JO_DIV_BY_64

#define JO_DIV_BY_64 ( X)

Devide a variable by 64.

Remarks
faster than X / 64
Parameters
XVariable name

◆ JO_DIV_BY_65536

#define JO_DIV_BY_65536 ( X)

Devide a variable by 65536.

Remarks
faster than X / 65536
Parameters
XVariable name

◆ JO_DIV_BY_8

#define JO_DIV_BY_8 ( X)

Devide a variable by 8.

Remarks
faster than X / 8
Parameters
XVariable name

◆ JO_FABS

#define JO_FABS ( X)

Get the absolute value of X.

Parameters
XVariable name

◆ JO_FIXED_0

#define JO_FIXED_0

Fixed floating point value for 0.

◆ JO_FIXED_1

#define JO_FIXED_1

Fixed floating point value for 1.

◆ JO_FIXED_120

#define JO_FIXED_120

Fixed floating point value for 120.

◆ JO_FIXED_150

#define JO_FIXED_150

Fixed floating point value for 150.

◆ JO_FIXED_16

#define JO_FIXED_16

Fixed floating point value for 16.

◆ JO_FIXED_180

#define JO_FIXED_180

Fixed floating point value for 180.

◆ JO_FIXED_180_DIV_PI

#define JO_FIXED_180_DIV_PI

Fixed value of 180/PI.

◆ JO_FIXED_1_DIV

#define JO_FIXED_1_DIV

Fixed value of 1/65536.

◆ JO_FIXED_1_DIV_2

#define JO_FIXED_1_DIV_2

Fixed floating point value for 0.5.

◆ JO_FIXED_2

#define JO_FIXED_2

Fixed floating point value for 2.

◆ JO_FIXED_3

#define JO_FIXED_3

Fixed floating point value for 3.

◆ JO_FIXED_32

#define JO_FIXED_32

Fixed floating point value for 32.

◆ JO_FIXED_360

#define JO_FIXED_360

Fixed floating point value for 360.

◆ JO_FIXED_3_PI_OVER_2

#define JO_FIXED_3_PI_OVER_2

Fixed value of 3 PI / 2.

◆ JO_FIXED_4

#define JO_FIXED_4

Fixed floating point value for 4.

◆ JO_FIXED_8

#define JO_FIXED_8

Fixed floating point value for 8.

◆ JO_FIXED_ALMOST_1

#define JO_FIXED_ALMOST_1

Fixed floating point value for 0.999.

◆ JO_FIXED_DECIMAL_MASK

#define JO_FIXED_DECIMAL_MASK

Decimal part mask of a jo_fixed.

◆ JO_FIXED_EPSILON

#define JO_FIXED_EPSILON

Jo Fixed minimum positive value.

◆ JO_FIXED_MAX

#define JO_FIXED_MAX

Fixed floating point value for +32767.99998.

◆ JO_FIXED_MIN

#define JO_FIXED_MIN

Fixed floating point value for -32767.99998.

◆ JO_FIXED_OVERFLOW

#define JO_FIXED_OVERFLOW

Indicate an overflow error.

◆ JO_FIXED_PI

#define JO_FIXED_PI

Fixed value of PI.

◆ JO_FIXED_PI_2

#define JO_FIXED_PI_2

Fixed value of 2 PI.

◆ JO_FIXED_PI_DIV_180

#define JO_FIXED_PI_DIV_180

Fixed value of PI/180.

◆ JO_FIXED_PI_DIV_2

#define JO_FIXED_PI_DIV_2

Fixed value of PI/2.

◆ JO_FIXED_PI_OVER_2

#define JO_FIXED_PI_OVER_2

Fixed value of PI/2.

◆ JO_FIXED_TO_INT

#define JO_FIXED_TO_INT ( X)

Convert jo_fixed to int.

Parameters
Xoperand

◆ JO_FLOAT_EPSILON

#define JO_FLOAT_EPSILON

Float minimum positive value.

◆ JO_FLOAT_NEARLY_EQUALS

#define JO_FLOAT_NEARLY_EQUALS ( A,
B )

Check if A and B is nearly the same value.

Parameters
AFirst operand
BSecond operand

◆ JO_FLOAT_TO_FIXED

#define JO_FLOAT_TO_FIXED ( X)

Convert a float to jo_fixed.

Parameters
XFloat (constant expression friendly, usable in static initializers)

◆ JO_HAS_FLAG

#define JO_HAS_FLAG ( BYTEFIELD,
FLAG )

Check if flag is checked in bytefield.

Parameters
BYTEFIELDBytefield
FLAGFlag

◆ JO_INT_TO_FIXED

#define JO_INT_TO_FIXED ( X)

Convert int to jo_fixed.

Parameters
Xoperand

◆ JO_IS_FLOAT_NULL

#define JO_IS_FLOAT_NULL ( A)

Check if A nearly equals zero.

Parameters
Aoperand

◆ JO_IS_ODD

#define JO_IS_ODD ( A)

Check if A is odd.

Parameters
Aoperand

◆ JO_IS_POW2

#define JO_IS_POW2 ( N)

Fast check if N of a power of 2.

Parameters
NNumber

◆ JO_MAX

#define JO_MAX ( A,
B )

Get the bigger value between A and B.

Parameters
AFirst operand
BSecond operand

◆ JO_MIN

#define JO_MIN ( A,
B )

Get the smaller value between A and B.

Parameters
AFirst operand
BSecond operand

◆ JO_MOD_POW2

#define JO_MOD_POW2 ( N,
M )

Fast modulo of a power of 2.

Remarks
faster than N % M
Parameters
NNumber
MModulo

◆ JO_MULT_BY_1024

#define JO_MULT_BY_1024 ( X)

Multiply a variable by 1024.

Remarks
faster than X * 1024
Parameters
XVariable name

◆ JO_MULT_BY_128

#define JO_MULT_BY_128 ( X)

Multiply a variable by 128.

Remarks
faster than X * 128
Parameters
XVariable name

◆ JO_MULT_BY_16

#define JO_MULT_BY_16 ( X)

Multiply a variable by 16.

Remarks
faster than X * 16
Parameters
XVariable name

◆ JO_MULT_BY_2

#define JO_MULT_BY_2 ( X)

Multiply a variable by 2.

Remarks
faster than X * 2
Parameters
XVariable name

◆ JO_MULT_BY_2048

#define JO_MULT_BY_2048 ( X)

Multiply a variable by 2048.

Remarks
faster than X * 2048
Parameters
XVariable name

◆ JO_MULT_BY_256

#define JO_MULT_BY_256 ( X)

Multiply a variable by 256.

Remarks
faster than X * 256
Parameters
XVariable name

◆ JO_MULT_BY_32

#define JO_MULT_BY_32 ( X)

Multiply a variable by 32.

Remarks
faster than X * 32
Parameters
XVariable name

◆ JO_MULT_BY_32768

#define JO_MULT_BY_32768 ( X)

Multiply a variable by 32768.

Remarks
faster than X * 32768
Parameters
XVariable name

◆ JO_MULT_BY_4

#define JO_MULT_BY_4 ( X)

Multiply a variable by 4.

Remarks
faster than X * 4
Parameters
XVariable name

◆ JO_MULT_BY_4096

#define JO_MULT_BY_4096 ( X)

Multiply a variable by 4096.

Remarks
faster than X * 4096
Parameters
XVariable name

◆ JO_MULT_BY_512

#define JO_MULT_BY_512 ( X)

Multiply a variable by 512.

Remarks
faster than X * 512
Parameters
XVariable name

◆ JO_MULT_BY_64

#define JO_MULT_BY_64 ( X)

Multiply a variable by 64.

Remarks
faster than X * 64
Parameters
XVariable name

◆ JO_MULT_BY_65536

#define JO_MULT_BY_65536 ( X)

Multiply a variable by 65536.

Remarks
faster than X * 65536
Parameters
XVariable name

◆ JO_MULT_BY_8

#define JO_MULT_BY_8 ( X)

Multiply a variable by 8.

Remarks
faster than X * 8
Parameters
XVariable name

◆ JO_OPAQUE

#define JO_OPAQUE ( VAR)

Hide the value of a variable from the optimizer of the compiler (no instruction).

Parameters
VARVariable (in a register)
Remarks
GCC replaces "x != 1 ? y / x : y" by a division in all the cases (y / 1 = y) and a product by a variable power of 2 by a shift by a variable amount: calls of the library of the compiler on the SH-2 (no division instruction, no barrel shifter). The variable hidden in the branch, or before the product, keeps the code written

◆ JO_PERCENT_USED

#define JO_PERCENT_USED ( TOTAL,
FREE )

Compute percent ((TOTAL - FREE) x 100 / TOTAL, rounded down).

Parameters
TOTALTotal (42 949 672 at most, 0: 0 %)
FREEFree
Remarks
Integers: the float version linked the float emulation of the compiler in every program (about 2 KB)

◆ JO_PI

#define JO_PI

PI value.

Remarks
float constant: a double constant made the whole expression use the double precision, even slower than the float on the SH-2 (no FPU, both are computed by libgcc)

◆ JO_PI_2

#define JO_PI_2

PI/2 value.

◆ JO_RAD_TO_ANGLE

#define JO_RAD_TO_ANGLE ( X)

Convert a radian to jo_angle.

Parameters
XRadian (constant expression friendly, usable in static initializers)

◆ JO_RAD_TO_DEG

#define JO_RAD_TO_DEG ( A)

Convert radians to degrees.

Parameters
Aoperand

◆ JO_REMOVE_ALL_FLAGS

#define JO_REMOVE_ALL_FLAGS ( BYTEFIELD)

Remove all flags in bytefield.

Parameters
BYTEFIELDBytefield

◆ JO_REMOVE_FLAG

#define JO_REMOVE_FLAG ( BYTEFIELD,
FLAG )

Remove flag in bytefield.

Parameters
BYTEFIELDBytefield
FLAGFlag

◆ JO_SET_ALL_FLAGS

#define JO_SET_ALL_FLAGS ( BYTEFIELD)

Set all flags in bytefield.

Parameters
BYTEFIELDBytefield

◆ JO_SET_FLAGS

#define JO_SET_FLAGS ( BYTEFIELD,
FLAGS )

Set flags in bytefield.

Parameters
BYTEFIELDBytefield
FLAGSFlags

◆ JO_SQUARE

#define JO_SQUARE ( A)

Square computation (x²).

Parameters
Aoperand

◆ JO_SWAP

#define JO_SWAP ( A,
B )

Swap A and B values.

Parameters
Aoperand
Boperand
Remarks
With a temporary variable: the XOR swap gave 0 when A and B were the same variable

◆ JO_ZERO

#define JO_ZERO ( X)

Set a variable to zero.

Remarks
faster than X = 0
Parameters
XVariable name

Function Documentation

◆ __jo_angle_to_sin_index()

__jo_force_inline unsigned int __jo_angle_to_sin_index ( const jo_angle angle)
static

Table index of an angle (Internal usage).

Parameters
anglejo_angle
Returns
0 to 4095 (4096 steps per turn, rounded to the nearest)

◆ __jo_fixed_dot4()

__jo_force_inline jo_fixed __jo_fixed_dot4 ( const jo_fixed ptA[4],
const jo_fixed ptB[4] )
static

Dot product of 2 vectors of 4 fixed numbers (Internal usage).

Parameters
ptAFirst vector (4 contiguous fixed numbers)
ptBSecond vector (4 contiguous fixed numbers)
Returns
ptA · ptB
Remarks
Sum on 64 bits by the multiply and accumulate unit (mac.l), like jo_fixed_dot()

◆ __jo_sin_index()

__jo_force_inline jo_fixed __jo_sin_index ( const unsigned int index)
static

Sinus of a table index (Internal usage).

Parameters
index0 to 4095 (4096 steps per turn)
Returns
Q16.16 fixed number

◆ jo_acos_radf()

__jo_force_inline float jo_acos_radf ( const float angle)
static

Fast Arc Cosinus computation (linear approximation).

Parameters
angleCosinus (-1 to 1)
Returns
Acos(angle) in radian using floating number: PI for -1, PI/2 for 0, 0 for 1
Warning
Rough: error up to about 0.21 radian (12 degrees)

◆ jo_atan2_angle()

__jo_force_inline jo_angle jo_atan2_angle ( const float y,
const float x )
static

ATAN2 as a jo_angle (65536 per turn, like jo_sin_angle() and the rotations of the 3D).

Parameters
yFirst value
xSecond value
Returns
Angle (-32768 to 32767)
Remarks
Finer than jo_atan2_degrees() (a degree is 182 units of jo_angle): a camera aimed with it does not shake

◆ jo_atan2_degrees()

int jo_atan2_degrees ( const jo_fixed y,
const jo_fixed x )

ATAN2 in degree without floating point (fixed numbers).

Parameters
yFirst value (Q16.16)
xSecond value (Q16.16)
Warning
Y is the first operand (like Math.Atan2() in C#)
Returns
ATAN2(Y, X) in degree, -179 to 180 (0 if x and y are 0). Error: about 1 degree at most (rounded down)
Remarks
Much faster than jo_atan2f() (the SH-2 has no FPU): a division and a polynomial. The heading of a vector (x = cos, z = sin, like jo_cos() / jo_sin()) is jo_atan2_degrees(z, x)

◆ jo_atan2_fixed()

jo_angle jo_atan2_fixed ( const jo_fixed y,
const jo_fixed x )

ATAN2 as a jo_angle without floating point (fixed numbers).

Parameters
yFirst value (Q16.16)
xSecond value (Q16.16)
Warning
Y is the first operand (like Math.Atan2() in C#)
Returns
Angle (-32768 to 32767, 65536 per turn: like jo_atan2_angle()), 0 if x and y are 0
Remarks
Much faster than jo_atan2_angle() (the SH-2 has no FPU: about 100 us against 5 us), exact to one unit: a camera aimed with it does not shake. The heading of a vector (x = cos, z = sin): jo_atan2_fixed(z, x)

◆ jo_atan2f()

__jo_force_inline int jo_atan2f ( const float y,
const float x )
static

Fast ATAN2 computation in degree.

Parameters
yFirst value
xSecond value
Warning
Y is the first operand (like Math.Atan2() in C#)
Returns
ATAN2(Y, X)

◆ jo_atan2f_rad()

float jo_atan2f_rad ( const float y,
const float x )

Fast ATAN2 computation in radian.

Parameters
yFirst value
xSecond value
Warning
Y is the first operand (like Math.Atan2() in C#)
Returns
ATAN2(Y, X)

◆ jo_cos()

__jo_force_inline jo_fixed jo_cos ( const int deg)
static

Fast cosinus computation.

Parameters
degAngle in degree
Returns
Fixed Cos(deg)

◆ jo_cos_angle()

__jo_force_inline jo_fixed jo_cos_angle ( const jo_angle angle)
static

Cosinus of an angle (table lookup, fast).

Parameters
anglejo_angle (0x10000 = 360 degrees, it wraps)
Returns
Q16.16 fixed number

◆ jo_cos_mult()

__jo_force_inline int jo_cos_mult ( const int value,
const int deg )
static

Fast cosinus multiplication.

Parameters
degAngle in degree
valueValue
Returns
value * Cos(deg)
Remarks
64 bits product: value * Cos(deg) overflowed from |value| > 32767

◆ jo_cos_rad()

__jo_force_inline jo_fixed jo_cos_rad ( const float rad)
static

Cosinus computation.

Parameters
radAngle in radian
Returns
Fixed Cos(rad)
Warning
slower than jo_cos() because it use floating point

◆ jo_cos_radf()

__jo_force_inline float jo_cos_radf ( const float rad)
static

Cosinus computation.

Parameters
radAngle in radian
Returns
Cos(rad) using floating number (slow)
Warning
slower than jo_cos_rad() because it use floating point

◆ jo_cosf()

__jo_force_inline float jo_cosf ( const int deg)
static

Cosinus computation.

Parameters
degAngle in degree
Returns
Cos(deg) using floating number (slow)
Warning
slower than jo_cos() because it use floating point

◆ jo_cosf_mult()

__jo_force_inline float jo_cosf_mult ( const float value,
const int deg )
static

Fast cosinus multiplication.

Parameters
degAngle in degree
valueValue
Returns
value * Cos(deg) using floating number (slow)

◆ jo_DEGtoANG()

__jo_force_inline jo_angle jo_DEGtoANG ( const float deg)
static

Convert a degree to jo_angle using floating number.

Parameters
degDegree
Returns
jo_angle

◆ jo_DEGtoANG_int()

__jo_force_inline jo_angle jo_DEGtoANG_int ( const int deg)
static

Convert a degree to jo_angle using interger.

Parameters
degDegree
Returns
jo_angle

◆ jo_direction_to_angle()

__jo_force_inline short jo_direction_to_angle ( const jo_8_directions direction)
static

Convert jo_8_directions to angle in degree.

Parameters
directionDirection
Returns
Angle in degree

◆ jo_fixed2float()

__jo_force_inline float jo_fixed2float ( const jo_fixed x)
static

Convert jo engine fixed to float.

Parameters
xFixed to convert
Returns
Float value

◆ jo_fixed2int()

__jo_force_inline int jo_fixed2int ( const jo_fixed x)
static

Convert jo engine fixed to int.

Parameters
xFixed
Returns
Integer value

◆ jo_fixed_ceil()

__jo_force_inline jo_fixed jo_fixed_ceil ( const jo_fixed x)
static

Returns the smallest (fixed) integer value greater than or equal to x.

Parameters
xFixed value
Returns
Smallest (fixed) integer value greater than or equal to x

◆ jo_fixed_cos()

__jo_force_inline jo_fixed jo_fixed_cos ( const jo_fixed rad)
static

Fast cosinus computation using fixed number.

Parameters
radFixed angle in radian
Returns
Cos(rad)
Remarks
Table lookup (jo_cos_angle())

◆ jo_fixed_deg2ANGLE()

__jo_force_inline jo_angle jo_fixed_deg2ANGLE ( const jo_fixed deg)
static

Convert fixed degree to jo_angle.

Parameters
degJo Engine fixed degree
Returns
jo_angle

◆ jo_fixed_deg2rad()

__jo_force_inline jo_fixed jo_fixed_deg2rad ( const jo_fixed deg)
static

Convert fixed degree to fixed radian.

Parameters
degFixed angle in degree
Returns
Fixed angle in radian

◆ jo_fixed_div()

__jo_force_inline jo_fixed jo_fixed_div ( const jo_fixed dividend,
const jo_fixed divisor )
static

Divide fixed-point numbers (expresses dividend / divisor).

Parameters
dividend(first operand)
divisor(second operand)
Returns
dividend / divisor
Remarks
Uses the SH-2 division unit (64 bits / 32 bits in 39 cycles). The CPU waits automatically for the result.
Warning
The result is undefined if divisor is 0 or if the quotient doesn't fit in a jo_fixed

◆ jo_fixed_div_result()

__jo_force_inline jo_fixed jo_fixed_div_result ( void )
static

Get the result of the division started by jo_fixed_div_start().

Returns
dividend / divisor
Remarks
The CPU waits automatically if the division is not finished

◆ jo_fixed_div_start()

__jo_force_inline void jo_fixed_div_start ( const jo_fixed dividend,
const jo_fixed divisor )
static

Start a fixed-point division in the background (see jo_fixed_div_result()).

Parameters
dividend(first operand)
divisor(second operand)
Remarks
The SH-2 division unit computes the quotient in 39 cycles while the CPU executes other instructions
Warning
Don't start another division before reading the result

◆ jo_fixed_dot()

__jo_force_inline jo_fixed jo_fixed_dot ( const jo_fixed ptA[3],
const jo_fixed ptB[3] )
static

Dot product two fixed 3D points.

Parameters
ptAPoint A (first operand)
ptBPoint B (second operand)
Returns
ptA · ptB
Remarks
The sum is computed on 64 bits by the SH-2 multiply and accumulate unit (mac.l), so only the result must fit in a jo_fixed
It's about twice faster than 3 calls of jo_fixed_mult()

◆ jo_fixed_floor()

__jo_force_inline jo_fixed jo_fixed_floor ( const jo_fixed x)
static

Returns the largest (fixed) integer value less than or equal to x.

Parameters
xFixed value
Returns
largest (fixed) integer value less than or equal to x

◆ jo_fixed_mult()

__jo_force_inline jo_fixed jo_fixed_mult ( const jo_fixed x,
const jo_fixed y )
static

Multiply to fixed number.

Parameters
xFirst operand
ySecond operand
Returns
x * y
Remarks
Compiled as a single SH-2 instruction (dmuls.l) + 3 register moves

◆ jo_fixed_mult_to_int()

__jo_force_inline int jo_fixed_mult_to_int ( const jo_fixed x,
const jo_fixed y )
static

Multiply to fixed number and keep the integer part: jo_fixed2int(jo_fixed_mult(x, y)), without overflow.

Parameters
xFirst operand
ySecond operand
Returns
Integer part of x * y (rounded down)
Remarks
The high word of the 64 bits product (dmuls.l + sts mach): faster than jo_fixed_mult() then a shift

◆ jo_fixed_pow()

jo_fixed jo_fixed_pow ( jo_fixed x,
jo_fixed y )

x raised to the power of the integer part of y

Parameters
xFirst operand
ySecond operand
Returns
x^y

◆ jo_fixed_rad2ANGLE()

__jo_force_inline jo_angle jo_fixed_rad2ANGLE ( const jo_fixed rad)
static

Convert fixed radian to jo_angle.

Parameters
radJo Engine fixed radian
Returns
jo_angle

◆ jo_fixed_rad2deg()

__jo_force_inline jo_fixed jo_fixed_rad2deg ( const jo_fixed rad)
static

Convert fixed radian to fixed degree.

Parameters
radFixed angle in radian
Returns
Fixed angle in degree

◆ jo_fixed_rsqrt()

jo_fixed jo_fixed_rsqrt ( jo_fixed value)

Fast Reciprocal Square root using fixed number.

Parameters
valueValue
Returns
RSqrt(value)

◆ jo_fixed_sin()

__jo_force_inline jo_fixed jo_fixed_sin ( const jo_fixed rad)
static

Fast sinus computation using fixed number.

Parameters
radFixed angle in radian
Returns
Sin(rad)
Remarks
Table lookup (jo_sin_angle())

◆ jo_fixed_sqrt()

jo_fixed jo_fixed_sqrt ( jo_fixed value)

Fast Square root using fixed number.

Parameters
valueValue
Returns
Sqrt(value), rounded down to 1/65536 (JO_FIXED_OVERFLOW if value is negative)
Remarks
A table and one step of Newton's method with the division unit (see jo_sqrt())

◆ jo_fixed_wrap_to_180()

__jo_force_inline jo_fixed jo_fixed_wrap_to_180 ( jo_fixed deg)
static

Wrap deg in [-180 180].

Parameters
degFixed degree
Returns
deg wrapped in [-180 180]

◆ jo_fixed_wrap_to_pi()

__jo_force_inline jo_fixed jo_fixed_wrap_to_pi ( jo_fixed rad)
static

Wrap rad in [−pi pi].

Parameters
radFixed radian
Returns
rad wrapped in [−pi pi]

◆ jo_float2fixed()

__jo_force_inline jo_fixed jo_float2fixed ( const float x)
static

Convert float to jo engine fixed (avoid usage of GCC Soft Float).

Parameters
xFloat to convert
Returns
Fixed value

◆ jo_gcd()

int jo_gcd ( int a,
int b )

Get the greatest common divisor.

Remarks
PGCD in French
Parameters
aFirst value (> 0)
bSecond value (> 0)
Returns
GCD(a, b)

◆ jo_highest_bit()

__jo_force_inline unsigned int jo_highest_bit ( unsigned int x)
static

Index of the highest bit set in a value (31 - number of leading zeros).

Parameters
xValue
Returns
0 to 31 (0 if x is 0 or 1)
Remarks
Binary search in 5 steps: the SH-2 has no instruction for it

◆ jo_int2fixed()

__jo_force_inline jo_fixed jo_int2fixed ( const int x)
static

Convert int to jo engine fixed.

Parameters
xFloat to convert
Returns
Fixed value

◆ jo_int_div()

__jo_force_inline int jo_int_div ( const int dividend,
const int divisor )
static

Divide 2 integers (dividend / divisor, rounded toward 0 as in C).

Parameters
dividend(first operand)
divisor(second operand)
Returns
dividend / divisor
Remarks
Uses the SH-2 division unit (32 bits / 32 bits in 39 cycles): faster than the division of the compiler (___sdivsi3, a routine of the library: about 3 times slower)
Warning
The result is undefined if divisor is 0

◆ jo_is_float_equals_zero()

__jo_force_inline bool jo_is_float_equals_zero ( const float f)
static

Check if float almost equals 0.

Parameters
ffloating point number
Returns
true if the float almost equals 0 otherwise false

◆ jo_lerp()

__jo_force_inline jo_fixed jo_lerp ( const jo_fixed v0,
const jo_fixed v1,
const jo_fixed t )
static

Linear interpolation which guarantees v = v1 when t = 1.

Parameters
v0First value
v1Second value
tT [0, 1]
Returns
Interpolation between two inputs (v0, v1) for a parameter (t) in the closed unit interval [0, 1].

◆ jo_matrix_identity()

__jo_force_inline void jo_matrix_identity ( jo_matrix *const result)
static

Creates the identity matrix (using fixed numbers).

Parameters
resultResult matrix

◆ jo_matrix_mul()

__jo_force_inline void jo_matrix_mul ( const jo_matrix *const a,
const jo_matrix *const b,
jo_matrix *const result )
static

Multiply 2 matrix (using fixed numbers).

Parameters
aFirst matrix
bSecond matrix
resultResult matrix
Warning
a, b and result parameters must not be the same address
Remarks
Each element is a sum of 4 products on 64 bits (mac.l). The sum was a float before: slow (no FPU) and only 24 bits of precision

◆ jo_matrix_mul_vector4()

__jo_force_inline void jo_matrix_mul_vector4 ( const jo_matrix *const m,
const jo_vector4_fixed *const v,
jo_vector4_fixed *const result )
static

Multiply a matrix by a vector4 (using fixed numbers).

Parameters
mMatrix
vVector4
resultResult vector4
Warning
v and result parameters can be the same address

◆ jo_matrix_rotation_x_rad()

__jo_force_inline void jo_matrix_rotation_x_rad ( const float angle_in_rad,
jo_matrix *const result )
static

Creates rotating matrix (X axis) (using fixed numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrix_rotation_y_rad()

__jo_force_inline void jo_matrix_rotation_y_rad ( const float angle_in_rad,
jo_matrix *const result )
static

Creates rotating matrix (Y axis) (using fixed numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrix_rotation_z_rad()

__jo_force_inline void jo_matrix_rotation_z_rad ( const float angle_in_rad,
jo_matrix *const result )
static

Creates rotating matrix (Z axis) (using fixed numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrix_scaling()

__jo_force_inline void jo_matrix_scaling ( const jo_vector_fixed *const scale,
jo_matrix *const result )
static

Creates scaling matrix (using fixed numbers).

Parameters
scaleScale vector
resultResult matrix

◆ jo_matrix_translation()

__jo_force_inline void jo_matrix_translation ( const jo_vector_fixed *const offset,
jo_matrix *const result )
static

Creates translation matrix (using fixed numbers).

Parameters
offsetOffset vector
resultResult matrix

◆ jo_matrix_transpose()

__jo_force_inline void jo_matrix_transpose ( const jo_matrix *const matrix,
jo_matrix *const result )
static

Creates transpose matrix (using fixed numbers).

Parameters
matrixInput matrix
resultResult matrix
Warning
matrix and result parameters must not be the same address

◆ jo_matrixf_identity()

__jo_force_inline void jo_matrixf_identity ( jo_matrixf *const result)
static

Creates the identity matrix (using floating numbers).

Parameters
resultResult matrix

◆ jo_matrixf_invert_affine()

__jo_force_inline void jo_matrixf_invert_affine ( const jo_matrixf *const matrix,
jo_matrixf *const result )
static

Inverts an affine transformation matrix (using floating numbers).

Parameters
matrixMatrix
resultResult matrix

◆ jo_matrixf_look_at()

__jo_force_inline void jo_matrixf_look_at ( const jo_vectorf *const from,
const jo_vectorf *const to,
const jo_vectorf *const up,
jo_matrixf *const result )
static

Builds a transformation matrix for a camera (using floating numbers).

Parameters
fromViewpoint
totarget
upDefines the direction that's upwards for the camera
resultResult matrix

◆ jo_matrixf_mul()

__jo_force_inline void jo_matrixf_mul ( const jo_matrixf *const a,
const jo_matrixf *const b,
jo_matrixf *const result )
static

Multiply 2 matrix (using floating numbers).

Parameters
aFirst matrix
bSecond matrix
resultResult matrix
Warning
a, b and result parameters must not be the same address

◆ jo_matrixf_mul_dir()

__jo_force_inline void jo_matrixf_mul_dir ( const jo_matrixf *const matrix,
const jo_vectorf *const direction,
jo_vectorf *const result )
static

Multiplies a 4x4 matrix with a 3D vector representing a direction in 3D space (using floating numbers).

Parameters
matrixMatrix
directionDirection
resultResult matrix

◆ jo_matrixf_mul_pos()

__jo_force_inline void jo_matrixf_mul_pos ( const jo_matrixf *const matrix,
const jo_vectorf *const position,
jo_vectorf *const result )
static

Multiplies a 4x4 matrix with a 3D vector representing a point in 3D space (using floating numbers).

Parameters
matrixMatrix
positionPosition
resultResult matrix

◆ jo_matrixf_ortho()

__jo_force_inline 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 )
static

Creates an orthographic projection matrix (using floating numbers).

Parameters
leftLeft (Cube)
rightRight (Cube)
bottomBottom (Cube)
topTop (Cube)
backBack (Cube)
frontFront (Cube)
resultResult matrix

◆ jo_matrixf_perspective()

__jo_force_inline 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 )
static

Creates a perspective projection matrix for a camera (using floating numbers).

Parameters
vertical_field_of_view_in_degSpecifies the field of view angle, in degrees, in the y direction.
aspect_ratioSpecifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
near_view_distanceSpecifies the distance from the viewer to the near clipping plane (always positive).
far_view_distanceSpecifies the distance from the viewer to the far clipping plane (always positive).
resultResult matrix
Remarks
Similar to gluPerspective

◆ jo_matrixf_rotation()

__jo_force_inline void jo_matrixf_rotation ( const float angle_in_rad,
const jo_vectorf *const axis,
jo_matrixf *const result )
static

Creates a matrix to rotate around an axis by a given angle in radiant (using floating numbers).

Parameters
angle_in_radAngle in radiant
axisAxis
resultResult matrix

◆ jo_matrixf_rotation_x_rad()

__jo_force_inline void jo_matrixf_rotation_x_rad ( const float angle_in_rad,
jo_matrixf *const result )
static

Creates rotating matrix (X axis) (using floating numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrixf_rotation_y_rad()

__jo_force_inline void jo_matrixf_rotation_y_rad ( const float angle_in_rad,
jo_matrixf *const result )
static

Creates rotating matrix (Y axis) (using floating numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrixf_rotation_z_rad()

__jo_force_inline void jo_matrixf_rotation_z_rad ( const float angle_in_rad,
jo_matrixf *const result )
static

Creates rotating matrix (Z axis) (using floating numbers).

Parameters
angle_in_radAngle in radiant
resultResult matrix

◆ jo_matrixf_scaling()

__jo_force_inline void jo_matrixf_scaling ( const jo_vectorf *const scale,
jo_matrixf *const result )
static

Creates scaling matrix (using floating numbers).

Parameters
scaleScale vector
resultResult matrix

◆ jo_matrixf_translation()

__jo_force_inline void jo_matrixf_translation ( const jo_vectorf *const offset,
jo_matrixf *const result )
static

Creates translation matrix (using floating numbers).

Parameters
offsetOffset vector
resultResult matrix

◆ jo_matrixf_transpose()

__jo_force_inline void jo_matrixf_transpose ( const jo_matrixf *const matrix,
jo_matrixf *const result )
static

Creates transpose matrix (using floating numbers).

Parameters
matrixInput matrix
resultResult matrix
Warning
matrix and result parameters must not be the same address

◆ jo_planar_rotate()

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.

Parameters
pointPoint to rotate
originRotation origin
angleAngle in degrees
resultThe new point coordinate
Remarks
result and point parameters can be the same pointer

◆ jo_random()

int jo_random ( int max)

Get a random number.

Parameters
maxmaximum value
Returns
1 to max
Remarks
Park-Miller generator (16807 * seed mod 2^31 - 1) computed without division (same sequence as before)

◆ jo_random_using_multiple()

__jo_force_inline int jo_random_using_multiple ( int max,
int multiple )
static

Get a random number with a specific multiple.

Parameters
maxmaximum value
multiplemultiple
Returns
A multiple between 1 to max

◆ jo_rsqrt()

float jo_rsqrt ( float value)

Fast Reciprocal Square root using floating number.

Parameters
valueValue
Returns
RSqrt(value)

◆ jo_shift_right8()

__jo_force_inline int jo_shift_right8 ( const int x)
static

Arithmetic right shift by 8 bits (x >> 8, rounded toward minus infinity) of any value.

Parameters
xValue
Returns
x >> 8
Remarks
The SH-2 shifts arithmetically by one bit only: GCC calls a routine of its library (___ashiftrt_r4_8). Here the logical shift (shlr8) of x or of its complement

◆ jo_shift_right8_small()

__jo_force_inline int jo_shift_right8_small ( const int x)
static

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 example).

Parameters
xValue
Returns
x >> 8
Remarks
Without a branch: the logical shift of x + 2^23 (positive), minus 2^15
Warning
The result is wrong out of the range

◆ jo_sin()

__jo_force_inline jo_fixed jo_sin ( const int deg)
static

Fast sinus computation.

Parameters
degAngle in degree
Returns
Fixed Sin(deg)

◆ jo_sin_angle()

__jo_force_inline jo_fixed jo_sin_angle ( const jo_angle angle)
static

Sinus of an angle (table lookup, fast).

Parameters
anglejo_angle (0x10000 = 360 degrees, it wraps: for instance (jo_angle)(degrees * 182) for an angle that grows)
Returns
Q16.16 fixed number
Remarks
Inlined: a table lookup costs less than a function call

◆ jo_sin_mult()

__jo_force_inline int jo_sin_mult ( const int value,
const int deg )
static

Fast sinus multiplication.

Parameters
degAngle in degree
valueValue
Returns
value * Sin(deg)
Remarks
64 bits product: value * Sin(deg) overflowed from |value| > 32767

◆ jo_sin_rad()

__jo_force_inline jo_fixed jo_sin_rad ( const float rad)
static

Sinus computation.

Parameters
radAngle in radian
Returns
Fixed Sin(rad)
Warning
slower than jo_sin() because it use floating point

◆ jo_sin_radf()

__jo_force_inline float jo_sin_radf ( const float rad)
static

Sinus computation.

Parameters
radAngle in radian
Returns
Sin(rad) using floating number (slow)
Warning
slower than jo_sin_rad() because it use floating point

◆ jo_sincos()

__jo_force_inline void jo_sincos ( const int deg,
jo_fixed *const sin_value,
jo_fixed *const cos_value )
static

Sinus and cosinus of the same angle in degree (table lookup, fast).

Parameters
degAngle in degree
sin_valueFixed Sin(deg)
cos_valueFixed Cos(deg)
Remarks
Same values as jo_sin() and jo_cos(), the angle is converted once

◆ jo_sincos_angle()

__jo_force_inline void jo_sincos_angle ( const jo_angle angle,
jo_fixed *const sin_value,
jo_fixed *const cos_value )
static

Sinus and cosinus of the same angle (table lookup, fast).

Parameters
anglejo_angle (0x10000 = 360 degrees, it wraps)
sin_valueSinus (Q16.16 fixed number)
cos_valueCosinus (Q16.16 fixed number)
Remarks
Same values as jo_sin_angle() and jo_cos_angle(), the angle is converted once

◆ jo_sinf()

__jo_force_inline float jo_sinf ( const int deg)
static

Sinus computation.

Parameters
degAngle in degree
Returns
Sin(deg) using floating number (slow)
Warning
slower than jo_sin() because it use floating point

◆ jo_sinf_mult()

__jo_force_inline float jo_sinf_mult ( const float value,
const int deg )
static

Fast sinus multiplication.

Parameters
degAngle in degree
valueValue
Returns
value * Sin(deg) using floating number (slow)

◆ jo_sqrt()

unsigned int jo_sqrt ( unsigned int value)

Fast square root.

Parameters
valueValue
Returns
Integer part of Sqrt(value)
Remarks
A table and one step of Newton's method with the division unit (about 70 cycles)

◆ jo_sqrtf()

__jo_force_inline float jo_sqrtf ( float value)
static

Fast Square root using floating number.

Parameters
valueValue
Returns
Sqrt(value)
Warning
Not precise

◆ jo_square_intersect()

__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 )
static

Fast method to get if two square intersects (HitBox processing).

Parameters
x1Horizontal position of the first square
y1Vertical position of the first square
w1Width of the first square
h1Height of the first square
x2Horizontal position of the second square
y2Vertical position of the second square
w2Width of the second square
h2Height of the second square
Returns
true if squares collides otherwise false

◆ jo_tan()

__jo_force_inline jo_fixed jo_tan ( const int deg)
static

Fast tangent computation.

Parameters
degAngle in degree
Returns
Fixed Tan(deg)

◆ jo_tan_rad()

__jo_force_inline jo_fixed jo_tan_rad ( const float rad)
static

Tangent computation.

Parameters
radAngle in radian
Returns
Fixed Tan(rad)
Warning
slower than jo_tan() because it use floating point

◆ jo_tan_radf()

__jo_force_inline float jo_tan_radf ( const float rad)
static

Tangent computation.

Parameters
radAngle in radian
Returns
Tan(rad) using floating number (slow)
Warning
slower than jo_tan_rad() because it use floating point

◆ jo_tanf()

__jo_force_inline float jo_tanf ( const float deg)
static

Tangent computation.

Parameters
degAngle in degree
Returns
Tan(deg) using floating number (slow)
Warning
slower than jo_tan() because it use floating point

◆ jo_turn_toward()

__jo_force_inline int jo_turn_toward ( const int angle,
const int target,
const int max_step )
static

Turn an angle toward another angle, by the shortest way.

Parameters
angleCurrent angle in degree (0 to 359)
targetTarget angle in degree (any value)
max_stepLargest change in degree (positive)
Returns
New angle in degree (0 to 359)

◆ jo_vector4_fixed_add()

__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 )
static

Add 2 vectors4 (using fixed numbers).

Parameters
aFirst vector4
bSecond vector4
resultoutput vector4
Remarks
You can pass a or b address for result parameter

◆ jo_vector4_fixed_cross()

__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 )
static

Cross product of 2 vectors4 (using fixed numbers).

Parameters
aFirst vector4
bSecond vector4
resultoutput vector4

◆ jo_vector4_fixed_dot()

__jo_force_inline jo_fixed jo_vector4_fixed_dot ( const jo_vector4_fixed *const a,
const jo_vector4_fixed *const b )
static

Dot product of 2 vectors4 (using fixed numbers).

Parameters
aFirst vector4
bSecond vector4
Returns
Dot product

◆ jo_vector4_fixed_sub()

__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 )
static

Substract 2 vectors4 (using fixed numbers).

Parameters
aFirst vector4
bSecond vector4
resultoutput vector4
Remarks
You can pass a or b address for result parameter

◆ jo_vector4_swap()

__jo_force_inline void jo_vector4_swap ( jo_vector4_fixed *const a,
jo_vector4_fixed *const b )
static

Swap 2 vectors4 (using fixed numbers).

Parameters
aFirst vector4
bSecond vector4

◆ jo_vector_fixed_add()

__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 )
static

Add 2 vectors (using fixed numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Remarks
You can pass a or b address for result parameter

◆ jo_vector_fixed_compute_bezier_point()

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).

Parameters
tValue of the function on the curve [0 to JO_FIXED_1]
p0First vector
p1Second vector
p2Third vector
p3Fourth vector
resultoutput vector

◆ jo_vector_fixed_muls()

__jo_force_inline void jo_vector_fixed_muls ( const jo_vector_fixed *const a,
const jo_fixed s,
jo_vector_fixed *const result )
static

Multiply value to vector (using fixed numbers).

Parameters
aVector
sConstant
resultoutput vector
Remarks
You can pass a address for result parameter

◆ jo_vectorf_add()

__jo_force_inline void jo_vectorf_add ( const jo_vectorf *const a,
const jo_vectorf *const b,
jo_vectorf *const result )
static

Add 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Remarks
You can pass a or b address for result parameter

◆ jo_vectorf_adds()

__jo_force_inline void jo_vectorf_adds ( const jo_vectorf *const a,
const float s,
jo_vectorf *const result )
static

Add value to vector (using floating numbers).

Parameters
aVector
sConstant
resultoutput vector
Remarks
You can pass a address for result parameter

◆ jo_vectorf_angle_between_radf()

__jo_force_inline float jo_vectorf_angle_between_radf ( const jo_vectorf *const a,
const jo_vectorf *const b )
static

Get the angle between 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
Returns
Angle in radian using floating numbers

◆ jo_vectorf_compute_bezier_point()

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).

Parameters
tValue of the function on the curve [0.0f to 1.0f]
p0First vector
p1Second vector
p2Third vector
p3Fourth vector
resultoutput vector

◆ jo_vectorf_cross()

__jo_force_inline void jo_vectorf_cross ( const jo_vectorf *const a,
const jo_vectorf *const b,
jo_vectorf *const result )
static

Cross 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Warning
Don't pass a or b address in result parameter

◆ jo_vectorf_div()

__jo_force_inline void jo_vectorf_div ( const jo_vectorf *const a,
const jo_vectorf *const b,
jo_vectorf *const result )
static

Divide 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Remarks
You can pass a or b address for result parameter

◆ jo_vectorf_divs()

__jo_force_inline void jo_vectorf_divs ( const jo_vectorf *const a,
const float s,
jo_vectorf *const result )
static

Divide value to vector (using floating numbers).

Parameters
aVector
sConstant
resultoutput vector
Remarks
You can pass a address for result parameter

◆ jo_vectorf_dot()

__jo_force_inline float jo_vectorf_dot ( const jo_vectorf *const a,
const jo_vectorf *const b )
static

Get the dot product of 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
Returns
a.b

◆ jo_vectorf_length()

__jo_force_inline float jo_vectorf_length ( const jo_vectorf *const a)
static

Get the length of a vector (using floating numbers).

Parameters
aVector
Returns
Vector length

◆ jo_vectorf_mul()

__jo_force_inline void jo_vectorf_mul ( const jo_vectorf *const a,
const jo_vectorf *const b,
jo_vectorf *const result )
static

Multiply 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Remarks
You can pass a or b address for result parameter

◆ jo_vectorf_muls()

__jo_force_inline void jo_vectorf_muls ( const jo_vectorf *const a,
const float s,
jo_vectorf *const result )
static

Multiply value to vector (using floating numbers).

Parameters
aVector
sConstant
resultoutput vector
Remarks
You can pass a address for result parameter

◆ jo_vectorf_normalize()

__jo_force_inline void jo_vectorf_normalize ( const jo_vectorf *const a,
jo_vectorf *const result )
static

Normalize a vector (using floating numbers).

Parameters
aVector
resultoutput vector
Remarks
You can pass a address for result parameter

◆ jo_vectorf_proj()

__jo_force_inline void jo_vectorf_proj ( const jo_vectorf *const v,
const jo_vectorf *const onto,
jo_vectorf *const result )
static

Compute projection vector (using floating numbers).

Parameters
vVector
ontoVector
resultoutput vector

◆ jo_vectorf_sub()

__jo_force_inline void jo_vectorf_sub ( const jo_vectorf *const a,
const jo_vectorf *const b,
jo_vectorf *const result )
static

Subtract 2 vectors (using floating numbers).

Parameters
aFirst vector
bSecond vector
resultoutput vector
Remarks
You can pass a or b address for result parameter

◆ jo_vectorf_subs()

__jo_force_inline void jo_vectorf_subs ( const jo_vectorf *const a,
const float s,
jo_vectorf *const result )
static

Subtract value to vector (using floating numbers).

Parameters
aVector
sConstant
resultoutput vector
Remarks
You can pass a address for result parameter

Variable Documentation

◆ __jo_sin_table

const jo_fixed __jo_sin_table[1025]
extern

Sinus table: sin(x) for x in [0, pi/2] (1024 steps, Q16.16) (Internal usage, see math.c).

◆ jo_random_seed

int jo_random_seed
extern

Get or set current random seed.

Remarks
Set by jo_core_init() from the date. 0 and 2147483647 (2^31 - 1) are replaced by 1 at the next jo_random() (they would give the same number forever)