Featured Posts

8. Bump Mapping in GLSL8. Bump Mapping in GLSL Introduction Bump mapping is essential in todays computer games, and computer graphics in general. Would you like to know the best thing about it? It is extremely simple to implement. Bump mapping works...

Read more

Swiftless GLSL Shader DeveloperSwiftless GLSL Shader Developer Swiftless GLSL Shader Developer   Version 0.1a Currently Swiftless GLSL Shader Developer is in it's first public release, and is currently in alpha status, meaning it is not complete and may contain...

Read more

Wordpress Optimization Wordpress Website Optimizations Introduction Wordpress itself is a fairly wonderful tool. Since switching to it, I find it is a lot quicker to make changes to my website and it is also quicker to get...

Read more

36. OpenGL Framebuffers36. OpenGL Framebuffers Introduction Frame buffers are one of those mythical things that we have all heard of, but many beginner OpenGL developers avoid because there is not much information about them, and they can be confusing...

Read more

1. Terrain Class1. Terrain Class Terrain is one of those things that so far, hasn't been perfectly recreated in computer graphics. But it is almost there! Looking over a beautiful landscape can be one of the most amazing feelings in the...

Read more

  • Prev
  • Next

4. Maths Vector Length

Posted on : 25-03-2010 | By : Swiftless | In : Maths

Tags: , , ,

1

The first thing we will look at is how to work out the length of a vector.

Vector Length 1

Take a look at the diagram and try to grasp that we can determine the length of every vector there.

————————Figure 1 – The triangle on the left———————-

First go to the iamge in the left. You will see a triangle with sides of length a, b and c.

The vector a is facing towards c, the vector b is facing towards a and the vector c is facing towards b.

So to work out the length of the vectors we start at the end of the vector WITHOUT the arrow and work our way around to the end with the arrow.

To work out the length of a, we would start at the end of a, so the start of b and work around to the end of a with the arrow. So our length would be:

a = -b + -c

Which comes down to:

a = -b-c

If we were to work out negative a, we would get:

-a = c + b

Because to work out the negative value, we start at the other end.

For our formulae for a to be:

a = -b-c

You have to take into account that moving in the same direction is positive and moving opposite to the arrow is negative.

So all our lengths for our triangle would be:

a = -b-c

b = -c-a

c = -a-b

————————Figure 2 – The square on the right———————-

Vector Length 2

If you follow our rules from above, the lengths of our vectors come out to:

a = -d-c+b

b = c+d+a

c = b-a-d

d = -c+b-a

Keep in mind that no matter what shape you have, you ALWAYS work it out the same way. And thanks to vectors being what they are, this will always work.

__LENGTH OF A VECTOR PART 2__

In this part, we are going to be looking at the length of a vector in almost the exact same way as before. Only this time, the characters, a,b and c are not lines, but points.

Vector Length 3

To work out the length of these, you just have to work it out a little differently.

Take point A and point C. Now the length of that vector is AC (with a line above it)

Vector Length 4

The arrow above it just represents a vector instead of a normal line.

So in this diagram we have lengths:

AC

CB

BA

And to work that out is exactly the same as before.

AC = |AC| or -|AB|-|BC|

Where the lines | | represent the length.

__LENGTH OF A VECTOR PART 3__

Here we are going to be acctually calculating the length of the vector using numbers.

Vector Length 5

A is going to be located at (1,1)

B is going to be located at (1,0)

C is going to be located at (2,0.5)

Now the line AC comes to:

AC = [cX - aX, cY - aY]

Therefore:

AC = [2 - 1, 0.5 - 1]

AC = [1, -0.5]

Now to work out the length/distance:

d = sqrt(x^2 + y^2)

And vectors dont acctually have a length measuring system like cm, m, km etc. They are just measured in units.

so AC = sqrt(1^2 + (-0.55)^2)

AC = sqrt(1 + 0.25)

AC = sqrt(1.25) units.

If you have any questions, please email me at swiftless@gmail.com

VN:F [1.9.3_1094]
Please rate so I know where to improve the site. 1 means needs a lot of improvement, 10 means perfect. If you leave a low rating, please state why. I don't want people just coming to bash the site.
Rating: 1.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: -1 (from 1 vote)
4. Maths Vector Length, 1.0 out of 10 based on 1 rating

Related posts:

  1. 5. Maths Vector Dot Product
  2. 1. Maths Distance Formula
  3. 6. Maths Trigonometry
  4. 2. Maths Pythagoras Theorem
  5. 3. Maths Lines

Comments (1)

[...] cartoon character characters Clouds colorfull Commercial use computer icon Ecology Icon elements …4. Maths Vector Length | SwiftlessVectors are the back bone of 3D graphics, without them, the world of computer graphics would be a [...]

Write a comment

Improve the web with Nofollow Reciprocity.