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 09-02-2003, 07:23 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Vector Crash Course

Q: What is a vector?
A: A vector is a way of describing motion through space, regardless of the starting point of that motion.

Q: How do you write a vector? In physics, there are two useful ways. The first is polar coordinates. Polar coordinates tells you the magnitude and the direction of the vector. So you could say some vector, say v, is this.

v = r @ theta
For example:
v = 1.75 units @ 30 degrees (or pi/4 radians if you prefer)

However, this is not exactly useful when it comes to the calculations involved. Not, at least, given that most if not all of us are more familiar with Cartesian coordinates. In Cartisian coordinates, the vector tells information about the change in x and the change in y, usually called dx and dy, respectively.

v = <dx,dy>

Based upon the Pythagorean theorem, we can write polar coordinates in terms of Cartesian coordinates and vice-versa.

dx= r*cos(theta)
dy= r*sin(theta)

r^2=dx^2+dy^2
tan (theta)= dy/dx

So, from the earlier example of polar coordinates:

v = <1.299,.75> (roughly)

Next Post: Addition and multiplication of vectors
__________________


Help me keep scripting

Last edited by TribulationStaff; 09-02-2003 at 07:43 PM..
Reply With Quote
  #2  
Old 09-02-2003, 07:35 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
in other words,vector is a mathematical device for describing a quantity that has a magnitude and a direction.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #3  
Old 09-02-2003, 07:41 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Right, where a scalar quantity only has magnitude.

An example: Speed is a scalar quantity that only tells distance/time. Velocity is speed in a given direction. Sorry, should have mentioned that.
__________________


Help me keep scripting
Reply With Quote
  #4  
Old 09-02-2003, 07:43 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
It's interesting..
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #5  
Old 09-02-2003, 07:43 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
If you want my opinion, I'd say you went way over their heads. I don't think polar coordinates are a necessary topic, and overcomplicates matters.

osrs, anybody can copy & paste :-p
__________________
Reply With Quote
  #6  
Old 09-02-2003, 07:46 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by Kaimetsu
osrs, anybody can copy & paste :-p
Yes,but since i'm studying it i know what i'm talking about.
You aren't the only one smart guy here.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #7  
Old 09-02-2003, 07:48 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Actually, my physics class talked about polar coordinates first, because it is more simple to understand visually.

For those of you who don't know. An angle in a graph is taken counterclockwise from the positive x axis.
__________________


Help me keep scripting
Reply With Quote
  #8  
Old 09-02-2003, 08:13 PM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
what about those of us who arent doing physics. XD i only understood you in begining...
__________________
Im still searching...
Reply With Quote
  #9  
Old 09-02-2003, 08:15 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Scalar multiplication of vectors:

When you multiply a vector by a scalar, the direction of the vector is unchanged; only the magnitude changes. Let A=<a,b> and c be some real number. Then c*A=<a*c,b*c>.

Q: Why doesn't the direction change?
A: Think of it this way, if you have been in algebra, you should know that the slope of a line is the rise(change in y) divided by the run (change in x). Well, that is just what b and a are, respectively. So the slope of that vector is the direction of that vector. When you multiply both a and b by c, nothing changes in the slope, because c "cancels out" in the division.

Addition of vectors:

Q: How do you add/subtract vectors?
A: It is easy, once in Cartesian coordinates. Let A=<a,b> and B=<c,d>. Then A+B=<a+c,b+d>. If you wanted to subtract B instead of add it, you could just multiply it by -1, as above, then add just like you would normally.

The Scalar Product (The Dot Product)

Given two vectors, A and B, the scalar product of the two, in mathematical terms is written A·B=|A|*|B|*cos(theta), where theta is acute (or 180) angle between them. What does || mean, though? Well || returns the magnitude of the vector, making a scalar quantity. Since the dot product only involves the magnitudes of vectors, the dot prodect itself is a scalar quantity, hence the name scalar product. Using a previous example, speed is the magnitude of velocity.

Q: How do you find the magnitude of a vector?
A: Let v=<a,b>. Then, |v|=sqrt(a^2+b^2). For those with a good memory, you might recognize that to be just like the formula for finding r from Cartesian coordinates. That is because r is the magnitude of the vector.

Q: What if you don't know the angle between them?
A: That is one of the uses of the dot product. There is a shortcut way of figuring out the answer of the dot product itself. Let A=<a,b> and B=<c,d>. Then, A·B=a*c+b*d. And you already know how to find the magnitude of A and B. So just divide both sides by those magnitudes, and you are left with (A·B)/(|A|*|B|)=cos(theta). With the help of a calculator, you can find that angle.

Next post: Vector product (cross product)
__________________


Help me keep scripting

Last edited by TribulationStaff; 09-03-2003 at 06:54 AM..
Reply With Quote
  #10  
Old 09-02-2003, 08:20 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Like I said, this is only a crash course. If you need more than what I have here, an excellent reference, if you want to sift through it, is http://mathworld.wolfram.com
__________________


Help me keep scripting
Reply With Quote
  #11  
Old 09-02-2003, 08:39 PM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
I took a physics course, and it was pretty easy, but I don't think I'd have the know-how to apply it to a script, I can think of some basic scripts.. but my knowledge in scripting isn't near some of yours, I will try to learn more scripting before I get into this...
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #12  
Old 09-02-2003, 09:30 PM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
same here. im still working on fairly simple things, and using every chance i get to look at new scripts posted here to learn from them.
__________________
Im still searching...
Reply With Quote
  #13  
Old 09-02-2003, 11:56 PM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by osrs


Yes,but since i'm studying it i know what i'm talking about.
You aren't the only one smart guy here.
Yes, but what you stated in that thread was clearly not made from your own words, but a copy+paste job, or a direct typing of a book definition. The diction and grammar contained therein are far superior to your own.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #14  
Old 09-03-2003, 12:18 AM
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
Quote:
Originally posted by TribulationStaff

Q: How do you add/subtract vectors?
A: It is easy, once in Cartesian coordinates. Let A=<a,b> and B=<c,d>. Then A+B=<a+c,c+d>.
that'll confuse somebody, hurry! fix it before some unsuspecting learner hits their head on it!

The most basic use of vectors in script is just movement, many people already use them without knowing it. Whenever you have a direction (i.e. angle, or even built in directions) and a speed (magnitude) you're using vectors. Using dx (delta x or distance x, whichever you say) and dy is also using vectors, cept they don't need translation (sin + cos) to be used on the board.

I'll post some basics in physics if anyone is interested and if Gilt doesn't mind.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #15  
Old 09-03-2003, 01:21 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by Tseng


Yes, but what you stated in that thread was clearly not made from your own words, but a copy+paste job, or a direct typing of a book definition. The diction and grammar contained therein are far superior to your own.
The best answer for you is:
Shh..
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #16  
Old 09-03-2003, 01:29 AM
marcoR marcoR is offline
Registered User
Join Date: Jul 2003
Posts: 1,349
marcoR is on a distinguished road
Lol Your both~ like stuped Lol~ man iM like so coOl`~)@@#!!

I think that did the job nicely.
__________________
If this is your account, contact me.
- loriel
email, jabber: [email protected]
icq: 67530805
aim: lorielvictrix
Reply With Quote
  #17  
Old 09-03-2003, 03:39 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by osrs


The best answer for you is:
Shh..
Awww, no way to combat my points with logic? That's too bad.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #18  
Old 09-03-2003, 04:13 AM
ShadowStrike2k1 ShadowStrike2k1 is offline
Banned
Join Date: Jul 2002
Posts: 215
ShadowStrike2k1 is on a distinguished road
Quote:
Originally posted by osrs


The best answer for you is:
Shh..

Osrs, I would follow your own instructions and "Shh.." Whats the use in fighting a fight that you cant win?
Reply With Quote
  #19  
Old 09-03-2003, 05:18 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by Tseng


Awww, no way to combat my points with logic? That's too bad.
I just don't care to what you say...
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #20  
Old 09-03-2003, 06:55 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Thanks for pointing out my typo, go ahead and do you physics stuff in a new thread.
__________________


Help me keep scripting
Reply With Quote
  #21  
Old 09-03-2003, 09:42 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
I had to learn polar coordinates and rectangular coordinates.

I needed to use them like constantly in AC electronics.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
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 06:23 PM.


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