celery 8 Posted August 30, 2007 So what's the formula or command to turn a vectordir array into degrees? Share this post Link to post Share on other sites
fasad 1 Posted August 30, 2007 edit^2 : getDir? (sorry, got assignment to finish, acos/asin method will need more work than I can give it right now...) Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 30, 2007 Are you talking about a 2-dimensional vector or 3-dimensional vector (like vector dirs)? For flat 2 dimensions, you can try something like this: fnCalcAzimuth.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Desc: Calculate Azimuth between 2 (objects) positions _posA = _this select 0; _posB = _this select 1; _Cx = _posA select 0; _Cy = _posA select 1; _Kx = _posB select 0; _Ky = _posB select 1; _dx = -(_Cx - _Kx); _dy = -(_Cy - _Ky); // Result is: -180 < Azimuth <= 180 _Azimuth = round(_dx atan2 _dy); // adjust to compass angle: 0 <= Azimuth < 360 if (_Azimuth < 0) then { _Azimuth = 360+_Azimuth; }; _Azimuth; // Result Share this post Link to post Share on other sites
celery 8 Posted August 30, 2007 Thank you, that was what I was looking for! But I have another problem regarding the use of this. My very limited brain capacity can't solve how to detect when the player's azimuth is matching another one in a limited arc. So that the player should be facing a certain direction inside a 90 degree arc, but the 360 degree scale is giving trouble when the arc crosses both ends. Share this post Link to post Share on other sites
thy_ 151 Posted March 6, 2023 On 8/29/2007 at 9:31 PM, celery said: So what's the formula or command to turn a vectordir array into degrees? If someone need set a vehicle in the same direction of another object/marker but without use (brute force) setDir, here: "This function sets the tracked vehicle in the same direction as the hold-marker set by the mission editor": Share this post Link to post Share on other sites