PDA

View Full Version : Im slightly stuck with Vectors


silverspawn
17-12-2010, 06:00 PM
Im trying my hand at vectors trying to grasp more about object in a 2d and 3d space but struggling wondering if anyone could help at all got the basic concept out the way of vectors to having hard time grasping the next stage

If a 2d line passes though Po(10,15) and P1(150,300) I am trying to find the equation of the line ?

And also find the distance from point P(-500,400) to the line?

Thnaks in advance

elephantinc
17-12-2010, 06:26 PM
The general equation is y=mx+c
Where m is the gradient and c is a constant (the Y intercept)

You can work out m by constructing a triangle between the two points, (see pic). The height/width gives you the gradient, so in this case it would be 285/140 (just over 2).
You are then left with y=2m+c and you can work out C by putting in some values for x and y (from your points). I'll use 10 and 15 since they're smaller.
15=10*2+c
15=20+c
c=-5 (roughly since m isn't exactly 2)
so the equation is y=2m-5

silverspawn
18-12-2010, 07:01 PM
Thanks elephantinc

That sure is impressive I am finding vectors and matrices harder than modelling :)

do you know anything about matrices at all could i am struggling with this too?

the basics to vectors are pretty straight forward , but with matrices not got a great deal of knowledge or lit on the topic

I came across these but not sure how to work it out;


A =(1 -2 3) (3 1 5) (0 1 -3) B = ( 1 -8) (-9 8 )(2 4 )


Find A x B


2 (a) write out the rotation matrix that rotates an 2D object counterclockwise by 45 degrees by the coordinate origin.

b) suppose the three vertices of a triangle are A(0,0), B(10,5) and C(5,8) .Where are the vertices after the triangle is rotated counterclockwise 45 degrees by the coordinate origin?

Any help guidance would be greatful


Jt

maheshsubbiah
18-12-2010, 07:31 PM
Silverspawn

Check this link.

May be its of help to you

http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm

Mahesh

Chirone
18-12-2010, 10:45 PM
A =(1 -2 3) (3 1 5) (0 1 -3) B = ( 1 -8) (-9 8 )(2 4 )
Find A x B

find the cross product of those two matrices?
im not sure i understand your equation though. I thought cross product is done between vectors and the way you typed A and B doesn't make sense. are the stuff in () columns or rows?
a matrix is a 'grid' of numbers like

3 5 6
4 4 4
1 2 2
the cross product of two vectors gives you the vector that's perpendicular to the two vectors...


2 (a) write out the rotation matrix that rotates an 2D object counterclockwise by 45 degrees by the coordinate origin.

b) suppose the three vertices of a triangle are A(0,0), B(10,5) and C(5,8) .Where are the vertices after the triangle is rotated counterclockwise 45 degrees by the coordinate origin?
2a is trivial, you can look on the internet for what the rotation matrix is. (wikipedia has such info)
once you've done that and told us what you've found then someone could give you an example on how to resolve 2b

ctbram
19-12-2010, 12:49 AM
There are generally two useful forms to describe a line, the one everyone remembers (slope-intercept), which is generally less useful and the more useful (point-slope) form. The reason (point-slope) form is more useful is because we are almost always given enough information in a question to derive a point and the slope directly.

Here are the two forms:

(slope-intercept): y = mx + b ;where m=slope=dy/dx and b=the y-intercept (eq.1)

(point-slope): y-y1 = m(x-x1); where m=slope=dy/dx and (x1,y1) is a point on the line (eq.2)

So for your first problem we are given p1(10,15), p2(150,300)

therefore the slope m=dy/dx=(y2-y1)/(x2-x1)=(300-15)/(150-10)=285/140 which is ~2.04. (eq.3))

So now we have all we need to determine the equation for the line using (point-slope) form (eq.2) and using p1(10,15) we get:

L1: y-15 = (285/140)(x-10)
y=(285/140)x-(2850/140)+15
y=(285/140)x-(2850/140)+(2100/140)
y=(285/140)x-(750/140) <==== here is your first answer the eq of L1

Therefore the y-intercept of this line using (eq.1) is b=-(750/140) ~ -5.4

To check lets use p2(150,300) and (point-slope) (eq.2) to verify that

y=(285/140)x-(750/140) substituting p2(150,300) we get

300=(285/140)(150) - (750/140) ................ which is true

ctbram
19-12-2010, 01:06 AM
the next part is also easy. given p3(-500,400) then the shortest distance to L1 is a line that from p3 to L1 is perpendicular to L1 and we will call it L2. If the slope of L1 is m then the slope of L2 (m2) will be -(1/m) or m2 = -(140/285). Now just use point-slope with p3 and m2 to find the equation of L2:

L2: y-400 = m2(x + 500)
y = -(140/285)(x+500)-400

I'll let you reduce this.

Now with the equation of L1 and L2 you can find the x intersection by setting L1 = L2 and solving for x.

L1 = L2
(285/140)x-(750/140) = -(140/285)(x+500)-400
solve for x

now plug x into either L1 or L2 and get y.

P4(x,y) is the perp intersection of L1 and L2. Now use P3 and P4 to compute the shortest distance from P3 to the line L1 where dist = sqrt(dy^2 + dx^2).

dist_p3.p4 = sqrt((y4 -y3)^2 + (x4-x3)^2) <===== this is your second answer you just need to solve for p4(x4,y4) using the stuff above.

silverspawn
19-12-2010, 08:12 AM
Thanks guys although not completly crystal clear at the moment it kinda making sense in a strange beginners way, It kinda gets annoying when you have something like this that you really want to learn, but like when I was in colleage there is no one to go through it step by step, but thanks for the prompt response guys will have a go at a few others and try implement the methods you have showed me :)

silverspawn
19-12-2010, 08:27 AM
find the cross product of those two matrices?
im not sure i understand your equation though. I thought cross product is done between vectors and the way you typed A and B doesn't make sense. are the stuff in () columns or rows?
a matrix is a 'grid' of numbers like

3 5 6
4 4 4
1 2 2
the cross product of two vectors gives you the vector that's perpendicular to the two vectors...


2a is trivial, you can look on the internet for what the rotation matrix is. (wikipedia has such info)
once you've done that and told us what you've found then someone could give you an example on how to resolve 2b

Is 2a something along the line like this


R =
cos(45degrees) -sin(45degrees)
sin (45degrees) cos(45degrees)


At ctbram and elephantinc are the methods and answers you both give me the same but in different concept of how you work them out ???

Thnask again guys for taking time for my annoyance.....promise to post something maya up within the next few weeks :)

Chirone
20-12-2010, 07:15 AM
Is 2a something along the line like this
R =
cos(45degrees) -sin(45degrees)
sin (45degrees) cos(45degrees)
that's a rotation matrix.
but you see how it's only a 2x2 matrix? (pronounced 2 by 2)
that means it only applies in 2D space because it can only be multiplied by 2 dimensional vectors (vectors with 2 components in them such as (2,3))
the second sentence in this link: http://en.wikipedia.org/wiki/Rotation_matrix explains so

3D has x, y, and z.
see if you can find the rotation matrix for that.
actually, there are a few, one that rotates around x, one that rotates around y, and one that rotates around z, and one that is all of them at once.

wait, i just re-read your second question in your second post. yeah, the 2d rotation matrix is the one you want..

bullet1968
20-12-2010, 07:26 AM
God that all looks so bloody complicated

Chirone
20-12-2010, 07:29 AM
well i dont want to spoon feed him or else he wont learn anything, but yeah, it is pretty tough to get your head around
i know i struggled with it for a while, but it was mostly because the notation is crazy...

bullet1968
20-12-2010, 07:47 AM
LOL furry muff mate.......I stopped all that YEARS ago....now the software does it...dont worry though I had to write my own vector and co-ord programs....on an 11C Hewlett Packard was the first...then the HP32...what a pain..good luck people...you can have it...done my time in the trenches.

cheers bullet

ctbram
20-12-2010, 09:48 AM
This is not rocket science guys. You only need to know 4 things to solve what silver is asking:

1. y-y1 = m(x-x1) .... the point-slope form of a line

2. slope m = dy/dx given two points p1 and p2 m = (y2-y1)/(x2-x1)

3. if L1 has a slope of m and is perpendicular to L2 then L2 has a slope of -1/m

4. dist btween two points p1 and p2 is dist = sqrt(dy^2 + dx^2) = sqrt((y2-y1)^2 + (x2-x1)^2)

With those four things you can solve for all the things he asked for.

and I have no idea why he is asking about 2D rotation matrices when his question is about finding the equation of a line given two points and the shortest distance from a point to line, unless this is all just a joke and he is trying to see how much time he can make people waste.

In fact his second question was "what is the distance from p3(-500,400) to line L1?" Well, silver if that is the exact question you were asked then there are an infinite number of answers. PROOF: L1 is infinite and therefore has an infinite number of points, so you can draw an infinite number of lines from p3 to any point on L1 and therefore compute a distance for each line drawn and thus have an infinite number of distances from p3 to the line L1. QED

Note: even if L1 is just the line segment from p1 to p2 it still has an infinite number of points that can be defined along the line and therefore would have an infinite number of lines that could be drawn from a point on L1 to the point p3. So the proof above still holds true. QED

Chirone
20-12-2010, 11:18 AM
ctbram, i was referring to his second question in his second post
i forgot part way through my earlier reply to his rotation matrix that it was 2D space he was working in for that question.
in which case all he has to do is turn his points into column vectors and multiply it by the rotation matrix

silver: a column vector is a vector where the numbers are listed vertically.
eg,
(1
2)
is a column vector because the numbers are going down, as opposed to
(1,2)
which is a row vector because the numbers are going across ways

basically, the way the vector is written influences the result when you multiply it by a matrix.
do you need an example of a vector multiplied to a matrix?


This is not rocket science guys.:yellowcarded:

ctbram
20-12-2010, 11:36 AM
nah did not mean to pick on you chirone. was just getting confused because it's really elementary geometry here and the switch to the 2D rotation matrix just seemed to be a complete non sequitur.