Home   Help Search Login Register  

Author Topic: Math velocity and other problems  (Read 911 times)

0 Members and 1 Guest are viewing this topic.

Offline uiox

  • Contributing Member
  • **
Math velocity and other problems
« on: 18 Jan 2003, 23:01:05 »
Not good enought in english (for math expressions) && math:

Command drop:

Object one getpos no problem

Object two getpos no problem

Start particule pos object one no problem

For reach object  two with only velocity, big problem...

My particule begins object one, finishes object two, it speed is 1000 meters second,could you give me velocity?
« Last Edit: 19 Jan 2003, 12:50:16 by uiox »

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Math velocity and other problems
« Reply #1 on: 19 Jan 2003, 08:05:04 »
Are you saying you want to send a particle from the position of object one to the position of object two at a velocity of 1000 m/s?

Hmm....
_o1x
_o1y
_o2x
_o2y
_velocity = 1000
_distance = _o1 distance _o2
_xcomponent = (_o2x-_o1x)/_distance
_ycomponent = (_o2y-_o1y)/_distance
_zcomponent = _distance *(sqrt (1- ((_xcomponent^2)+(_ycomponent^2)))
_zcontrol = "logic" camcreate [_o2x, _o2y, _o2z + _zcomponent]
?_o1 distance _zcontrol > _distance:_zcomponent = -1 * _zcomponent
deletevehicle _Zcontrol
_xvector = _velocity * _xcomponent
_yvector = _velocity * _Ycomponent
_zvector = _velocity * _zcomponent
Dinger/Cfit

Offline uiox

  • Contributing Member
  • **
Re:Math velocity and other problems
« Reply #2 on: 19 Jan 2003, 11:09:55 »
Ooohps forget this  :-[

Quote
_distance = _o1 distance _o2

No matrix, vector an other barbarian tools : pythagore

Thx Dinger!

« Last Edit: 19 Jan 2003, 12:20:33 by uiox »

Offline uiox

  • Contributing Member
  • **
Re:Math velocity and other problems
« Reply #3 on: 19 Jan 2003, 12:41:28 »
Don't work.



Your script adapt

_obj = _this select 0
_pos = _this select 1
_PosTarget = getpos ah
_velocity = 1000
_distance = _obj distance ah
_x1 = (getpos _obj select 0)
_y1 =  (getpos _obj select 1)
_x2 = (_PosTarget  select 0)
_y2 =  (_PosTarget  select 1)
_z2 =(_PosTarget  select 2)
_xcomponent = (_x2  - _x1)/_distance
_ycomponent = (_y2 -_y1)/_distance
_zcomponent = _distance * (sqrt ( 1- ( (_xcomponent^2) + (_ycomponent^2) ) ) )
_zcontrol = "logic" camcreate [_x2, _y2, _z2 + _zcomponent]
?_obj distance _zcontrol > _distance:_zcomponent = -1 * _zcomponent
deletevehicle _Zcontrol
_xvector = _velocity * _xcomponent
_yvector = _velocity * _Ycomponent
_zvector = _velocity * _zcomponent

Speeds are very hight... ( ~400,~600,~- 60000 for 50,50,50 position)
« Last Edit: 19 Jan 2003, 12:49:31 by uiox »

Offline uiox

  • Contributing Member
  • **
Re:Math velocity and other problems
« Reply #4 on: 19 Jan 2003, 13:19:35 »
I begin to understand.

If this is right :

_Coef = distance/speed
velocity = [(x1-x2)*_coef,(y1-y2)*_coef,(z2-z1)*_coef]

Wrong or not?

For z I have to adapt the 2 z with alitude of sea level...

Offline uiox

  • Contributing Member
  • **
Re:Math velocity and other problems
« Reply #5 on: 19 Jan 2003, 15:22:09 »
This works

_obj = _this select 0
_PosObject = getPos _obj
_PosTarget = getpos ah
_velocity = 1000
_distance = _obj distance ah
trigPos setPos _PosObject
_z1sea = trigPos distance _obj
trigPos setPos _PosTarget
_z2sea = trigPos distance ah
_x1 =  (_PosObject  select 0)
_y1 =  (_PosObject  select 1)
_z1 =  (_PosObject  select 2)
_x2 = (_PosTarget  select 0)
_y2 =  (_PosTarget  select 1)
_z2 =(_PosTarget  select 2)
_Coef = _velocity/_distance
_xcomponent = (_x2  - _x1)
_ycomponent = (_y2 -_y1)
_zcomponent = (_z2+_z2sea)   -(_z1 + _z1sea  )  
_xvector =  _xcomponent * _coef
_yvector =_Ycomponent * _coef
_zvector =  _zcomponent * _coef
player globalchat format ["z1sea %1  z2sea %2  z1 %3 z2 %4",_z1sea, _z2sea ,_z1, _z2 ]

_lifetime = _distance/_velocity

_weight = 1
_Volume = 0.155 * 0.2 *0.155
_Densite =7.85

drop ["cl_fire", ""      , "Billboard", 10, _lifetime, _PosObject , [_xvector ,_yvector ,_zvector ],   0, _weight, _Volume , 0, [_weight,_Volume], [[1,1,0,1], [1, 1, 0, 1]],
  • , 0, 0, "", "sparks.sqs",""]



Thx Dinger  8)
« Last Edit: 19 Jan 2003, 17:28:17 by uiox »