Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-08-2002, 11:13 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Newb Gift: Circular Movement

It seems that all the newbs seem to have problems for some reason with cos and sin. I feel it is my responsibility then to provide help and give a quick description. I know this has been covered UBER amounts of time (Maybe this'll get stickied even)

First off, Sin is the opposite angle divided by the hypotenuse. Cos is the adjacent angle divided by the hypotenuse. Perhaps Kai will be kind enough to post his chart up again Using sine (sin) is generally applied to the x value. Using cosine(cos) is generally applied to the y value. When moving around persay a light or something, this is the format you would use:
NPC Code:

if (action)
{ x=x+sin(angle)*distance;
y=y+cos(angle)*distance;
}


The x value gets added to the sin of the angle, then multiplied by the distance from the centre point. It isn't all that hard. Play with it a bit. Use a variable for angle and distance. Try and get things to move on a timeout or whatnot. It'll come in handy. I hope you find use for it and I explained what you did not understand. If you have any other questions, that haven't been answered in EVERY other cos/sin thread, ask away.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #2  
Old 10-08-2002, 02:14 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Re: Newb Gift: Circular Movement

Quote:
Originally posted by emortylone
It seems that all the newbs seem to have problems for some reason with cos and sin. I feel it is my responsibility then to provide help and give a quick description. I know this has been covered UBER amounts of time (Maybe this'll get stickied even)

First off, Sin is the opposite angle divided by the hypotenuse. Cos is the adjacent angle divided by the hypotenuse. Perhaps Kai will be kind enough to post his chart up again Using sine (sin) is generally applied to the x value. Using cosine(cos) is generally applied to the y value. When moving around persay a light or something, this is the format you would use:
NPC Code:

if (action)
{ x=x+sin(angle)*distance;
y=y+cos(angle)*distance;
}


The x value gets added to the sin of the angle, then multiplied by the distance from the centre point. It isn't all that hard. Play with it a bit. Use a variable for angle and distance. Try and get things to move on a timeout or whatnot. It'll come in handy. I hope you find use for it and I explained what you did not understand. If you have any other questions, that haven't been answered in EVERY other cos/sin thread, ask away.
---Shifter
it would be more accurate to say

x=x+sin(angle)*radius;
y=y+cos(angle)*radius;
Reply With Quote
  #3  
Old 10-08-2002, 06:41 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Re: Newb Gift: Circular Movement

Quote:
Originally posted by emortylone

First off, Sin is the opposite side divided by the hypotenuse. Cos is the adjacent side divided by the hypotenuse.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #4  
Old 10-08-2002, 11:19 PM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
It all deals with triangles, it isn't that hard to comprehend I think. Get in a GeoMetry class, perhaps even a lower Algebra class would be useful. If you need some equations, I can help you guys out. It just takes a bit getting used to. ANd yes, Distance is radius, but since the people seem to need help in this area, I assumed that using more mathmatical terms was unnecessary. I said it was the distance from the centre, basically the radius
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #5  
Old 10-08-2002, 11:31 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Even though the radius is diameter/2
Reply With Quote
  #6  
Old 10-09-2002, 02:03 AM
Com013 Com013 is offline
Registered User
Join Date: Aug 2002
Location: GMT+1
Posts: 381
Com013 is on a distinguished road
Re: Newb Gift: Circular Movement

Quote:
Originally posted by emortylone
Using sine (sin) is generally applied to the x value. Using cosine(cos) is generally applied to the y value
No! The other way 'round! Normally a mathematical cricle starts right and continues counter-clockwise. In graal it'd be:
xvalue = cos(angle)
yvalue = -sin(angle)
"getangle" is doing the same, so to be compatible, just follow this.
__________________
Com013
Former Admin of the LAT on Graal The Adventure

e-mail: [email protected]
Reply With Quote
  #7  
Old 10-09-2002, 06:24 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Thats because you were treating him like a 20 year old adult, and not like a little baby


EDIT!!!

Shifter!!! WHAT ABOUT RADIANS??

Radian = Degree / 180 *3.142

So....

To show something at 45 degrees... to a point you would use
this.angle = 45/180*3.14;
x=x+sin(this.angle)*this.radius;
y=y+cos(this.angle)*this.radius;
Reply With Quote
  #8  
Old 10-09-2002, 06:27 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
LOL, ain't THAT the truth Kai :P It was the best way to learn, but I know it can be aggravating. Knowing THAT something works doesn't mean you understand the command. Knowing WHY something works is when you can say you comprehend it.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #9  
Old 10-09-2002, 06:28 AM
Graal2001_NAT Graal2001_NAT is offline
Registered User
Join Date: Sep 2002
Posts: 241
Graal2001_NAT is on a distinguished road
...and who told you how to to that r0bin :P
__________________
GONE, BAI
Reply With Quote
  #10  
Old 10-09-2002, 06:29 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Same place he learns MOST of his new tricks From meh :P and j00
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #11  
Old 10-09-2002, 06:29 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
JAGEN! TEH 1337EST DUDE!!!!!!!!!!!!

(Yeah people were wondering... "where did r0bin get this extensive knowledge all of a sudden?")

NOT FROM YOU SHIFTER!!!

Jagen taught me everything i know <3
Reply With Quote
  #12  
Old 10-09-2002, 06:31 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
WTF are you talking about bish?! WHO IM'ed ME asking to be taught cos and sin?!
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #13  
Old 10-09-2002, 06:32 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
I did, but you taught me **** all :P

Bah i must have listened to jagen and not you :P
Reply With Quote
  #14  
Old 10-09-2002, 06:37 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
I dunno, I'm feeling discredited and unloved here =/ You know I'd always help you...
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #15  
Old 10-09-2002, 06:41 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
I still <3 you!! even if you dont come on aim any more :'(
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.