vectorDir: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " +" to " ")
m (Text replacement - "killzone_kid" to "Killzone_Kid")
 
(43 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma1
|game1= ofpe
|version1= 1.00


|1.00
|game2= arma1
|version2= 1.00
 
|game3= arma2
|version3= 1.00
 
|game4= arma2oa
|version4= 1.50
 
|game5= tkoh
|version5= 1.00
 
|game6= arma3
|version6= 0.50


|arg= global
|arg= global
Line 9: Line 23:
|gr2= Math - Vectors
|gr2= Math - Vectors


| Returns object's normalized direction vector in world space (<tt>[x,y,z]</tt>).  
|descr= [[File:arma3_object-vectors.jpg|thumb|right|An object with its [[vectorDir]], [[vectorUp]] and [[vectorSide]] (vectors not to scale)]]
* A unit facing North would return <tt>[0,1,0]</tt>
Returns an object's direction vector in world space.
* A unit facing East would return <tt>[1,0,0]</tt>
* A unit facing South would return <tt>[0,-1,0]</tt>
* A unit facing West would return <tt>[-1,0,0]</tt>


|[[vectorDir]] object
{{Feature|important|The vector is '''not necessarily [[vectorNormalized|normalized]]'''. The [[vectorMagnitude|magnitude]] of the vector depends on the [[getObjectScale|object's scale]].}}
 
For an object facing one of the cardinal directions on perfectly flat ground (parallel to the XY-plane of the world space), [[vectorDir]] returns simple values:
* {{hl|[0, 1, 0]}} if the object is facing directly north
* {{hl|[1, 0, 0]}} if the object is facing directly east
* {{hl|[0, -1, 0]}} if the object is facing directly south
* {{hl|[-1, 0, 0]}} if the object is facing directly west
 
|s1= [[vectorDir]] object


|p1= object: [[Object]]
|p1= object: [[Object]]


| [[Array]] - format [[Vector3D]]
|r1= [[Array]] format [[Vector3D]]


|x1= <code>_dirVector = [[vectorDir]] _unit;</code>
|x1= <sqf>_vecDir = vectorDir MyObject;</sqf>


|seealso= [[vectorModelToWorld]], [[vectorDirVisual]], [[vectorUp]], [[setVectorDir]], [[setVectorUp]], [[setVectorDirAndUp]], [[vectorDiff]], [[vectorAdd]], [[vectorMultiply]], [[vectorCrossProduct]], [[vectorDistance]], [[vectorMagnitudeSqr]], [[vectorDistanceSqr]], [[vectorCos]], [[vectorMagnitude]], [[vectorDotProduct]], [[vectorNormalized]], [[vectorFromTo]], [[BIS_fnc_transformVectorDirAndUp]]
|seealso= [[vectorModelToWorld]] [[vectorDirVisual]] [[vectorSide]] [[vectorSideVisual]] [[vectorUp]] [[setVectorDir]] [[setVectorUp]] [[setVectorDirAndUp]] [[vectorDiff]] [[vectorAdd]] [[vectorMultiply]] [[vectorCrossProduct]] [[vectorDistance]] [[vectorMagnitudeSqr]] [[vectorDistanceSqr]] [[vectorCos]] [[vectorMagnitude]] [[vectorDotProduct]] [[vectorNormalized]] [[vectorFromTo]] [[BIS_fnc_transformVectorDirAndUp]]
}}
}}




{{GameCategory|ofpe|Scripting Commands}}
<dl class="command_description">
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}


<dl class="command_description">
<dt></dt>
<dt></dt>
<dd class="notedate">Posted on February 2, 2019 - 01:03 (UTC)</dd>
<dd class="notedate">Posted on 2019-02-02 - 01:03 (UTC)</dd>
<dt class="note">[[User:killzone_kid|killzone_kid]]</dt>
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
<dd class="note"> vectorDir 2D: <code><nowiki>[</nowiki>[[sin]] _azimuth, [[cos]] _azimuth, 0]</code>
<dd class="note"> vectorDir 2D:
vectorDir 3D: <code><nowiki>[</nowiki>[[sin]] _azimuth * [[cos]] _altitude, [[cos]] _azimuth * [[cos]] _altitude, [[sin]] _altitude]</code>
<sqf>[sin _azimuth, cos _azimuth, 0]</sqf>
vectorDir 3D:
<sqf>[sin _azimuth * cos _altitude, cos _azimuth * cos _altitude, sin _altitude]</sqf>
</dd>
</dd>
</dl>
</dl>

Latest revision as of 18:52, 18 February 2024

Hover & click on the images for description

Description

Description:
An object with its vectorDir, vectorUp and vectorSide (vectors not to scale)

Returns an object's direction vector in world space.

The vector is not necessarily normalized. The magnitude of the vector depends on the object's scale.

For an object facing one of the cardinal directions on perfectly flat ground (parallel to the XY-plane of the world space), vectorDir returns simple values:

  • [0, 1, 0] if the object is facing directly north
  • [1, 0, 0] if the object is facing directly east
  • [0, -1, 0] if the object is facing directly south
  • [-1, 0, 0] if the object is facing directly west
Groups:
Math - Vectors

Syntax

Syntax:
vectorDir object
Parameters:
object: Object
Return Value:
Array format Vector3D

Examples

Example 1:
_vecDir = vectorDir MyObject;

Additional Information

See also:
vectorModelToWorld vectorDirVisual vectorSide vectorSideVisual vectorUp setVectorDir setVectorUp setVectorDirAndUp vectorDiff vectorAdd vectorMultiply vectorCrossProduct vectorDistance vectorMagnitudeSqr vectorDistanceSqr vectorCos vectorMagnitude vectorDotProduct vectorNormalized vectorFromTo BIS_fnc_transformVectorDirAndUp

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note


Posted on 2019-02-02 - 01:03 (UTC)
Killzone_Kid
vectorDir 2D:
[sin _azimuth, cos _azimuth, 0]
vectorDir 3D:
[sin _azimuth * cos _altitude, cos _azimuth * cos _altitude, sin _altitude]