Home   Help Search Login Register  

Author Topic: scripting.. how long to learn?  (Read 4670 times)

0 Members and 1 Guest are viewing this topic.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:scripting.. how long to learn?
« Reply #60 on: 20 Dec 2004, 21:51:17 »
hey, penguinman, i'll get back to you on this, its exam week fo me, so when i get the time i'll come back and show you how to use sin cos and tan.
alright?
unless someone else would like to explain it...

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:scripting.. how long to learn?
« Reply #61 on: 21 Dec 2004, 04:25:32 »
ok great,

 :)
« Last Edit: 21 Dec 2004, 04:25:56 by penguinman »

RedHouse

  • Guest
Re:scripting.. how long to learn?
« Reply #62 on: 21 Dec 2004, 09:30:28 »
i dont understand it that well, but i know h^2 = b^2 + a^2,


this is some text i put in one of my scripts, it shows two ways to work out 2d rotations of a point on a grid but it took me ages to figure it out and i still dont know if its right but it works so im happy. I would explain it if i could but I really can't remember how the hell it works.

Code: [Select]
_m_TO_SQUARE = (_x_ORIGEN_U ^2) + (_y_ORIGEN_U ^2)
_m = sqrt _m_TO_SQUARE
_x_ORIGEN_ROTATED_U = _x_ORIGEN_U * cos angle + _y_ORIGEN_U * sin angle
_y_ORIGEN_ROTATED_U = _y_ORIGEN_U * cos angle - _x_ORIGEN_U * sin angle
_x_ROTATED_U = _x_ORIGEN_ROTATED_U + _xT
_y_ROTATED_U = _y_ORIGEN_ROTATED_U + _yT
_x_POSITION_U = ((_x_ROTATED_U - ((sin angle) * _m)))
_y_POSITION_U = ((_y_ROTATED_U - ((cos angle) * _m)))

maybe someone smarter will make sense of it.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:scripting.. how long to learn?
« Reply #63 on: 21 Dec 2004, 11:36:30 »
Apologies if I am missing something (this is a long thread).

Does this help:

A right angled triangle is one that has one angle = 90 degrees.  The side opposite this angle is called the hypotenuse.  Let us call it h and let us call the other sides x and y.
Also let us call the angle opposite side x theta.  The angle opposite side y will therefore be (90 - theta).

Then

h^2 = x^2 + y^2

sin (theta) = x/h
cos (theta) = y/h
tan (theta) = x/y

sin (90-theta) = y/h
cos (90-theta) = x/h
tan (90-theta) = y/x

From the above you can work out anything you need.


For example:
If an object is located at (x1,y1) with direction theta
and you want the coordinates of a point that is a distance d away  at an angle alpha to the direction the object is facing then the formulae are:

x = x1 + d*Sin(theta + alpha)
y = y1 + d*Cos(theta + alpha)



And:
To find the coordinates of a point in front of or to the side of an object

if:
x1,y1 are the coordinates of the object
theta is the direction of the object
d is the distance of the point from the object

then:
For a point in front of the object
X coordinate = x1 + d*sin(theta)
y coordinate = y1 + d*cos(theta)

(for a point behind use -d or theta+180)


For a point to the right of the object
X coordinate = x1 + d*cos(theta)
y coordinate = y1 - d*sin(theta)

(for a point to the left use -d or theta+180)  
 
 

« Last Edit: 21 Dec 2004, 11:46:26 by THobson »

RedHouse

  • Guest
Re:scripting.. how long to learn?
« Reply #64 on: 21 Dec 2004, 11:47:49 »
thats very helpfull thx

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:scripting.. how long to learn?
« Reply #65 on: 21 Dec 2004, 15:40:27 »
well there you go penguinman

Lean Bear

  • Guest
Re:scripting.. how long to learn?
« Reply #66 on: 15 Feb 2005, 17:26:53 »
TriggerHappy's right everyone.

The Pythagoras Theorem, radii of circles, algebra in general is required to be able to script efficiently in computers. Not only OFP.

That's why you'll find that at college etc. to do a decent computing course involving prgramming, scripting etc. you'll need a high grade in Math.

dan ick

  • Guest
Re:scripting.. how long to learn?
« Reply #67 on: 15 Feb 2005, 19:05:18 »
 ;D Hey

             You will get there in the end i myself am just learning simple scripts and yes it is a bit confusing at first but like someone mentioned start with the init fields etc.....

I only started using PC's about a year and a half ago and i started with the inits,on activ etc.......
I could not understand scripts for months but i read Snypirs guide and a few others quite a few times till i could nearly remember it word for word,However i just seen the post with someone meantioning pythagoros,After seeing that very word and reading a bit of the example,There is now smoke pouring out of my ears and i can smell wood burning :P

Anyway Good luck ;)


YOU CAN DO IT,YOU DA MAN :-* ;D
« Last Edit: 15 Feb 2005, 19:09:28 by dan ick »

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:scripting.. how long to learn?
« Reply #68 on: 18 Feb 2005, 22:45:19 »
yay locked it... that should do it for completely off-topic posts... go make ure own...
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage