17122010, 06:00 PM  #1 
Registered User
Join Date: Aug 2008
Location: U.K.
Posts: 223
Thanks: 0
Thanked 21 Times in 21 Posts

Im slightly stuck with Vectors
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 
17122010, 06:26 PM  #2 
Level 32 pachyderm
Join Date: Dec 2007
Location: England
Posts: 1,859
Thanks: 12
Thanked 43 Times in 37 Posts

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=2m5
__________________
http://users.ecs.soton.ac.uk/as28g11/ Last edited by elephantinc : 17122010 at 06:29 PM. 
18122010, 07:01 PM  #3 
Registered User
Join Date: Aug 2008
Location: U.K.
Posts: 223
Thanks: 0
Thanked 21 Times in 21 Posts

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 
18122010, 07:31 PM  #4 
Registered User
Join Date: Mar 2009
Location: India
Posts: 145
Thanks: 2
Thanked 21 Times in 19 Posts

Silverspawn
Check this link. May be its of help to you http://www.euclideanspace.com/maths/...tion/index.htm Mahesh 
18122010, 10:45 PM  #5  
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
Thanks: 11
Thanked 147 Times in 143 Posts

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 Code:
3 5 6 4 4 4 1 2 2
once you've done that and told us what you've found then someone could give you an example on how to resolve 2b
__________________
that's a "Ch" pronounced as a "K" Computer skills I should have: Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D 

19122010, 12:49 AM  #6 
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,996
Thanks: 42
Thanked 582 Times in 532 Posts

There are generally two useful forms to describe a line, the one everyone remembers (slopeintercept), which is generally less useful and the more useful (pointslope) form. The reason (pointslope) 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: (slopeintercept): y = mx + b ;where m=slope=dy/dx and b=the yintercept (eq.1) (pointslope): yy1 = m(xx1); 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=(y2y1)/(x2x1)=(30015)/(15010)=285/140 which is ~2.04. (eq.3)) So now we have all we need to determine the equation for the line using (pointslope) form (eq.2) and using p1(10,15) we get: L1: y15 = (285/140)(x10) 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 yintercept of this line using (eq.1) is b=(750/140) ~ 5.4 To check lets use p2(150,300) and (pointslope) (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
__________________
"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675 Last edited by ctbram : 20122010 at 01:36 PM. 
19122010, 01:06 AM  #7 
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,996
Thanks: 42
Thanked 582 Times in 532 Posts

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 pointslope with p3 and m2 to find the equation of L2:
L2: y400 = 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 + (x4x3)^2) <===== this is your second answer you just need to solve for p4(x4,y4) using the stuff above.
__________________
"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675 Last edited by ctbram : 20122010 at 01:37 PM. 
19122010, 08:12 AM  #8 
Registered User
Join Date: Aug 2008
Location: U.K.
Posts: 223
Thanks: 0
Thanked 21 Times in 21 Posts

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

19122010, 08:27 AM  #9  
Registered User
Join Date: Aug 2008
Location: U.K.
Posts: 223
Thanks: 0
Thanked 21 Times in 21 Posts

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 

20122010, 07:15 AM  #10  
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
Thanks: 11
Thanked 147 Times in 143 Posts

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 reread your second question in your second post. yeah, the 2d rotation matrix is the one you want..
__________________
that's a "Ch" pronounced as a "K" Computer skills I should have: Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D Last edited by Chirone : 20122010 at 11:09 AM. 

20122010, 07:26 AM  #11 
Lifetime Member
Join Date: Feb 2010
Location: Australia
Posts: 4,255
Thanks: 158
Thanked 651 Times in 621 Posts

God that all looks so bloody complicated
__________________
bullet1968 "A Darkness at Sethanon", a book I aspire to model some of the charcters and scenes 
20122010, 07:29 AM  #12 
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
Thanks: 11
Thanked 147 Times in 143 Posts

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...
__________________
that's a "Ch" pronounced as a "K" Computer skills I should have: Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D 
20122010, 07:47 AM  #13 
Lifetime Member
Join Date: Feb 2010
Location: Australia
Posts: 4,255
Thanks: 158
Thanked 651 Times in 621 Posts

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 coord 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
__________________
bullet1968 "A Darkness at Sethanon", a book I aspire to model some of the charcters and scenes 
20122010, 09:48 AM  #14 
Moderator
Join Date: Jan 2004
Location: Michigan, USA
Posts: 2,996
Thanks: 42
Thanked 582 Times in 532 Posts

This is not rocket science guys. You only need to know 4 things to solve what silver is asking:
1. yy1 = m(xx1) .... the pointslope form of a line 2. slope m = dy/dx given two points p1 and p2 m = (y2y1)/(x2x1) 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((y2y1)^2 + (x2x1)^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
__________________
"If I have seen further it is by standing on the shoulders of giants." Sir Isaac Newton, 1675 Last edited by ctbram : 20122010 at 10:00 AM. 
20122010, 11:18 AM  #15 
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
Thanks: 11
Thanked 147 Times in 143 Posts

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, Code:
(1 2) Code:
(1,2) 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?
__________________
that's a "Ch" pronounced as a "K" Computer skills I should have: Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D 