Jump to content
gc8

Vector creation command

Recommended Posts

Hi

I'm looking for a command that creates a vector but I can't seem to find it from the wiki. I have been using my old vector creation function that looks like this: [_angle, _dist] call getVector; But I would like to replace that with engine command for speed. Anyone know such command?

 

thx!

Share this post


Link to post
Share on other sites

speed in km/h is similar to : 3.6 * (velocityModelSpace _obj select 1)

If you need a 3D vector for _obj:

velocityModelSpace _obj  // [x,y,z] referring to the object, so X and Z near to 0 for a land vehicle.

You can:

velocityModelSpace _obj vectorMultiply 3.6 for results in km/h

 

 

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, pierremgi said:

speed in km/h is similar to : 3.6 * (velocityModelSpace _obj select 1)

If you need a 3D vector for _obj:

velocityModelSpace _obj  // [x,y,z] referring to the object, so X and Z near to 0 for a land vehicle.

You can:

velocityModelSpace _obj vectorMultiply 3.6 for results in km/h

 

 

 

But these commands require object? I want to create vector without object... (just with angle & distance)

Share this post


Link to post
Share on other sites

So, not really a speed of something. Any vector has a coordinate system.
In 2D:

angle (direction from North) and distance is just  [distance * sin direction, distance * cos direction,0]  // so [x,y,0]

 

You understand that in 3D, there is a lack of info (direction angle, distance, elevation angle)

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

So, not really a speed of something.

 

lol no sorry little confusion there , I meant fast command execution

 

4 minutes ago, pierremgi said:

angle (direction from North) and distance is just  [distance * sin direction, distance * cos direction,0]  // so [x,y,0]

 

yep this is what my function does... no engine version for that?

Share this post


Link to post
Share on other sites
14 minutes ago, gc8 said:

 

lol no sorry little confusion there , I meant fast command execution

 

 

yep this is what my function does... no engine version for that?

No, it's basic... and useless most of the time. Arma is more oriented object and 3D.

 

Share this post


Link to post
Share on other sites
14 minutes ago, pierremgi said:

No, it's basic... and useless most of the time. Arma is more oriented object and 3D.

 

 

you have a point there. Guess I could use #define for "inline" solution

Share this post


Link to post
Share on other sites
9 hours ago, pierremgi said:

angle (direction from North) and distance is just  [distance * sin direction, distance * cos direction,0]  // so [x,y,0]

 

9 hours ago, gc8 said:

yep this is what my function does... no engine version for that?

No engine command would be faster anyways... r*cos(theta) and r*sin(theta) are the most simple calculations you can make.

Share this post


Link to post
Share on other sites
7 hours ago, NumbNutsJunior said:

No engine command would be faster anyways... r*cos(theta) and r*sin(theta) are the most simple calculations you can make.

 

I suppose the difference isn't that big but it depends on how many times the code is needed/executed

 

Did some tests (my fn vs no call code):

 

Result:
0.0014 ms

Cycles:
10000/10000

Code:
_length = 100; _angle = 90; [sin _angle * _length,cos _angle * _length]


Result:
0.0041 ms

Cycles:
10000/10000

Code:
[90, 100] call getVector

 

 

 

 

Code of my getVector:

 

private["_angle","_length","_x","_y","_vec"];

_angle = _this select 0;
_length = _this select 1;

_x = sin _angle * _length;
_y = cos _angle * _length;

_vec = [_x,_y];

_vec

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×