Jo Engine  9
Jo Sega Saturn Engine
Macros | Functions | Variables
math.h File Reference

Jo Engine Math tools. More...

Go to the source code of this file.

Macros

#define JO_ZERO(X)
 Set a variable to zero. More...
 
#define JO_FIXED_0
 Fixed floating point value for 0. More...
 
#define JO_FIXED_1
 Fixed floating point value for 1. More...
 
#define JO_FIXED_120
 Fixed floating point value for 120. More...
 
#define JO_FIXED_150
 Fixed floating point value for 150. More...
 
#define JO_FLOAT_EPSILON
 Float minimum positive value. More...
 
#define JO_PI
 PI value. More...
 
#define JO_PI_2
 PI/2 value. More...
 
#define JO_MULT_BY_2(X)
 Multiply a variable by 2. More...
 
#define JO_MULT_BY_4(X)
 Multiply a variable by 4. More...
 
#define JO_MULT_BY_8(X)
 Multiply a variable by 8. More...
 
#define JO_MULT_BY_16(X)
 Multiply a variable by 16. More...
 
#define JO_MULT_BY_32(X)
 Multiply a variable by 32. More...
 
#define JO_MULT_BY_256(X)
 Multiply a variable by 256. More...
 
#define JO_MULT_BY_1024(X)
 Multiply a variable by 1024. More...
 
#define JO_MULT_BY_32768(X)
 Multiply a variable by 32768. More...
 
#define JO_MULT_BY_65536(X)
 Multiply a variable by 65536. More...
 
#define JO_DIV_BY_2(X)
 Devide a variable by 2. More...
 
#define JO_DIV_BY_4(X)
 Devide a variable by 4. More...
 
#define JO_DIV_BY_8(X)
 Devide a variable by 8. More...
 
#define JO_DIV_BY_16(X)
 Devide a variable by 16. More...
 
#define JO_DIV_BY_32(X)
 Devide a variable by 32. More...
 
#define JO_DIV_BY_1024(X)
 Devide a variable by 1024. More...
 
#define JO_DIV_BY_32768(X)
 Devide a variable by 32768. More...
 
#define JO_DIV_BY_65536(X)
 Devide a variable by 65536. More...
 
#define JO_ABS(X)
 Get the absolute value of X. More...
 
#define JO_FABS(X)
 Get the absolute value of X. More...
 
#define JO_MIN(A, B)
 Get the smaller value between A and B. More...
 
#define JO_MAX(A, B)
 Get the bigger value between A and B. More...
 
#define JO_CHANGE_SIGN(X)
 Change the sign of X. More...
 
#define JO_FLOAT_NEARLY_EQUALS(A, B)
 Check if A and B is nearly the same value. More...
 
#define JO_IS_FLOAT_NULL(A)
 Check if A nearly equals zero. More...
 
#define JO_RAD_TO_DEG(A)
 Convert radians to degrees. More...
 
#define JO_DEG_TO_RAD(A)
 Convert degrees to radians. More...
 
#define JO_IS_ODD(A)
 Check if A is odd. More...
 
#define JO_SWAP(A, B)
 Swap A and B values. More...
 
#define JO_PERCENT_USED(TOTAL, FREE)
 Compute percent (100 / TOTAL * (TOTAL - FREE)) More...
 
#define JO_SQUARE(A)
 Square computation (x) More...
 

Functions

static __jo_force_inline int jo_float2fixed (const float x)
 Convert float to jo engine fixed (avoid usage of GCC Soft Float) More...
 
static __jo_force_inline bool jo_is_float_equals_zero (float f)
 Check if float almost equals 0;. More...
 
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) More...
 
int jo_random (int max)
 Get a random number. More...
 
static __jo_force_inline int jo_random_using_multiple (int max, int multiple)
 Get a random number with a specific multiple. More...
 
unsigned int jo_sqrt (unsigned int value)
 Fast square root. More...
 
static __jo_force_inline float jo_sqrtf (float value)
 Fast Square root using floating number. More...
 
static __jo_force_inline int jo_cos (const int angle)
 Fast cosinus computation. More...
 
static __jo_force_inline float jo_cosf (const int angle)
 Cosinus computation. More...
 
static __jo_force_inline int jo_cos_rad (const float angle)
 Cosinus computation. More...
 
static __jo_force_inline float jo_cos_radf (const float angle)
 Cosinus computation. More...
 
static __jo_force_inline int jo_cos_mult (const int value, const int angle)
 Fast cosinus multiplication. More...
 
static __jo_force_inline float jo_cosf_mult (const float value, const int angle)
 Fast cosinus multiplication. More...
 
static __jo_force_inline int jo_sin (const int angle)
 Fast sinus computation. More...
 
static __jo_force_inline float jo_sinf (const int angle)
 Sinus computation. More...
 
static __jo_force_inline int jo_sin_rad (const float angle)
 Sinus computation. More...
 
static __jo_force_inline float jo_sin_radf (const float angle)
 Sinus computation. More...
 
static __jo_force_inline int jo_sin_mult (const int value, const int angle)
 Fast sinus multiplication. More...
 
static __jo_force_inline float jo_sinf_mult (const float value, const int angle)
 Fast sinus multiplication. More...
 
static __jo_force_inline int jo_tan (const int angle)
 Fast tangent computation. More...
 
static __jo_force_inline float jo_tanf (const float angle)
 Tangent computation. More...
 
static __jo_force_inline int jo_tan_rad (const float angle)
 Tangent computation. More...
 
static __jo_force_inline float jo_tan_radf (const float angle)
 Tangent computation. More...
 
static __jo_force_inline float jo_acos_radf (const float angle)
 Fast Arc Cosinus computation. More...
 
float jo_atan2f_rad (const float y, const float x)
 Fast ATAN2 computation in radian. More...
 
static __jo_force_inline int jo_atan2f (const float y, const float x)
 Fast ATAN2 computation in degree. More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
static __jo_force_inline float jo_vectorf_length (const jo_vectorf *const a)
 Get the length of a vector (using floating numbers) More...
 
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) More...
 
static __jo_force_inline void jo_vectorf_normalize (const jo_vectorf *const a, jo_vectorf *const result)
 Normalize a vector (using floating numbers) More...
 
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) More...
 
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) More...
 
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) More...
 
static __jo_force_inline void jo_matrixf_identity (jo_matrixf *const result)
 Creates the identity matrix (using floating numbers) More...
 
static __jo_force_inline void jo_matrixf_translation (const jo_vectorf *const offset, jo_matrixf *const result)
 Creates translation matrix (using floating numbers) More...
 
static __jo_force_inline void jo_matrixf_scaling (const jo_vectorf *const scale, jo_matrixf *const result)
 Creates scaling matrix (using floating numbers) More...
 
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) More...
 
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) More...
 
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) More...
 
static __jo_force_inline void jo_matrixf_transpose (const jo_matrixf *const matrix, jo_matrixf *const result)
 Creates transpose matrix (using floating numbers) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
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) More...
 
int jo_gcd (int a, int b)
 Get the greatest common divisor. More...
 
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. More...
 
static __jo_force_inline short jo_direction_to_angle (const jo_8_directions direction)
 Convert jo_8_directions to angle in degree. More...
 

Variables

int JoCosLookupTable [360]
 Cosinus lookup table (internal engine usage) use jo_cos() instead. More...
 

Detailed Description

Jo Engine Math tools.

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

Macro Definition Documentation

#define JO_ABS (   X)

Get the absolute value of X.

Parameters
XVariable name
#define JO_CHANGE_SIGN (   X)

Change the sign of X.

Parameters
XVariable name
#define JO_DEG_TO_RAD (   A)

Convert degrees to radians.

Parameters
Aoperand
#define JO_DIV_BY_1024 (   X)

Devide a variable by 1024.

Remarks
faster than X / 1024
Parameters
XVariable name
#define JO_DIV_BY_16 (   X)

Devide a variable by 16.

Remarks
faster than X / 16
Parameters
XVariable name
#define JO_DIV_BY_2 (   X)

Devide a variable by 2.

Remarks
faster than X / 2
Parameters
XVariable name
#define JO_DIV_BY_32 (   X)

Devide a variable by 32.

Remarks
faster than X / 32
Parameters
XVariable name
#define JO_DIV_BY_32768 (   X)

Devide a variable by 32768.

Remarks
faster than X / 32768
Parameters
XVariable name
#define JO_DIV_BY_4 (   X)

Devide a variable by 4.

Remarks
faster than X / 4
Parameters
XVariable name
#define JO_DIV_BY_65536 (   X)

Devide a variable by 65536.

Remarks
faster than X / 65536
Parameters
XVariable name
#define JO_DIV_BY_8 (   X)

Devide a variable by 8.

Remarks
faster than X / 8
Parameters
XVariable name
#define JO_FABS (   X)

Get the absolute value of X.

Parameters
XVariable name
#define JO_FIXED_0

Fixed floating point value for 0.

#define JO_FIXED_1

Fixed floating point value for 1.

#define JO_FIXED_120

Fixed floating point value for 120.

#define JO_FIXED_150

Fixed floating point value for 150.

#define JO_FLOAT_EPSILON

Float minimum positive value.

#define JO_FLOAT_NEARLY_EQUALS (   A,
 
)

Check if A and B is nearly the same value.

Parameters
AFirst operand
BSecond operand
#define JO_IS_FLOAT_NULL (   A)

Check if A nearly equals zero.

Parameters
Aoperand
#define JO_IS_ODD (   A)

Check if A is odd.

Parameters
Aoperand
#define JO_MAX (   A,
 
)

Get the bigger value between A and B.

Parameters
AFirst operand
BSecond operand
#define JO_MIN (   A,
 
)

Get the smaller value between A and B.

Parameters
AFirst operand
BSecond operand
#define JO_MULT_BY_1024 (   X)

Multiply a variable by 1024.

Remarks
faster than X * 1024
Parameters
XVariable name
#define JO_MULT_BY_16 (   X)

Multiply a variable by 16.

Remarks
faster than X * 16
Parameters
XVariable name
#define JO_MULT_BY_2 (   X)

Multiply a variable by 2.

Remarks
faster than X * 2
Parameters
XVariable name
#define JO_MULT_BY_256 (   X)

Multiply a variable by 256.

Remarks
faster than X * 256
Parameters
XVariable name
#define JO_MULT_BY_32 (   X)

Multiply a variable by 32.

Remarks
faster than X * 32
Parameters
XVariable name
#define JO_MULT_BY_32768 (   X)

Multiply a variable by 32768.

Remarks
faster than X * 32768
Parameters
XVariable name
#define JO_MULT_BY_4 (   X)

Multiply a variable by 4.

Remarks
faster than X * 4
Parameters
XVariable name
#define JO_MULT_BY_65536 (   X)

Multiply a variable by 65536.

Remarks
faster than X * 65536
Parameters
XVariable name
#define JO_MULT_BY_8 (   X)

Multiply a variable by 8.

Remarks
faster than X * 8
Parameters
XVariable name
#define JO_PERCENT_USED (   TOTAL,
  FREE 
)

Compute percent (100 / TOTAL * (TOTAL - FREE))

Parameters
TOTALTotal
FREEFree
#define JO_PI

PI value.

#define JO_PI_2

PI/2 value.

#define JO_RAD_TO_DEG (   A)

Convert radians to degrees.

Parameters
Aoperand
#define JO_SQUARE (   A)

Square computation (x)

Parameters
Aoperand
#define JO_SWAP (   A,
 
)

Swap A and B values.

Parameters
Aoperand
Boperand
#define JO_ZERO (   X)

Set a variable to zero.

Remarks
faster than X = 0
Parameters
XVariable name

Function Documentation

static __jo_force_inline float jo_acos_radf ( const float  angle)
static

Fast Arc Cosinus computation.

Parameters
angleAngle in radian
Returns
Acos(angle) using floating number
static __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)
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)
static __jo_force_inline int jo_cos ( const int  angle)
static

Fast cosinus computation.

Parameters
angleAngle in degree
Returns
Cos(angle) * 32768
static __jo_force_inline int jo_cos_mult ( const int  value,
const int  angle 
)
static

Fast cosinus multiplication.

Parameters
angleAngle in degree
valueValue
Returns
value * Cos(angle)
static __jo_force_inline int jo_cos_rad ( const float  angle)
static

Cosinus computation.

Parameters
angleAngle in radian
Returns
Cos(angle) * 32768
Warning
slower than jo_cos() because it use floating point
static __jo_force_inline float jo_cos_radf ( const float  angle)
static

Cosinus computation.

Parameters
angleAngle in radian
Returns
Cos(angle) using floating number (slow)
Warning
slower than jo_cos_rad() because it use floating point
static __jo_force_inline float jo_cosf ( const int  angle)
static

Cosinus computation.

Parameters
angleAngle in degree
Returns
Cos(angle) using floating number (slow)
Warning
slower than jo_cos() because it use floating point
static __jo_force_inline float jo_cosf_mult ( const float  value,
const int  angle 
)
static

Fast cosinus multiplication.

Parameters
angleAngle in degree
valueValue
Returns
value * Cos(angle) using floating number (slow)
static __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
static __jo_force_inline int 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 (int)(x * 32768.0f)
Remarks
result and point parameters can be the same pointer
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)
static __jo_force_inline bool jo_is_float_equals_zero ( float  f)
static

Check if float almost equals 0;.

Parameters
ffloating point number
Returns
true if the float almost equals 0 otherwise false
static __jo_force_inline void jo_matrixf_identity ( jo_matrixf *const  result)
static

Creates the identity matrix (using floating numbers)

Parameters
resultResult matrix
static __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
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 
)
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
static __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
static __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
static __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
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 
)
static

Creates an orthographic projection matrix (using floating numbers)

Parameters
leftLeft (Cube)
rightRight (Cube)
bottomBottom (Cube)
topTop (Cube)
backBack (Cube)
frontFront (Cube)
resultResult matrix
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 
)
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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
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
int jo_random ( int  max)

Get a random number.

Parameters
maxmaximum value
Returns
1 to max
static __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
static __jo_force_inline int jo_sin ( const int  angle)
static

Fast sinus computation.

Parameters
angleAngle in degree
Returns
Sin(angle) * 32768
static __jo_force_inline int jo_sin_mult ( const int  value,
const int  angle 
)
static

Fast sinus multiplication.

Parameters
angleAngle in degree
valueValue
Returns
value * Sin(angle)
static __jo_force_inline int jo_sin_rad ( const float  angle)
static

Sinus computation.

Parameters
angleAngle in radian
Returns
Sin(angle) * 32768
Warning
slower than jo_sin() because it use floating point
static __jo_force_inline float jo_sin_radf ( const float  angle)
static

Sinus computation.

Parameters
angleAngle in radian
Returns
Sin(angle) using floating number (slow)
Warning
slower than jo_sin_rad() because it use floating point
static __jo_force_inline float jo_sinf ( const int  angle)
static

Sinus computation.

Parameters
angleAngle in degree
Returns
Sin(angle) using floating number (slow)
Warning
slower than jo_sin() because it use floating point
static __jo_force_inline float jo_sinf_mult ( const float  value,
const int  angle 
)
static

Fast sinus multiplication.

Parameters
angleAngle in degree
valueValue
Returns
value * Sin(angle) using floating number (slow)
unsigned int jo_sqrt ( unsigned int  value)

Fast square root.

Parameters
valueValue
Returns
Sqrt(value)
static __jo_force_inline float jo_sqrtf ( float  value)
static

Fast Square root using floating number.

Parameters
valueValue
Returns
Sqrt(value)
Warning
Not precise
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 
)
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
static __jo_force_inline int jo_tan ( const int  angle)
static

Fast tangent computation.

Parameters
angleAngle in degree
Returns
Tan(angle) * 32768
static __jo_force_inline int jo_tan_rad ( const float  angle)
static

Tangent computation.

Parameters
angleAngle in radian
Returns
Tan(angle) * 32768
Warning
slower than jo_tan() because it use floating point
static __jo_force_inline float jo_tan_radf ( const float  angle)
static

Tangent computation.

Parameters
angleAngle in radian
Returns
Tan(angle) using floating number (slow)
Warning
slower than jo_tan_rad() because it use floating point
static __jo_force_inline float jo_tanf ( const float  angle)
static

Tangent computation.

Parameters
angleAngle in degree
Returns
Tan(angle) using floating number (slow)
Warning
slower than jo_tan() because it use floating point
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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
static __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

int JoCosLookupTable[360]

Cosinus lookup table (internal engine usage) use jo_cos() instead.

Warning
MC Hammer: don't touch this