Go Back   Wiremod Forums > Wiremod Skills > Wiremod Tutorials

Wiremod Tutorials Post your wiremod tutorials/guides here.

Reply
 
LinkBack Thread Tools Display Modes
Old 09-29-2008   #1 (permalink)
Wire Guru

 
Beer's Avatar
 

Join Date: Jul 2007
Location: Dallas, Texas
Posts: 536
Beer is on a distinguished road
Default Vector everything.

EDIT: This is a request.. forgot to tag the topic title.

I'm completely mystified by vectors. And I'm not just talking about vector thrusters, I'm talking about all the related functions and terminology (scalar, cross product, dot product, axis aligned velocity, up/down/forward vector, vector normalize, etc).

From the documentation:
Code:
vector(x, y, z)       : Create a vector for use with these functions
 
vecx(v)               : X component of the vector
vecy(v)               : Y component of the vector
vecz(v)               : Z component of the vector
 
vecpitch(v)           : Pitch for the vector
vecyaw(v)             : Yaw for the vector
 
veclength(v)          : Length of the vector
vecnormalize(v)       : Normalize the vector
 
vecadd(v1, v2)        : Add two vectors
vecsub(v1, v2)        : Subtract two vectors
vecmul(v1, v2)        : Multiply two vectors
 
vecsmul(v1, n)        : Multiply a vector by a scalar
vecsdiv(v1, n)        : Divide a vector by a scalar
 
vecdot(v1, v2)        : Dot product of two vectors
veccross(v1, v2)      : Cross product of two vectors
vecdistance(v1, v2)   : Distance between two vectors
 



extcolor(r, g, b) : Sets the color, 0-255
extcolor(r, g, b, a) : Sets the color, 0-255
 
extcolorr() : Returns the color (red component)
extcolorg() : Returns the color (green component)
extcolorb() : Returns the color (blue component)
extcolora() : Returns the color (alpha component)
 
extposx()   : Returns the position (x coordinate)
extposy()   : Returns the position (y coordinate)
extposz()   : Returns the position (z coordinate)
extpos()    : Returns the position (vector)
 
extvelx()   : Returns the velocity (x coordinate)
extvely()   : Returns the velocity (y coordinate)
extvelz()   : Returns the velocity (z coordinate)
extvel()    : Returns the velocity (vector)
 
extvelabsx()   : Returns the axis aligned velocity (x coordinate)
extvelabsy()   : Returns the axis aligned velocity (y coordinate)
extvelabsz()   : Returns the axis aligned velocity (z coordinate)
extvelabs()    : Returns the axis aligned velocity (vector)
 
extdirfwx() : Returns the forward vector (x component)
extdirfwy() : Returns the forward vector (y component)
extdirfwz() : Returns the forward vector (z component)
extdirfw()  : Returns the forward vector (vector)
 
extdirrtx() : Returns the right vector (x component)
extdirrty() : Returns the right vector (y component)
extdirrtz() : Returns the right vector (z component)
extdirrt()  : Returns the right vector (vector)
 
extdirupx() : Returns the up vector (x component)
extdirupy() : Returns the up vector (y component)
extdirupz() : Returns the up vector (z component)
extdirup()  : Returns the up vector (vector)
vecrotate(v, p, y, r) : Rotate a vector using pitch, yaw and roll
I'm not asking someone to explain each and every function.. but maybe an example of what some of them are used for and why they are used. I occasionally see people make contraptions or post code that looks something like "vecadd(vecsmul(extdirrt(), S-W), vecsmul(extdirfw(), D-A))".. and I have absolutely no idea how they come to a solution like that.. and I want to learn.

I watched revan's vector thruster tutorial and it explained almost nothing, just a tutorial how to build a particular contraption.

We need something in-depth about vectors here. I know there are many other people here as confused as I am about it all.
Beer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 09-29-2008   #2 (permalink)
Advanced Member
 
Whodunnit's Avatar
 

Join Date: Jan 2008
Posts: 176
Whodunnit is on a distinguished road
Default Re: Vector everything.

if you know what a vector is , thats a start.

anyway, a vector is a line in a direction, with x,y,z parameters. coordinates you use all the time with GPS, is jst teh direction vector to that point from teh origin

cross product between two vectors will give you the perpindicular vector to each.

scalar product of two vectors is this is this

Cos(angle betweenthem) = scalarproduct/(magnitudeofvector 1 *magnitude of vector 2)

Last edited by Whodunnit; 09-29-2008 at 10:28 PM..
Whodunnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-29-2008   #3 (permalink)
Member
 
zentiger's Avatar
 

Join Date: Jul 2007
Location: Norfolk, VA
Posts: 73
zentiger is on a distinguished road
Default Re: Vector everything.

Vector physics is complex.
I am on a quest to better understand this field as well, and have been searching for answers in much the same way with very similar results.
Here is an article that helped me understand it a little better.

A vector is an object that has both direction and length.
One important thing to remember is that a vector has a major component known as velocity,
which is speed and direction. Example: 5 mph North.

In what I have learned so far (which is not much, I admit) you would use vectors when determining direction, distance, and location that is relative to either a particular entity (a contraption, or a vehicle) or the player.
If you want to go left, your position afterward would be relative to the direction you are facing. You would get that direction by getting the forward vector:
Code:
Forward = extdirfw()
Once you have the forward vector you can get the right vector in much the same way.

Revan's vector thruster tutorial did show one thing I found useful, and that was how he got the vector between the contraption and the target. He did that by subtracting the base of the vector (the point of the local GPS) and the tail of the vector (the locator)

I would recommend reading that article in doses you find manageable. I initially found it rather daunting but a worthy challenge, and have found its benefits encouraging.

I wholeheartedly agree though that we should have some much better descriptions of this field - with examples of applications that people have found useful.
__________________
"Not everything that counts can be counted, and not everything that can be counted counts." -Sign hanging in Albert Einstein's office at Princeton
Has the LHC Destroyed the Earth?
zentiger is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #4 (permalink)
Wire Dev - Thruster God
 
Shandolum's Avatar
 

Join Date: Apr 2007
Location: Europe -> Denmark
Posts: 877
Shandolum has a spectacular aura aboutShandolum has a spectacular aura aboutShandolum has a spectacular aura about
Send a message via MSN to Shandolum
Default Re: Vector everything.

the vector functions of the expression gate 1, is only experimental, and can't really be used for anything else than calculations within the gate. also the syntax:
vecadd(vector(X,Y,Z),vector(0,0,64)):normalize() ect.....
is highly inefficient, but this will be much better with expression 2.
But really. Vectors are only for those who have knowledge within them.
__________________
Everything can be improved upon. Nothing is Perfect.
The only way to move forward, is to surpass what has already been done.
Creator of many things.
Shandolum is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #5 (permalink)
Wire Guru

 
Beer's Avatar
 

Join Date: Jul 2007
Location: Dallas, Texas
Posts: 536
Beer is on a distinguished road
Default Re: Vector everything.

Thanks for the replies. I started to sort of skim the wikipedia page and I think I'm starting to understand it a little bit. Keyword little.

One thing I'm not understanding, is that if you create a vector(x,y,z) (which is only one point in 3d space), how does vecyaw(), veclength(), vecpitch(), etc know how to determine the values? You can't determine yaw, pitch, or length with only one point. Now, I would understand if you feed a vector thruster an X,Y,Z.. it would know where to point to because it has two coordinates: one of them where the thruster is, one where the values you input are. From there it can determine which way to point (am I on track here?).

But for basic calculations, I don't see how you could possibly find the veclength() for example with a single point.

i.e.

V=vector(10,20,30)
Length=veclength(V) <-- makes no sense to me

Last edited by Beer; 09-30-2008 at 01:30 AM..
Beer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #6 (permalink)
Wire Dev - Thruster God
 
Shandolum's Avatar
 

Join Date: Apr 2007
Location: Europe -> Denmark
Posts: 877
Shandolum has a spectacular aura aboutShandolum has a spectacular aura aboutShandolum has a spectacular aura about
Send a message via MSN to Shandolum
Default Re: Vector everything.

you are forgetting that vectors are not as simple as single points. they can be the difference between 2 points, movement, and a lot of other things. the pitch and yaw is found from the world. it is the difference of angles between the (1,0,0) vector of the world, and the vector that you have.
Vectors are really useful, but they require that you know how to use them.
also the length of a vector can be found via.

X^2+Y^2+Z^2=Length^2
so vector(10,20,30) would equal 30 in length
10*10+20*20+30*30 = 900
square root of 900 is 30
__________________
Everything can be improved upon. Nothing is Perfect.
The only way to move forward, is to surpass what has already been done.
Creator of many things.

Last edited by Shandolum; 09-30-2008 at 01:50 AM..
Shandolum is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #7 (permalink)
Wire Guru

 
Beer's Avatar
 

Join Date: Jul 2007
Location: Dallas, Texas
Posts: 536
Beer is on a distinguished road
Default Re: Vector everything.

Quote:
Originally Posted by Shandolum View Post
you are forgetting that vectors are not as simple as single points. they can be the difference between 2 points, movement, and a lot of other things. the pitch and yaw is found from the world. it is the difference of angles between the (1,0,0) vector of the world, and the vector that you have.
Vectors are really useful, but they require that you know how to use them.
Oh, I get it. Thanks for the help. I'm still quite a ways away from knowing how it all works, but I'm starting to understand.

"Vectors are really useful, but they require that you know how to use them."

Gotta start somewhere.


EDIT: Since you edited and added some extra text (which was very helpful).. let me take a stab at something. If, instead of entering coordinates, I entered velocity (or the absolute of rate of change) along the X, Y and Z axis, the vector of those values would be the overall 3D velocity in any direction. Which would essentially be like a speedometer. Am I right?

Last edited by Beer; 09-30-2008 at 02:05 AM..
Beer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #8 (permalink)
Advanced Member
 
Whodunnit's Avatar
 

Join Date: Jan 2008
Posts: 176
Whodunnit is on a distinguished road
Default Re: Vector everything.

yeah, like i said, a cordinate given to you by GPS is actually just the direction vector from from the origin.
Whodunnit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #9 (permalink)
Wire Guru
 
Syranide's Avatar
 

Join Date: Mar 2007
Posts: 2,033
Syranide has disabled reputation
Default Re: Vector everything.

Quote:
Originally Posted by Beer View Post
Oh, I get it. Thanks for the help. I'm still quite a ways away from knowing how it all works, but I'm starting to understand.

"Vectors are really useful, but they require that you know how to use them."

Gotta start somewhere.


EDIT: Since you edited and added some extra text (which was very helpful).. let me take a stab at something. If, instead of entering coordinates, I entered velocity (or the absolute of rate of change) along the X, Y and Z axis, the vector of those values would be the overall 3D velocity in any direction. Which would essentially be like a speedometer. Am I right?
What you need to know about vectors is that first of there are basically two types of vectors, "vectors" and "direction vectors". A vector specifies a point in space, whereas a direction vector gives specifies a direction in space (these mostly have length = 1).

Another important thing is to understand that a direction vector only specifies the pitch and yaw (or properly, elevation and bearing), not the roll, but roll cannot be determined from a vector.

So, in a nutshell, vectors define position or movement in space, and provides the means of transforming between these two. So if you have two vectors, and do "A-B" you will get a vector that describes the direction from A to B. Another common use is if you want to extract the three axis vectors of a ship, then it is enough to only have two, then you take the cross-product of those two vectors and you get the third.

The rest is just about understanding the possibilties of vectors and how they are used.
Syranide is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-30-2008   #10 (permalink)
Wire Guru

 
Beer's Avatar
 

Join Date: Jul 2007
Location: Dallas, Texas
Posts: 536
Beer is on a distinguished road
Default Re: Vector everything.

Ok, I'm starting to catch on. I made my first simple vector contraption. And it actually worked on the first try and did exactly what I expected.

Basically, it's just two melons (so you can see them) with a GPS welded to them. Two vectors are created with the coordinates of each GPS, then subtracted to produce a direction vector. Doing this, I can create a vector thruster that fires in a direction relative to the 2 melons.

Didn't feel like waiting for youtube to process a video, so here's a gif:




I'm beginning to understand. I do still think there needs to be an in-depth tutorial on the subject though for everyone to use.
Beer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 11:57 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.

Page top