Comparing points

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

Comparing points

Post by Guest »

I'm new to 3D programming and I'm not sure how I go about comparing one point in relation to another.

For example the distance between objects. I can't use greater than or less than can I?

Also could someone quickly explain the concept of vectors to me. I understand they hold an x,y z value, but don't understand the final point in relation to the other objects on screen. :(
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

A Vector is the distance in relationship to another object.
A Matrix is the location of the object.

Hold your hand out in front of you.
In relation to your eyes (the vector) it is probably about:
X = 0.5 meters
Y = -0.1 meters
Z = 0.5 meters
Away from your eyes.
X = left/right
Y = up/down
Z = back/forth

In Universal terms (Matrix), it's exact point in the universe
X = 1 bazzilion meters
Y = 1 bazzilion meters
Z = 1 bazzilion meters

Blah, that's why I don't like matrixes, since I like thinking of a point of reference and just giving the offset for that point.

You really can't say "if (Vector1 > Vector2) {" because your comparing a position to another that is confusing. Does the person mean higher is greater? More to the right? Farther away?

What you will need to compare is each field to get an apples to apples comparison.

Vector1.X > Vector2.X
Vector1.Y > Vector2.Y
Vector1.Z > Vector2.Z
Crud, how do I do this again?
Guest

Post by Guest »

Thanks that helped alot :D
Guest

Post by Guest »

ok I have another question :wink:

How would you go about making a node follow another node in a realistic type way?

Say a player controlled node with an enemy character in pursuit.
elhim
Posts: 16
Joined: Sat Mar 13, 2004 12:37 am
Location: LI, NY

Post by elhim »

the 3d/vectors part. no knowledge of graphics needed, just some highschool math. but better, grab a book on linear algebra and read the vectors/vector spaces section and you probably won't have any more questions on vectors.
about the chase. depends on how realistic you want it to be. if you just want to make the "chaser" move a distance X from the "chased" you could just make the "chaser" a child of the "chased" and then write an algorithm to have the "chaser" face the "chased". for more complexity you'll need more complex code (obviously). don't see an easy way of doing it
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

To be a bit more accuarate about vectors and matrices:

A vector holds (mathematicaly) 2 things: a length and a direction in 3d space. It is (technically) encoded in 3 values (x, y, z).

It can be used differently. First it can be used to define a location of a point (or object) relative to the world origin (global) or to another object (local).

Second it can be used as a direction for example of a moving object (the length could represent speed here). Or it could define the direction an object faces (looks) to.

Sometimes you combine 2 vectors. The first defines the location of the second that contains direction and length.

A normalized vector has a length of exactly 1.0 and thus only contains direction information.

Irrlicht vectors are also often "abused" to hold rotation and scaling information.

Matrices hold transformation data. That's the sum of translation (position), rotation, and scaling. (Which also can be global, or local (relative to another matrix))

For example you ("ab")use a vector to set the rotation of a matrix.

core::matrix4 mat;
core::vector3df vrot(0,45,0);
mat.setRotation(vrot);
Guest

Post by Guest »

Post Reply