# SetVectorUp, SetVectorDir and 3D coords

## Recommended Posts

Hi,

I'm trying to make sense of two new commands, setVectorUp and setVectorDir. These commands should allow us to change the pitch and bank of objects. However it's not turning out to as simple as I had hoped for.

I didn't take long to realise there was something a bit more complex than say, velocity vectors. I got to thinking it might be based on 3D transformations? But I know next to nothing about proper 3D maths, so I'm left blindly stabbing around in the dark.

The only thing I did managed to do, was rotate a vehicle using setVectorDir.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Aircraft=_This Select 0;

_Aircraft SetFuel 0;

_Pos=GetPos _Aircraft;

_Pos Set [2,7];

_Inc=0;

WaitUntil

Â  Â Â  {

Â  Â  Â _Inc=_Inc+0.1;

Â  Â  Â _Aircraft SetPos _Pos;

Â  Â  Â _Aircraft SetVectorDir [Sin _Inc,Cos _Inc,0];

Â  Â  Â  Hint Format ["Up : \n%1\n\nDir :\n%2\n\nInc :\n%3",VectorUp _Aircraft,VectorDir _Aircraft,_Inc];

Â  Â  Â  };

Hardly an achievement, seen as you can already do this with setDir in a loop. But getting some sort of sensible reaction out of these commands is a milestone for me.

Just to give you another example, I tried the same idea with setVectorUp:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Aircraft=_This Select 0;

_Aircraft SetFuel 0;

_Pos=GetPos _Aircraft;

_Pos Set [2,7];

_Inc=0;

WaitUntil

Â  Â  Â {

Â  Â  Â _Inc=_Inc+0.1;

Â  Â  Â _Aircraft SetPos _Pos;

Â  Â  Â _Aircraft SetVectorUp [Sin _Inc,Cos _Inc,0];

Â  Â  Â  Hint Format ["Up : \n%1\n\nDir :\n%2\n\nInc :\n%3",VectorUp _Aircraft,VectorDir _Aircraft,_Inc];

Â  Â  Â  };

It still rotates, but as you can see, it's now fixed in a 90 degree bank? I've tried as many combinations of Sin, Cos e.t.c As I can think of, but so far, standard rotation is all I can work out.

Just wondered if anyone else has tried this out, or perhaps knows more about the parameters these commands use?

If not, there is always the hope that a maths whiz Â will come along to throw some light on this.

##### Share on other sites

The principle is, the terms x,z,y do represent three orthogonal vectors (axis) in 3D space.

The ratio from the length of the x,z,y axis-vectors do yield another vector, determining azimut and elevation from an object.

Here, x points to east, z points to north and y points upwards.

For example, choose a barrel and apply:

[1,0.001,0.001] the barrel points to east with no elevation

[0.001,1,0.001] the barrel points to north with no elevation

[0.001,0.001,1] the barrel points upwards

[0.001,0.001,-1] the barrel points downwards

[1,1,0.001] the barrel points to north-east (you see it's tangent behind it : ratio 1/1 is 45 deg)

Do not use 0.0 but instead small values like 0.001 to prevent divide by zero errors.

SetVectorUp is useful to let objects point in any spatial direction.

For more stepping in, read chapter 3.3.4 of my wrp objects tutorial in the wrpedit wiki branch

##### Share on other sites

Cheers, that sounds like just the thing I was looking for. I will give it a go tomorrow.

##### Share on other sites

It does not appear to be as simple as that. These two lines work, as per my original post:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[1,0.001,0.001] the barrel points to east with no elevation

[0.001,1,0.001] the barrel points to north with no elevation

The rest don't. I've got a little further, but creating smooth rotations around a pre-defined axis will take some more effort.

Cheers

##### Share on other sites

Hi there,

while playing around with SetVectorDir and SetVectorUp I noticed that unlike the BIKI states,SetVectorDir actually resets SetVectorUp sometimes.There are also problems involved with cos,sin since when they should give back 0 they give back -0 or 1.2E-19 most of the time,which fucks up the vector quite a bit.

Another problem is that SetVectorDir is only able to rotate the Forward axis counter-clockwise to the world-up-axis [0,0,1] which causes some unwanted results (The model looking the wrong way).

Another problem is that if you want to set a UpVector that is in the same direction as the current forwards vector(same plane) sometimes ArmA refuse to set the UpVector and force the forward vector to a new direction.

Following are two crappy functions I made to test this stuff.

1.[obj,Pitch-Angle,Bank-Angle] call fSetPitchBank

Basically you have to imagine a sphere(radius=1) and the 2 angles define where the vector points to.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

fSetPitchBank = {

_obj = _this select 0;

_p = _this select 1;

_b = _this select 2;

_obj setVectorUp [0,0.001,0.999];

_obj setVectorDir [0,0.999,0.001];

_vx = (sin _b)*(cos _p);

_vz = -(sin _p);

_vy = (cos _b)*(cos _p);

_v = [_vx,_vz,_vy];

_obj setVectorUp _v;

}

2.[obj,Direction-Angle] call fSetVdir

Angle being relative to last angle. Basically this uses a vector-product to get the side-vector,so you can do you sin/cos on the 2 base-vectors.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

fSetVdir = {

_obj = _this select 0;

_d = _this select 1;

_vup = vectorUp _obj;

_vdir = vectordir _obj;

_vsd = [(_vup select 1)*(_vdir select 2) - (_vup select 2)*(_vdir select 1),(_vup select 2)*(_vdir select 0) - (_vup select 0)*(_vdir select 2),(_vup select 0)*(_vdir select 1) - (_vup select 1)*(_vdir select 0)];

_obj setVectorDir [(cos _d)*(_vdir select 0)+(sin _d)*(_vsd select 0),(cos _d)*(_vdir select 1)+(sin _d)*(_vsd select 1),(cos _d)*(_vdir select 2)+(sin _d)*(_vsd select 2)];

_obj setVectorUp _vup}

I bet there is better and faster mathematical way to do it and I bet the functions are partly faulty,but it if helps you what the hell.If not,sorry for wasting anyones time

##### Share on other sites

Thanks lwlooz, it's does provide some more info. But I'm still just as confused.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj setVectorUp [0,0.001,0.999];

_obj setVectorDir [0,0.999,0.001];

_vx = (sin _b)*(cos _p);

_vz = -(sin _p);

_vy = (cos _b)*(cos _p);

_v = [_vx,_vz,_vy];

_obj setVectorUp _v;

This multiple call to setVectorUp?

It did back up the hunch I had about setVectorUp and setVectorDir being linked. I get more stable results if I call setVectorDir before setVectorUp.

But I think I need to confirm some basic facts first, I'm trying to fathom the correct axis:

If I use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Aircraft SetVectorDir [Sin _Inc,Cos _Inc,0];

I can get a perfect, continuous rotation around the red axis. So am I correct in thinking it's the Y axis, because Y is a constant? So according to my 3D maths book, green is the Z axis and blue the x axis?

In the back of my mind, I'm sure we could get a continuous rotation around all the axis. If we compensate for the sudden change in direction e.t.c ? Or is that asking the impossible?

Quote[/b] ]I bet there is better and faster mathematical way to do it and I bet the functions are partly faulty,but it if helps you what the hell.If not,sorry for wasting anyones time

Well I'm not in a position to say either way. I will be happy if I can find something that just works the way I want

##### Share on other sites

In accordance with math, SetVectorUp works about all axis.

But, one should consider, if SetVectorUp is applied, physics may change the set orientation again.

With version 1.01 the objects didn't wake up after SetVectorUp and could levitate above ground or stay in other strange positions, causing some confusion.

With 1.02, physics now applies at once. If one tilts the center of gravity from a barrel too far about for instance the x axis, it falls to the side. If one choose a small angle about x, it tilts back into it's normal, stable position. Therefore the effect in positioning the object by SetVectorUp sometimes only could be visible at the initial moment.

Also, there should be more faster transformation methods, then the standard one from polar to cartesian.

##### Share on other sites
Quote[/b] ]For more stepping in, Â read chapter 3.3.4 of my wrp objects tutorial in the wrpedit wiki branch

Do you have the URL?

Quote[/b] ]In accordance with math, SetVectorUp works about all axis.

I'm sure it does, only for me to understand the principle and hopefully apply it in Arma, I have to see it in practice.

Put when I tried your suggestion, with SetVectorUp:

Quote[/b] ][0.001,0.001,1] the barrel points upwards

Quote[/b] ]But, one should consider, Â if SetVectorUp is applied, physics may change the set orientation again.

True, but during my experiments, I have called SetVectorUp in a loop, without any delay. So in theory, it will never be able to readjust it's orientation.

As this is all a bit above my head, I decied to concentrate on one axis at a time.

Based on the code lwlooz posted for fSetPitchBank, I came up with this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_b=0;

_p=0;

_Inc=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Inc=_Inc+0.1;

_p=_Inc;

_Air setVectorUp [(Sin _b)*(Cos _p),-(Sin _p),(Cos _b)*(Cos _p)];

Hint Format ["%1 %2",VectorUp _Air];

};

This will pitch the aircraft in a constant 360 degree rotation (about the x axis) without the annoying, flipping effect at +\-180 degrees. Thatâ€™s great I thought. Just what I wanted. It works fine when the aircraft is pointing directly north or south.

But, there is one major problem. If you change the direction to east or west, instead of pitching, it now banks.

Take this variation of the above code as an example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_b=0;

_p=20;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Air setVectorUp [(Sin _b)*(Cos _p),-(Sin _p),(Cos _b)*(Cos _p)];

Hint Format ["%1 %2",VectorUp _Air];

};

So when the aircrafts direction is 0 degrees (north), I can set a pitch of 20 degrees and it all works fine. The aircraft now points upwards at an angle of 20 degrees. But if I change the direction to say 90 degrees (east), the aircraft is no longer pitching, but banking at 20 degrees. I can compensate for this by setting bank to -20 degrees and pitch back to 0:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 90;

_b=-20;

_p=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Air setVectorUp [(Sin _b)*(Cos _p),-(Sin _p),(Cos _b)*(Cos _p)];

Hint Format ["%1 %2",VectorUp _Air];

};

So now it's back to pointing upwards by 20 degrees, but this time with a heading of 90 degrees (east). So if I want the aircraft to maintaining a 20 degree pitch, upwards, while rotating it through 360 degrees. I have to come up with a way of applying the correct values for _p and _b, to maintain a pitch of 20+ degrees in any direction.

For the problem of rotating an aircraft through 360 degrees, while maintaining an upward pitch of 20 degrees. I'm sure I can cobble something together based on these crude assumptions:

Heading Â  Â  Â  _p Â  _b

0 degrees Â  Â  20 Â  0

90 degrees Â  Â 0 Â -20

180 degreesÂ -20 Â 0

270 degrees Â 0 Â Â  20

There must be a better way of doing all this, but I don't know what it is. Again I have the feeling this is all covered by 3D rotations and matrix multiplication? But I don't know either of them. So if I learn how to script a matrix, then I learn how to apply the rotations in scripts, I'm still not sure I will be able to apply them correctly to this problem. So if someone can solve the problem I mentioned above, then it gives me a head start in working out what I need to learn.

BTW I'm sure someone did implement all the required Matrix functions e.t.c in OFP scripts? Only I can't remember where I saw them.

Cheers

##### Share on other sites

Besides object manipulation, how much or is any of these functions directly used by ArmA AI in controlling aircraft behaviour? Â

I ask because if there is a powerful and flexible way to modify AI fixed wing aircraft behaviour when approaching threats (mods). Â Then, it might make it easier to develop algorithms that better simulate aircraft evasion or attack behaviours (high g turn for incomming missile threats, evading AAA fire, more intellegent aircraft engagement, etc.)

Right now, the best use I see for these new commands is overriding AI behaviour for a particular instance until more detailed understanding develops is:

1. script controlled landing for user defined landing areas

2. Manipulation of missile, bomb, bullet, and object behaviour in the air for a variety of uses:

Â  Â  Â  A. Â A realistically designed cluster bomb for aircraft use is needed. Â This could be adapted for artillery use too.

Â  Â  Â  B. Â Artillery, Ballistic Missiles, Cruise Missiles/Anti-ship missiles

Â  Â  Â  C. Â Surface to Air Missiles

Â  Â  Â  D. Â Air to Air Refuelling

Having more controls of the object's position and flight will enhance some project's simulation, however others will not need much of these extra features and will have to adapt their OFP coding to incorporate additional coordinates.

##### Share on other sites

Did I get you right, that you just want to set the pitch of the plane? Maybe this will work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_pitch = 20;

_vecDir = vectorDir _plane;

_vecDir set [2,sin _pitch];

_plane setVectorDir _vecDir;

##### Share on other sites

very nice work unn and co.

i like what this script here does and have found a use for it.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_b=0;

_p=0;

_Inc=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Inc=_Inc+0.1;

_p=_Inc;

_Air setVectorUp [(Sin _b)*(Cos _p),-(Sin _p),(Cos _b)*(Cos _p)];

Hint Format ["%1 %2",VectorUp _Air];

};

i wonder if theres a way to apply this to a missile fired by an aa soldier . the original select 4 , is not a simple ported code i fear.

my reason is because i want to write a spoofmissile script cause the aa are far to accurate at this time.

##### Share on other sites
Quote[/b] ]Besides object manipulation, how much or is any of these functions directly used by ArmA AI in controlling aircraft behaviour?

I've not done much testing on this side, still trying to work out the basics. But the wiki\Bis suggests they will respond to physics. I've also seen something along those lines myself. When I get the chance, I will try and make a flying AI, loop the loop.

Quote[/b] ]I ask because if there is a powerful and flexible way to modify AI fixed wing aircraft behaviour when approaching threats (mods). Â Then, it might make it easier to develop algorithms that better simulate aircraft evasion or attack behaviours (high g turn for incomming missile threats, evading AAA fire, more intellegent aircraft engagement, etc.)

Right now, the best use I see for these new commands is overriding AI behaviour for a particular instance until more detailed understanding develops is:

1. script controlled landing for user defined landing areas

2. Manipulation of missile, bomb, bullet, and object behaviour in the air for a variety of uses:

Â  Â  Â A. Â A realistically designed cluster bomb for aircraft use is needed. Â This could be adapted for artillery use too.

Â  Â  Â B. Â Artillery, Ballistic Missiles, Cruise Missiles/Anti-ship missiles

Â  Â  Â C. Â Surface to Air Missiles

Â  Â  Â D. Â Air to Air Refuelling

Having more controls of the object's position and flight will enhance some project's simulation, however others will not need much of these extra features and will have to adapt their OFP coding to incorporate additional coordinates.

There are a ton of uses, but a lot depends on the overheads of setting this up. Thatâ€™s why the scripts will probably need to make use of the most efficient methods, to calculate the correct rotations, for some of these applications.

Quote[/b] ]Did I get you right, that you just want to set the pitch of the plane? Maybe this will work:

Well I'm no expert, but setVectorDir appears to work just the same as setDir, it only rotates around the Y axis. But with the added advantage of using\returning vectors for X & Z?

Quote[/b] ]my reason is because i want to write a spoofmissile script cause the aa are far to accurate at this time.

Yeah, I see no reason why you can't use those commands to deflect a missile. Footmunch has a script in OFP that does that to a certain degree. Although, it can only effect direction and velocity. So adding pitch to make it look a little smoother should be easy enough, once it's all figured out.

##### Share on other sites

I made some more headway, I've managed to work out a solution to the problem of maintaining a constant pitch, during rotations. Don't know if this was already covered, but doing it this way meant I could figure it out one step at a time. I'm just trying to work out the rest of the details and trying to decide, if I need to go to all the trouble of setting up a matrix.

Here are some of the basic scripts I was using for rotations along each of the axis.

X Axis:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_Inc=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Up=VectorUp _Air;

_Inc=0.1;

_Air setVectorUp [(_Up Select 0),((Sin _Inc)*(_Up Select 2))+((Cos _Inc)*(_Up Select 1)),((Cos _Inc)*(_Up Select 2))-((Sin _Inc)*(_Up Select 1))];

Hint Format ["%1 %2",_Up];

};

Z Axis:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_Inc=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Up=VectorUp _Air;

_Inc=0.1;

_Air setVectorUp [((Cos _Inc)*(_Up Select 0))-((Sin _Inc)*(_Up Select 2)),(_Up Select 1),((Sin _Inc)*(_Up Select 0))+((Cos _Inc)*(_Up Select 2))];

Hint Format ["%1 %2",_Up];

};

Y Axis:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air setVectorUp [((Cos _Inc)*(_Up Select 0))+((Sin _Inc)*(_Up Select 1)),-((Sin _Inc)*(_Up Select 0))+((Cos _Inc)*(_Up Select 1)),(_Up Select 2)];

I don't think the Y Axis script will actually do anything with setVectorUp, on it's own. setVectorUp only displays rotations around the X & Z axis. But the equation was needed later on, when I started to change the aircrafts direction, so I thought I would post it now.

Back to the problem I had before, I wanted to rotate an aircraft 360 degrees along it's Y axis (from north..east..south to west e.t.c). During the rotation I wanted the aircraft to point upwards (X axis) by 20 degrees. So I ended up with this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Pitch=-20;

_Dir=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

_InitUp=VectorUp _Air;

_InitUp=[(_InitUp Select 0),((Sin _Pitch)*(_InitUp Select 2))+((Cos _Pitch)*(_InitUp Select 1)),((Cos _Pitch)*(_InitUp Select 2))-((Sin _Pitch)*(_InitUp Select 1))];

WaitUntil

{

_Air SetVelocity [0,0,0];

_Dir=_Dir+0.1;

_Air SetDir _Dir;

_Air setVectorUp [((Cos _Dir)*(_InitUp Select 0))+((Sin _Dir)*(_InitUp Select 1)),-((Sin _Dir)*(_InitUp Select 0))+((Cos _Dir)*(_InitUp Select 1)),(_InitUp Select 2)];

};

This works fine, it's only a simple example of one particular way of doing it. But the important thing is, it finally works I've avoided using setVectorDir for now, in this case setDir does the job and keeps the script simple.

_InitUp stores the vectors for the aircraft pointing north, at a pitch of 20 degrees. It's the same equation I used in the X Axis script. It effectivly means, at the start of each loop, I reset the aircraft back to 0 degrees direction, 20 degrees pitch.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air setVectorUp [((Cos _Dir)*(_InitUp Select 0))+((Sin _Dir)*(_InitUp Select 1)),-((Sin _Dir)*(_InitUp Select 0))+((Cos _Dir)*(_InitUp Select 1)),(_InitUp Select 2)];

This line is the same equation from the Y Axis script. All this is doing, is taking the values stored in _InitUp and performing a rotation along the Y axis, according to _Dir. Re-adjusting the values in _InitUp, so the aircraft still has a pitch of 20 degrees, no matter what direction it's pointing.

Ok, so in the script, _p is set to -20. That just corresponds to 20 degrees pitch in an upward direction. +20 means it will pitch downward.

In the end, I think we will probably want functions to do the following, as efficently as possible:

Relative rotations about a single axis X,Y or Z

Absolute rotations about a single axis X,Y or Z

Relative rotations about multiple axis X,Y and Z

Absolute rotations about multiple axis X,Y and Z

Return direction in degrees for a single axis X or Z

Return direction in degrees for multiple axis X,Y and Z

Can anyone think of any more?

There is still a bit for me to figure out, I've still got to try combined rotations along three axis. Plus, see if matrixes will be any quicker.

##### Share on other sites
Quote[/b] ]Yeah, I see no reason why you can't use those commands to deflect a missile. Footmunch has a script in OFP that does that to a certain degree. Although, it can only effect direction and velocity. So adding pitch to make it look a little smoother should be easy enough, once it's all figured out.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Air SetDir 0;

_b=0;

_p=0;

_Inc=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

WaitUntil

{

_Air SetVelocity [0,0,0];

_Inc=_Inc+0.1;

_p=_Inc;

_Air setVectorUp [(Sin _b)*(Cos _p),-(Sin _p),(Cos _b)*(Cos _p)];

Hint Format ["%1 %2",VectorUp _Air];

};

this one

and simply applied those values to a missile (activation random)

distance 150 from target and it looks real smooth.

thanks for the maths. it climbs away and @ _Inc > 105 i destroy it.

btw the vid isnt what happens now, just an early version to see what it was doing to missile .

at least everytime theres a miss not everytime an aa is launched )

##### Share on other sites
Quote[/b] ]heres a vid i made whilst testing.

Thanks for the vid, good to know missiles will work ok.

I did manage to test a loop on an aircraft in motion. For the player it worked fine. But with the AI it turned into a right mess. But I think thats because I was using an earlier version of the scripts.

Quote[/b] ]btw the vid isnt what happens now, just an early version to see what it was doing to missile

Shame, I thought you might be working on a "Catch the pigeon Mod" ....Errâ€¦perhaps I'm showing my age.

##### Share on other sites

lol iam old enough to remember .

but on a similar theme(ish) ,my main theme in ofp and arma is ambience and i hope to apply this script to the wild life, at the moment birds have min height of 60 but it would be nice if in future we can make them stoop for insects etc and maybe have the roller doves /pigeons that hannibal lecter talked of.lol

i better stop now.

##### Share on other sites

What is vectorUp supposed to do again?! It doesnt do anything to me!

At least: Something is wrong with the vector calculation as

SetVecorDir[ 0,1,0.000001 ]

gives completly nother effect than

SetVectorDir[ 0,1,0 ]

so: WTF?

##### Share on other sites

Something that may help you visualise it .... Create a mission with a player, a flying heli (theHeli) and second soldier (theSoldier). Run this script:-

while {true} do {

_pos = position theHeli ;

_pos set [2,(_pos select 2)-2];

theSoldier setPos _pos ;

theSolder setVectorDir (VectorUp the Heli) ;

theSolder setVectorUp (VectorDir the Heli) ;

Sleep 0.01 ;

} ;

You should then see the soldier flying prone in formation with the helicopter His 'up' vector is the same as the heli's 'Dir' vector and vice-versa.

##### Share on other sites

Sorry if I not try exactly this script but can you tell me why i doenst show any effect to apply VectorUp on a flying soldier where vectordir does a job?!

---edit---

Why is it not just one 4 dimensional vektor for orientation (3 elements) and rotation (1 element) ?

##### Share on other sites
Quote[/b] ]Sorry if I not try exactly this script but can you tell me why i doenst show any effect to apply VectorUp on a flying soldier where vectordir does a job?!

I think BIS are the only ones who could say for sure, I have a theory but thats about it. Either way, the results are the same, you can't alter the pitch e.t.c of infantry during normal game play. Even in OFP you could alter the direction, so I'm not suprised setVectorDir works.

##### Share on other sites

Yeah experimented with that one too,

cool to see that finally missile deflection is achievable in ArmA,

as most OFP chaff/flare scripts have used setdir on the missile

which did not alter their movement direction at all,but just their

##### Share on other sites
Why is it not just one 4 dimensional vektor for orientation (3 elements) and rotation (1 element) ?

It is easier to convert direction + up vectors to transformation matrix, since you can get 3rd column with just doing cross product of dir & up vectors, and conversion between direction+angle and transformation matrix isn't that trivial.

##### Share on other sites
Quote[/b] ]It is easier to convert direction + up vectors to transformation matrix, since you can get 3rd column with just doing cross product of dir & up vectors

Sorry, but any chance of explaining this in layman's terms.

If Cross product is illustrated as u x v:

How might that apply to ARMA. Would it make this any faster?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Air=_This Select 0;

_Pos=GetPos _Air;

_Pitch=-20;

_Dir=0;

_Pos Set [2,(_Pos Select 2)+5];

_Air SetPos _Pos;

_InitUp=VectorUp _Air;

_InitUp=[(_InitUp Select 0),((Sin _Pitch)*(_InitUp Select 2))+((Cos _Pitch)*(_InitUp Select 1)),((Cos _Pitch)*(_InitUp Select 2))-((Sin _Pitch)*(_InitUp Select 1))];

WaitUntil

{

_Air SetVelocity [0,0,0];

_Dir=_Dir+0.1;

_Air SetDir _Dir;

_Air setVectorUp [((Cos _Dir)*(_InitUp Select 0))+((Sin _Dir)*(_InitUp Select 1)),-((Sin _Dir)*(_InitUp Select 0))+((Cos _Dir)*(_InitUp Select 1)),(_InitUp Select 2)];

};

Traditionally, Sin and Cos were considered a bit intensive. Would it allow me to replace any of those? For this bit:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _Air setVectorUp [((Cos _Dir)*(_InitUp Select 0))+((Sin _Dir)*(_InitUp Select 1)),-((Sin _Dir)*(_InitUp Select 0))+((Cos _Dir)*(_InitUp Select 1)),(_InitUp Select 2)];

I think I understand what you mean about the transformation matrix, only Iâ€™m not sure itâ€™s worth going to the trouble of a matrix, for what I need it for. Perhaps even for most applications in ARMA?

Cheers

##### Share on other sites

Might one ask how a trasnformation matrix would make this easier? I have a good book on the subject relating to games by Ian Millington I could scan a load of the pages in and send them to you UNN if you wanted? It's all about transformation matrices.

Would a matrix method be required if one were to want an aircraft to goto any pitch and bank in any given direction? I assume the current solution has some large limitations?

##### Share on other sites
Quote[/b] ]Might one ask how a trasnformation matrix would make this easier?

I'm no expert on the subject, but I did start implementing a Matrix solution a while back. It seemed a little long-winded for what I wanted to do. It might be due to the way BIS have laid out these commands. Perhaps you just donâ€™t need to go that far?

Quote[/b] ]I have a good book on the subject relating to games by Ian Millington I could scan a load of the pages in and send them to you UNN if you wanted? It's all about transformation matrices.

Cheers, I have a couple of books myself. Along with a few good web sites I found, so I'm ok on that front.

Quote[/b] ]Would a matrix method be required if one were to want an aircraft to goto any pitch and bank in any given direction? I assume the current solution has some large limitations?

It's not required. It probably helps organise the code and makes it look a little more professional. But the impression I got was, you were adding lots of code that would never really be used with those commands? The scripts I posted at the bottom of the first page should be enough, they just have to be combined into one function. Depending on how you want to implement them.

I've not done any more work on them since. I don't have any use for them atm, since I shelved my original plans. For me, it required a lot of time and effort, to get as far as I did.

×

• Clubs