Skip to content

Commit

Permalink
Merge pull request #767 from Neviothr/nev-vectors-cleanup
Browse files Browse the repository at this point in the history
Vectors cleanup
  • Loading branch information
Killswitch00 committed Oct 25, 2017
2 parents 62e38fb + 6b23fea commit fd62c89
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 26 deletions.
7 changes: 2 additions & 5 deletions addons/vectors/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
class Extended_PreInit_EventHandlers
{
class ADDON
{
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

8 changes: 4 additions & 4 deletions addons/vectors/fnc_polar2vect.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Parameters:
_elev the elevation of the vector to create
Returns:
a vector in the form [x,z,y].
a vector in the form [x, z, y].
Examples:
(begin example)
Expand All @@ -25,7 +25,7 @@ scriptName "fnc_polar2vect.sqf";
#include "script_component.hpp"
SCRIPT(polar2vect);

params ["_mag","_dir","_elev"];
params ["_mag", "_dir", "_elev"];

private _magCosElev = _mag * cos(_elev);
[_magCosElev * sin(_dir), _magCosElev * cos(_dir), _mag * sin(_elev)];
private _magCosElev = _mag * cos (_elev);
[_magCosElev * sin (_dir), _magCosElev * cos (_dir), _mag * sin (_elev)];
2 changes: 1 addition & 1 deletion addons/vectors/fnc_scaleVect.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ scriptName "fnc_scaleVect.sqf";
#include "script_component.hpp"
SCRIPT(scaleVect);

params ["_vect","_factor"];
params ["_vect", "_factor"];

_vect vectorMultiply _factor;
2 changes: 1 addition & 1 deletion addons/vectors/fnc_scaleVectTo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ scriptName "fnc_scaleVectTo.sqf";
#include "script_component.hpp"
SCRIPT(scaleVectTo);

params ["_vect","_newMagn"];
params ["_vect", "_newMagn"];

(vectorNormalized _vect) vectorMultiply _newMagn
4 changes: 2 additions & 2 deletions addons/vectors/fnc_vect2polar.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ scriptName "fnc_vect2Polar.sqf";
SCRIPT(vect2Polar);


params ["_vx","_vy","_vz"];
params ["_vx", "_vy", "_vz"];

private _mag = vectorMagnitude _this;
private _elev = if (_mag > 0) then { asin (_vz / _mag) } else { 0 };
private _elev = if (_mag > 0) then {asin (_vz / _mag)} else {0};
private _dir = _this call CBA_fnc_vectDir;

[_mag, _dir, _elev];
2 changes: 1 addition & 1 deletion addons/vectors/fnc_vectCross2D.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ scriptName "fnc_vectCross2D.sqf";
#include "script_component.hpp"
SCRIPT(vectCross2D);

params ["_u","_v"];
params ["_u", "_v"];

((_u select 0) * (_v select 1)) - ((_u select 1) * (_v select 0));
2 changes: 1 addition & 1 deletion addons/vectors/fnc_vectDir.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description:
Returns the angle of a vector with the given i and k coordinates in the range 0 to 360.
Parameters:
_vect the 2D vector array in the form [x,z] or [x,z,y] (y value is ignored).
_vect the 2D vector array in the form [x, z] or [x, z, y] (y value is ignored).
Returns:
the corresponding angle in range 0 to 360.
Expand Down
4 changes: 2 additions & 2 deletions addons/vectors/fnc_vectElev.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description:
Returns the angle of elevation of a 3D vector with the given i, j and k coordinates in the range -90 to 90.
Parameters:
_vect the 3D vector in the form [i,k,j].
_vect the 3D vector in the form [i, k, j].
Returns:
the corresponding angle of elevation in range -90 to 90.
Expand All @@ -24,7 +24,7 @@ scriptName "fnc_vectElev.sqf";
SCRIPT(vectElev);


params ["_pos1","_pos2"];
params ["_pos1", "_pos2"];

private _dist2D = (_this) call CBA_fnc_vectMagn2D;

Expand Down
2 changes: 1 addition & 1 deletion addons/vectors/fnc_vectMagn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description:
Returns the magnitude of a 3D vector with the given i, j and k coordinates.
Parameters:
_vect a 3D vector [i,k,j]
_vect a 3D vector [i, k, j]
Returns:
the magnitude of the vector.
Expand Down
2 changes: 1 addition & 1 deletion addons/vectors/fnc_vectMagn2D.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ scriptName "fnc_vectMagn2D.sqf";
#include "script_component.hpp"
SCRIPT(vectMagn2D);

sqrt((_this select 0)^2 + (_this select 1)^2)
sqrt ((_this select 0) ^ 2 + (_this select 1) ^ 2)
8 changes: 4 additions & 4 deletions addons/vectors/fnc_vectRotate2D.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Author:

#include "script_component.hpp"

params ["_center","_vector","_angle"];
_center params ["_x","_y"];
params ["_center", "_vector", "_angle"];
_center params ["_x", "_y"];


private _dx = _x - (_vector select 0);
private _dy = _y - (_vector select 1);

[
_x - ((_dx* cos(_angle)) - (_dy* sin(_angle))),
_y - ((_dx* sin(_angle)) + (_dy* cos(_angle)))
_x - ((_dx * cos (_angle)) - (_dy * sin (_angle))),
_y - ((_dx * sin (_angle)) + (_dy * cos (_angle)))
]
2 changes: 1 addition & 1 deletion addons/vectors/fnc_vectSubtract.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ scriptName "fnc_vectSubtract.sqf";
SCRIPT(vectSubtract);


params ["_u","_v"];
params ["_u", "_v"];

private _i = (_u select 0) - (_v select 0);
private _k = (_u select 1) - (_v select 1);
Expand Down
1 change: 0 additions & 1 deletion addons/vectors/script_component.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#define COMPONENT vectors
#include "\x\cba\addons\main\script_mod.hpp"


#ifdef DEBUG_ENABLED_VECTORS
#define DEBUG_MODE_FULL
#endif
Expand Down
2 changes: 1 addition & 1 deletion addons/vectors/test_vectors.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,4 @@ _result = _temp call CBA_fnc_polar2vect;
TEST_TRUE([ARR_2(_result,_expected)] call _fnc_vectorEquals, "complex polar 2");


nil;
nil;

0 comments on commit fd62c89

Please sign in to comment.