/* ShipWars Universe Math */ #ifndef UNVMATH_H #define UNVMATH_H #include #include "objects.h" typedef struct _sw_units_struct sw_units_struct; /* * Units: */ struct _sw_units_struct { float ru_to_au; /* SW real units to * astronomical units */ }; /* Conversion */ extern float RADTODEG(const float radians); extern float DEGTORAD(const float degrees); extern float SANITIZERADIANS(const float radians); extern float SANITIZEDEGREES(const float degrees); extern float SWConvertRUToAU(sw_units_struct *units, const float x); extern float SWConvertRUToKM(sw_units_struct *units, const float x); extern float SWConvertRUToMiles(sw_units_struct *units, const float x); extern float SWConvertRUToKiloMiles(sw_units_struct *units, const float x); extern float SWConvertRUToLY(sw_units_struct *units, const float x); extern float SWConvertRUToParsecs(sw_units_struct *units, const float x); extern float SWConvertRUToMP(sw_units_struct *units, const float x); extern float SWConvertRUToSU(sw_units_struct *units, const float x); extern float SWConvertRUPerCycleToRUPerSecond( sw_units_struct *units, const float x ); extern float SWConvertRUPerCycleToAUPerSecond( sw_units_struct *units, const float x ); extern float SWConvertRUPerCycleToKMPerSecond( sw_units_struct *units, const float x ); extern float SWConvertRUPerCycleToMilesPerSecond( sw_units_struct *units, const float x ); extern float SWConvertRUPerCycleToKiloMilesPerSecond( sw_units_struct *units, const float x ); extern float SWConvertRUPerCycleToMPPerSecond( sw_units_struct *units, const float x ); /* Polar To Coordinate Conversion */ extern float SWMathRectangularToPolarX(const float theta, const float r); extern float SWMathRectangularToPolarY(const float theta, const float r); /* Vector Unitlization */ extern void SWMathSetUnitVector2D( sw_vector_compoent_struct *v, const float bearing ); extern void SWMathSetUnitVector3D( sw_vector_compoent_struct *v, const float bearing, const float pitch ); /* Angle & Vector Calculations */ extern float SWMathAngleDelta(const float theta_to, const float theta_cur); extern void SWMathVectorAdd( const float v1_dir, const float v1_mag, const float v2_dir, const float v2_mag, float *v_dir_rtn, float *v_mag_rtn ); extern float SWMathCoordinateDeltaVector(const float dx, const float dy); /* 3D Distance */ extern float SWMath3DDistance( const float dx, const float dy, const float dz ); /* Sector Checking */ extern int SWMath3DInSectorPtr( xsw_object_struct *obj_ptr, const long sect_x, const long sect_y, const long sect_z ); extern int SWMath3DInSameSector( xsw_object_struct **xsw_object, const int total_objects, const int obj_num1, const int obj_num2 ); extern int SWMath3DInSameSectorPtr( xsw_object_struct *obj1, xsw_object_struct *obj2 ); /* Spherical Contact */ extern int SWMath3DInContact( xsw_object_struct **xsw_object, const int total_objects, const int obj_num1, const int obj_num2 ); extern int SWMath3DInContactPtr( xsw_object_struct *obj1, xsw_object_struct *obj2 ); /* Vector Contact */ extern int SWMath3DInVectorContact( xsw_object_struct **xsw_object, const int total_objects, const int obj_num1, const int obj_num2, const float heading, /* Object 1 to object 2 */ const float heading_variance, const float range /* In screen units */ ); /* Range Contact */ extern int SWMath3DInRange( xsw_object_struct **xsw_object, const int total_objects, const int obj_num1, const int obj_num2, const float distance /* In real units */ ); extern int SWMath3DInRangePtr( xsw_object_struct *obj, xsw_object_struct *tar_obj, const float distance /* In real units */ ); /* Maximum range by velocity and time */ extern float SWMathMaxRangeByVelocity(const float v_max, const time_t t_ms); #endif /* UNVMATH_H */