Thursday, November 21, 2013

Vector!!!!......is back. dendenduuuuuuuuuun!

Direction
Magnitude
X components
Y components
                 Those are what vectors have. Ever watch Despicable Me? Well the rival bad guys name is vector,now your going to learn what a vector is. A vector is an arrow with direction,which is what "direction" the arrow points in,and magnitude,which is how long or short the arrow is. When you subtract 2 vectors then there is a result vector which is a different colored vector that connects the tips of the 2 other vectors to finish the shape. Then there's adding vectors. When you add vectors the 2nd vector starts from the tip of the 1st vector.  On a graph,vectors start from the origin (Middle point) for instance: when you subtract vectors then the vectors start from the origin and the result vector connects the tips of the 2 vectors. But when your adding vectors the 1st vector starts from the origin and the 2nd vector starts from the tip of the 1st one,and the result vector starts from the origin.

     Here's what some vector addition would resemble to:

    Here's what some vector subtraction would look like:

            The blue vectors are the vectors that I've been talking about and the red vector is the result vector. Now I'm going to talk about X components and Y components. The X component is how far right or left the vector points. And the Y component is how far up or down the vector points. When you add vectors you add the individual components,for example:if my X component for one vector was 3 and my Y component was 5 then if I add that to another vector that has a X component that's 4 and a Y component that is 2 then my result vector would be X 7 Y 7. And for subtraction it's the same thing.

Now I'm going to talk about scalar multiplication. There are 2 sliders that we haven't used yet called the scalars. The scalars are multiplication sliders that are usually at 1 because 1 times anything is exactly that value but If you change that 1 to a 2 then it will double the magnitude and change the direction of the vectors.
For example: here are my vectors with scalars of 1.

And here are vectors with scalars of 2.
I bet you can see the difference huh? Well even though they aren't the same size they are the same shape. Oh and make sure that you change the scalar for both vectors not just 1.

And last but not least here is my program:

float myFloats[6];

void CollinsBasicVectorEquationCallback(const BasicVectorEquationInfo& data)
{
myFloats[0]=data.x1*data.scalar1;
myFloats[1]=data.y1*data.scalar1;
myFloats[2]=data.x2*data.scalar2;
myFloats[3]=data.y2*data.scalar2;

if(data.add)
{
myFloats[4]=myFloats[0]+myFloats[2];
myFloats[5]=myFloats[1]+myFloats[3];
}
else
{
myFloats[4]=myFloats[0]-myFloats[2];
myFloats[5]=myFloats[1]-myFloats[3];
}

}  
Catch you later! 

No comments:

Post a Comment