• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Vector Sum

Status
Not open for further replies.
Level 20
Joined
Jul 6, 2009
Messages
1,885
In my map, i thought of using a simple 2D vector system with each vector having it's intensity and direction. Now i'm having problem summing 2 vectors.
I think i'm overcomplicating this, but here's the way i did it and it seems to return wrong values.

Given 2 vectors, i first determine which vector has greater angle so i have a geometric representation.
attachment.php

In the picture, i can find angle alpha since i have angles of vector 1 and 2. The beta angle is, from picture, 180 - alpha. With this, i used cosine law (c^2 = a^2 + b^2 - 2abcos(gamma) ) to determine result vector's intensity. Using sine law (a/sin(alpha) = b/sin(beta) = c/sin(gamma) ) i can determine angles between result vector and 2 vectors in which case i can add or subtract angles of 2 vectors to find the angle of resulting one

Is there another way or am i doing something wrong?
 

Attachments

  • vectors.jpg
    vectors.jpg
    24 KB · Views: 1,253
A vector has x and y components, which can be retrieved by sin(angle of vector)*magnitude of vector (y) and cos(angle of vector)*magnitude of vector (x) where the angles are in radians. Once you retrieve the components, you can then add them. This is the only way to add 2 vectors together mathematically (w/o like pencil + paper).

To put them back together, get the magnitude of the resulting vector.

So

||v|| = rt(x^2+y^2)

vx = m*cos(a)
vy = m*sin(a)
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
A vector has x and y components, which can be retrieved by sin(angle of vector)*magnitude of vector (y) and cos(angle of vector)*magnitude of vector (x) where the angles are in radians. Once you retrieve the components, you can then add them. This is the only way to add 2 vectors together mathematically (w/o like pencil + paper).

To put them back together, get the magnitude of the resulting vector.

So

||v|| = rt(x^2+y^2)

vx = m*cos(a)
vy = m*sin(a)
Thanks for explanation :]
So the length/magnitude of vector is represented by distance of x,y from 0,0 in coordinate system, eh?

Gotta spread rep before giving it to Nestharus again =[
 
A bird moving 3 m/s south... subtract 1 m/s northeast wind and find new velocity of bird due south.

First, you get the x,y components of both magnitudes, then you subtract, then you get magnitude of resulting vector.

Now, how do those numbers have anything to do with distance? :p

The bird could be at point 19,30 and the wind could be coming from point 3948398492, -2342389343

Vector has nothing to do with distance ;p, but it's like exacto to a line segment =D, the math is the same on both >.>.


It's almost like Blizzard invented vectors... rofl

Whenever I see something idiotic, I just say Blizzard made it ;D
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
A vector has x and y components
Wrong.

A vector has any number of components.

Generally for space calculations they are 3 dimensional but for solving differential equations it is possible to get them easilly going beyond that.

Additionally, when mapping a series of simultanious equations into a matrix and vector it is easilly possible to get a vector with a dimension greater than 3.

Some forms of mathematics can be applied only to vectors of a certain dimension. For example finding a vector which is perpendicular to 2 vectors is only possible on 3 and apparently 7 dimensional vectors.

You can invision a vector as sort of a n by 1 matrix where n is the dimension.

Vector has nothing to do with distance
The relationship logic is
All distances are a vector (distance being 1 dimensional while displacement being 2 or 3 dimensional).
All vectors are not a distance (as there are other units which use vectors).
 
Level 4
Joined
Jan 27, 2010
Messages
133
Oh! Nitpicking, are we!? :grin:

Vector has nothing to do with distance ;p, but it's like exacto to a line segment =D, the math is the same on both >.>.
.

Actually, the strict mathematical definition of a vector is pretty much a set of ordered numbers. For instance:

(1, 3, 7, PI)

If you chose to interpret them as distance in time and space; or position in time and space is up to you.

In a more physical sense, a vector is a value with a direction. Like speed; or acceleration. It COULD however be a position as well.
 
That was in response to DSG, not you =).

Tx for ripping this part out to make it seem like I was responding to you ;D
Yes, I know that DSG

He had all the info and math he needed when I first replied. DSG helped to clarify things about the definition of a vector ^)^. At this point, it's starting to turn into a huge pointless debate on what a vector is ^)^. All he needs to know is how to use it for what he is doing ;p.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Nestharus you're too subjective when you're explaining things. You talk about it as if you invented vectors. Tell the facts, not your opinions of the facts. That's one of the reasons why wc3c.net is such an out-of-tune community. They talk with nothing but opinions.

It's almost like Blizzard invented vectors... rofl

Whenever I see something idiotic, I just say Blizzard made it ;D

Like this.

Now, how do those numbers have anything to do with distance? :p

The bird could be at point 19,30 and the wind could be coming from point 3948398492, -2342389343

Vector has nothing to do with distance ;p, but it's like exacto to a line segment =D, the math is the same on both >.>.

And this.

A vector has x and y components, which can be retrieved by sin(angle of vector)*magnitude of vector (y) and cos(angle of vector)*magnitude of vector (x) where the angles are in radians. Once you retrieve the components, you can then add them. This is the only way to add 2 vectors together mathematically (w/o like pencil

And this.
 
Last edited:
Level 20
Joined
Jul 6, 2009
Messages
1,885
Nestharus you're too objective when you're explaining things. You talk about it as if you invented vectors. Tell the facts, not your opinions of the facts. That's one of the reasons why wc3c.net is such an out-of-tune community. They talk with nothing but opinions.
I think you mean subjective ;D
Objectivity is based off facts, subjectivity off opinion/s.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
His minitutorial on how to convert from a polar to a coordinate vector seems fine though.

I was commenting on how this concept of converting Cartesian coordinates to Polar coordinates is nothing foreign in Warcraft. It wasn't a very useful comment, but then neither were the last several comments.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The conversion between the two has become as simple as addition for me. Forgive me. As for the order, well that is just inconsequential. To object though this is not the first tutorial ever given on how to convert Polar coordinates to Cartesian coordinates. If you Google "wc3 polar coordinates" there are a few links on the first page that explain the conversion. Just because an enormous majority of people do not know how to make this conversion doesn't mean I can't brush it off as simple.
 
It gets taught at pre calc, which is beyond where quite a lot of people get to. I've seen enough people end at geometry.

Geometry -> Algebra 3-4 -> Pre-Calc

What's most surprising though is that delta isn't taught until calculus.... and delta is what slope is, which is taught in algebra 1-2

I'd like to take this moment to point out that I think the education system, at least when it concerns math, is totally fudged ;P.

Oh yea, and calc 1 and calc 2 are pretty darn useful. If you had a set of seemingly random data generated from an algorithm, you could actually come up with the equation that generates that data. First you get the derivatives until you get down to a constant (when I had data, had to do it 4x), then you take go backwards taking the integral of your constant and adding new constants in (came up with some crazy polynomial that generated seemingly random numbers, lol...)

Anyways, back on topic... the op only needed the equations I provided him... the rest of this stuff could just as easily go into an off topic discussion labeled math education, or something : P.

Oh yea, and what I find really funny is that people can understand this just fine
function hello takes nothing returns nothing
endfunction

but not this
f(x,y) = x+y
f(3,3) = ?

I drilled someone for a couple of hours that knew JASS and they couldn't tell me the answer =P.

What that tells me is that people memorize the stuff, they don't actually understand it >.>. If they did, they could translate it over to w/e... memorizing things seems to be the problem a lot of people face, especially in education... very few people actually learn and understand the stuff.
 
I'd like to take this moment to point out that I think the education system, at least when it concerns math, is totally fudged ;P.

you are still very lucky
In my school one does not learn anything about vectors at all
nevertheless we learn matrix math....

I heared that it is possible to rotate a vector A around vector B so that it would be like B was the x-axis

I also saw a formular which reflects a vector from a line segment
it works somehow with making a perpendicular vector to the line segment and then doing some magic
pretty awesome since it does not require slow sin/cos

so if anyone can find himself some time to explain it I'd be happy :grin:
 
You learn all of that stuff in calc 3, including major matrix math (first portion of class). It goes further in linear algebra I think? : )

yea, matrices are covered in algebra 3-4 to a small degree, but vectors aren't covered until calc 3. Also, matrices really become prevalent in calc 3 =o.

I guess you do learn about delta and vectors in physics though, but eh ^)^.
 
I guess you do learn about delta and vectors in physics though, but eh ^)^.

when we had to we were building water rockets (mine was best :)

usually we learned the math we have to use in physics one year later but now I'm in grade 13 so there won't be another year of math after that

school system in germany is damn retarded

fortunately one can learn a lot from warcraft 3
 
Status
Not open for further replies.
Top