Home   Help Search Login Register  

Author Topic: Maths! Noooo! Run away! (etc.)  (Read 1223 times)

0 Members and 1 Guest are viewing this topic.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Maths! Noooo! Run away! (etc.)
« on: 06 Jun 2007, 22:55:04 »
Long time no see to you all. Now ol' Armsty pretty much got raped by the Swedish business world and lost his summer employment. That means Armsty has way too much time on his hands. To keep him occupied he'll either have to resort to drugs, or start doing some editing again. Same thing different names anyway, is it not?

Not only am I very, very rusty, I have also put myself in something of a conumdrum. Involving maths. Should be easy for someone who hasn't had his head in a bucket the past fifteen years though.

Right. So basically, I have Unit A. What I want to find out the position of Unit A, say, 10 metres behind him. Now, all I've come up with is that I have to getDir Unit A, then subtract 180 so I get the opposite direction of the direction Unit A is facing (i.e. directly behind him). Then I have to use this value combined with Unit A's getPos-values and the number 10 to find what I want. I have no idea how though. Could someone help me out here? I'll kiss your feet digitally.

Hepp Hepp!
/Armsty

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Maths! Noooo! Run away! (etc.)
« Reply #1 on: 06 Jun 2007, 23:19:07 »
sin and cos are your friends. they won't buy you drugs, but they will solve this problem.

Code: [Select]
_x = getpos unita select 0
_y = getpos unita select 1
_dir = getdir unita
_distance = 10

_point_you_want = [_x + (10*sin(_dir-180)), _y + (10*cos(_dir-180))]

foot kissing not necessary, it's just nice to see you back.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Maths! Noooo! Run away! (etc.)
« Reply #2 on: 06 Jun 2007, 23:56:22 »
You are missing an small detail there  :P

Code: [Select]
_unit = _this select 0

_dir = getdir _unit
_distance = 10
_x = getpos _unit select 0
_y = getpos _unit select 1
_almost_point_you_want = [_x + (10*sin(_dir-180)), _y + (10*cos(_dir-180))]

;The previous point will be not 10m at the back of the unit unless at sea level ...
_sea = "EmptyDetector" camCreate [0,0,0]
_sea setPos [_x, _y, 0]
_asl1 = _sea distance _unit
_ground = "logic" camCreate [_almost_point_you_want select 0, _almost_point_you_want select 1, 0]
_als2 = _ground distance _sea
deleteVehicle _sea
deleteVehicle _ground


_z = _asl1 - _asl2
_point_you_really_want = [_almost_point_you_want select 0, _almost_point_you_want select 1, _z]

 :P


EDIT:
 :P

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re: Maths! Noooo! Run away! (etc.)
« Reply #3 on: 07 Jun 2007, 02:06:41 »
Cheers to you both! I'll check this out tomorrow afternoon. :)

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re: Maths! Noooo! Run away! (etc.)
« Reply #4 on: 07 Jun 2007, 22:52:13 »
Worked like a charm. Kisses to both of you. :D

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Maths! Noooo! Run away! (etc.)
« Reply #5 on: 07 Jun 2007, 23:30:55 »
has it been so long you've forgotten how to modify posts? mmm?  :whistle:

as an aside, your avatar isn't displaying mate - we all miss syd.