Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Help me understanding vectors.

This topic is 5309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Can anyone show me what the vectors of a triangle are with the co-ordinates (-3,-2), (-2,2), (-1,-1)? I just not know how the vectors a running and in wich direction they are pointing. I know how to calculate the vectors: Vector.x = Point1.x - Point2.x; Vector.y = Point1.y - Point2.y; If I do this I get a co-ordinate, but I don''t understand how this could be the correct vector. Please show me how it must be done (examples). Thanks. The One.

##### Share on other sites
Hello,

I am not exactly sure what you are trying to get at. Are you trying to calculate the normal ( a perpendicular vector coming out of the surface, think tree on the ground ).

Ben

##### Share on other sites
Hello Again

I figured I would try to explain a vector ( briefly ). First thing about a vector is that you really have to forget about the coordinate system. When you see a vector that is (1,1) you naturally think of a vertex (a point) with an arrow going from the origin. This is one way of representing a vector. Its a hard consept to grasp when you are confortable with coordinates and they look so much like them.

A vector defines nothing more then a length and a direction and has no location. So for the previously montioned vector <1,1> you assume it starts at (0,0) but you can have the same vector start at 4,4 and be the exact same vector.

So for lighting you usually have a normal (a vector pointing out from the surface) so take your pencil and put in on your desk (straight up of course).. now move it around but make sure the direction does not change. you can even go as far as lift it off you desk.

Your pencil is a vector, it didn't change size and the direction didn't change. So no matter were it was it still give you the same direction. Or more importantly it still give you the direction your desk is facing.

I hope that helps. Its really a difficult thing to grasp. Once you understand that they have no location and stop trying to define it then it will make sence.

Ben

[edited by - zander76 on January 6, 2004 12:18:14 PM]

##### Share on other sites
Thanks for the explanation, but how do I draw the vector of the triangle? How do I know where the vector starts and in wich direction it goes? Can you give me the calculation of a vector (and/or the calculation of the normal?) and maybe a picture of how I must imagine the vector of a triangle?

Thanks.

The One.

##### Share on other sites
To calculate the normal of a triangle, u use the cross product. Let''s say your triangles has three angles, A, B, C.
To get the vectors vector1 and vector2 from these points you do :
vector1.x = A.x - B.x
vector1.y = A.y - B.y
vector1.z = A.z - B.z

vector2.x = B.x - C.x
vector2.y = B.y - C.y
vector2.z = B.z - C.z

Once you have these vectors you can do the cross product, which gives you the normal vector :

normal.x = vector1.y*vector2.z - vector1.z*vector2.y
normal.y = vector1.z*vector2.x - vector1.x*vector2.z
normal.z = vector1.x*vector2.y - vector1.y*vector2.x

Thx x,y,z are the coordinates in space

Hope this helps,

Kiruagon

##### Share on other sites
Those two vectors are the vectors of the triangle, and that is what you wanted :-)

Kiruagon

##### Share on other sites
Tanks for your help, but how to get the vectors of a triangle if you only got the co-ordinates of the points of the triangle (without calculating the angles)? And how are the vectors running, are the parallel with the polygeon? How does a triangle with vectors look like? Can you draw it for me? :-)

You said that the x,y,z (of the normal) are the co-ordinates in space. But then you only have the co-ordinates of one point, you need at least two point to get the direction (of the normal)(because its a vector too).

Thanks.

The One.

##### Share on other sites
Vectors are not real in the way you are thinking about them. Vectors don''t translate into a trangle and are not drawable. Let go of that. If you want to represent them (note I said represent, its a way of visualizing and has no practical part to it like what you are talking) you can draw them from the origin using a cartisan coordinate system (x,y). But really vectors are not definable in the way you are thinking. Try to think of a vector like wind, or velocity. These are the things vectors are used for.

I have no idea what you are talking about when you say a vector of a triagle. A vector is an arrow. Perhaps you are thinking of a vertex (a point in space) then you can draw something using them.

Can you explain what you are trying to do, and try not to use the word vector. Like I said above a vector is a very confusing thing to get at first, since its undefinable in the logic you are following but thats not just you everybody has problems with this when they first start looking at them.

Ben

##### Share on other sites
I try to make ''make'' collision detection. I found a tutorial on that subject on www.gametutorials.com (RayPlaneCollision). I try to understand what they are doing and how it works. But the problem is that I have got a hard time understanding there vector class and what they are doing.
They have got a triangle with the points {-1, 0, 0}, {1,0,0}, {0,1,0}. They have a class that returns a vector between two points.

CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2)
{
CVector3 vVector = {0};
vVector.x = vPoint1.x - vPoint2.x; vVector.y = vPoint1.y - vPoint2.y; vVector.z = vPoint1.z - vPoint2.z;
return vVector;
}

The problem is that I don''t onderstand what they are doing. If you ''run'' this function you get a point (vector) with x,y,z values. What is this for point? Are the x,y,z value,
co-ordinates? Don''t you need two points to get a direction?
I don''t know how to visualise the vectors, I don''t know what I''m working with.

Thanks.

The One.

##### Share on other sites
quote:
Original post by Erik23a86
CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2)
{
CVector3 vVector = {0};
vVector.x = vPoint1.x - vPoint2.x; vVector.y = vPoint1.y - vPoint2.y; vVector.z = vPoint1.z - vPoint2.z;
return vVector;
}

The problem is that I don''t onderstand what they are doing. If you ''run'' this function you get a point (vector) with x,y,z values. What is this for point? Are the x,y,z value,
co-ordinates? Don''t you need two points to get a direction?
I don''t know how to visualise the vectors, I don''t know what I''m working with.

If you let A be a vector from point1 -> point2, this function
returns a vertex (point3). If we let B be a vector from point1 -> point3 it will be in the opposite direction of A.

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
17
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002295
×