• Create Account

Banner advertising on our site currently available from just \$5!

# 3D Line Equation?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1Motoky  Members   -  Reputation: 183

Like
1Likes
Like

Posted 14 August 2014 - 05:03 AM

I am currently learning from a book called Beginning Maths and Physics for Game Programmers. I had trouble with this book quite early on due to the fact that I had completely forgotten most of the maths I had learnt at school so I went through some Algebra and Linear Algebra books to help me and I feel I am doing better with this book, this time around.

Now, I am confused about a question in the book. It says, "Find the equation of a line connecting the following pairs of points:"

It continues to list a few points for a 2D coordinate system, but the last two is a 3D coordinate system and the two points for one of the questions are:

(2, 0, -1) and (3, 4, 5)

Now, the book doesn't tell you at all how to find out how to get the equation of three points, only two. I have tried applying different ways of doing it, but it never turns out right. I would have thought, when you come to exercises or tasks, you should be at least taught how to do it and not thrown into the dark because you learnt how to do the bare minimum.

### #2Paradigm Shifter  Crossbones+   -  Reputation: 5507

Like
2Likes
Like

Posted 14 August 2014 - 05:57 AM

It's the same equation,

p = a + (b-a) * t

where a and b are the endpoints of the line and t ranges from 0 to 1 (unless you want the infinite line through the points, where t can be any real number).

Just set a = (2, 0, -1) and b = (3, 4, 5) and you are good to go... isn't that what you did in the 2d case?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #3Motoky  Members   -  Reputation: 183

Like
0Likes
Like

Posted 14 August 2014 - 06:28 AM

For 2D, the book gives you this formula to get the equation:

(y - y1) = m(x - x1)

y1 and x1 being the first coordinates. m being the slope.

So, one of the questions in the book is to find the equation of 2D points as well, like:

(0, 10) and (5, 0)

(y - 10) = m(x - 0)

m = (0 - 10)/(5 - 0) = (-10)/5 = -2

y - 10 = 2x

y = 2x + 10

Anyway, there is only a little bit of info in the book, the answer isn't even an equation, but it's a vector...

You have:

Δx = x2 - x1

Δy = y2 - y1

Δz = z2 - z1

So with the coordinates, (2, 0, -1) and (3, 4, 5), it would be:

Δx = 3 - 2 = 1

Δy = 4 - 0 = 4

Δz = 5 - (-1) = 6

This is why I was confused because it was asking for an equation, not a vector... The answers were a bit further on. So I got them right, but it wasn't really worded very well because I was trying to find an equation...

Thanks anyway.

### #4Álvaro  Crossbones+   -  Reputation: 14635

Like
2Likes
Like

Posted 14 August 2014 - 06:48 AM

What Paradigm Shifter posted is a parametric equation. What you seem to be looking for is an implicit equation. The problem is that a single linear equation in R^3 describes a plane, not a straight line. You can use two equations to describe your line, for instance like this:

4*x -13*y +8*z = 0
3*y -2*z = 2

### #5tonemgub  Members   -  Reputation: 1435

Like
0Likes
Like

Posted 14 August 2014 - 06:59 AM

Δx = 3 - 2 = 1
Δy = 4 - 0 = 4
Δz = 5 - (-1) = 6

I think this is just a hint towards the proper equation - the Δ values represent only the (b-a) vector from Paradigm Shifter's answer. Sometimes, books don't give you full answers for the exercises, just because they want you to figure out stuff by yourself.

But some commenters on Amazon say that this book is filled with errors, so who knows... Maybe you should focus on the theory rather than the exercises.

Edited by tonemgub, 14 August 2014 - 07:04 AM.

### #6Motoky  Members   -  Reputation: 183

Like
1Likes
Like

Posted 14 August 2014 - 08:36 AM

I've come across some books that are really detailed and go through how they solve something and I prefer. I hate books that just give you an answer without any meaning behind it and expect you to figure out for yourself if you don't have a clue what some symbols might even mean or why nothing is actually showing up on the internet because they have written it down differently.

Anyway, I got passed that and onto the next set of exercises which is about finding the slope, y-intercept for each equation and the number of solutions. Well, I thought that a system of equations had to consist of more than one equation, if they don't, then I am completely lost because not even my previous books showed a system of equations with just one equation...

Anyway, the equation is:

x + y = 7

So the slope would be -1. The y-intercept would be: y = -x + 7.

Earlier in the book it tells you that to find out how many solutions a system of equations has by checking to see if the slopes of both equations are the same. If they are NOT the same, it has one solution, if it does, you then need to find the y-intercept and check to see if b1 and b2 are the same. b1 in this question would be 7.

So I have m1 = -1, and b1 = 7. The answer gives me that, but with m2 = 1/3 and b2 = 2/3, with only one solution.

I know you mentioned that I should focus on the theory and I guess understanding how it works, but I just wish someone could shed some light on this one so I can move on. If all of the exercises are like this, where they are giving me false answers or not explaining how they got the answer, I just don't see the point in the exercises...

### #7Álvaro  Crossbones+   -  Reputation: 14635

Like
1Likes
Like

Posted 14 August 2014 - 08:44 AM

It looks like the book is missing a second equation in that system. It's probably this one:

-x + 3*y = 2

Someone said that the book is known to have mistakes. If this bothers you, perhaps you should get a different book.

Edited by Álvaro, 14 August 2014 - 11:27 AM.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS