Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need help with Vectors

Author
Message
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 10th Feb 2003 14:22
Is it only me that can't find a 'search' button in the
forums?

Is there any tutorial out there, that explains the meaning and use of vectors3 and their operators?
what is the different between vector3 and vector4?
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Feb 2003 15:52
a vector is a point in space... the number of vector points determines what dimensions it is set in

Vector2 - X Y (2D)
Vector3 - X Y Z (3D)
Vector4 - X Y Z W (3D with extension Dimension)

as vectors combine all three points into a single calculation, means that you can use a Vec3 point to note perfectly a models position and then do physics operations on it based on a single calculation meaning that all the points are calculated similaneously which helps to prevent weird things happening to the models physics.

with Vec4 you normally use this for a vector which is set along a directional path so the 4th dimension is usually standing for speed or width/length ... it just add an extra variable so you can calculate physics more presisly when based on time

a simple vectorisation would be taking a cube placing it within a memblock and then altering the points with vectors - using the different calculations provide different results but is no different to doing them seperately it just takes aways the complex calculations required...

so result = Multiply Vec3(Vec3_a,Vec3_b)

would be the same as
model1.x * model2.x, model 2.y* model2.y, etc...

i can't remember but i think the values are standard bitshift floats - so like

Model.Vec3 = model.x + (model.y >> 8) + (model.z >> 16)

but as i said i can't remember so that might just be how i did it within DB Standard

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Dr OcCuLt
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 10th Feb 2003 16:34
there is no search no button so do`t worry.

a vectors3 or 3D vectors is a way of haveing a point in 3D space ig."X,Y,Z" why we ues vectors and not just x#,y#,z# is that thay can have sum mathematical tricks on then like dot products or matrix multplication.

here is an explain of a moon orbiting a planet


all of this is a bit hard to explains the best way to find out about vectors is to get a book on maths(ie a school book) if you are still at school you can ask your math teacher about it that what there payed for.

hope this is helpful
--Dr 0--
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 10th Feb 2003 18:13
Raven,Dr OcCuLt: first Thanks.
If i get it right, vector3 is just encapsulating the
x,y,z space coordinates, so ANY operation on it,
is a simple math on each of his members, while -
vector4 is more like the 'Vectors' i studied 15 years ago
(who remembers?...) in physics, which are holding the position and the direction, and there is the 'Vectors methods' of calculations involved. right?

Now,Dr OcCuLt, the code you sent confused me about Matrix4.
Could you please add a few words, really short explanation about Matrix4 and the way it interacts with the vectors in that code snipped? Thanks in advanced.

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Feb 2003 18:27
yup effectively thats it entirely
but as Occult noted, you can do some cool and clever math tricks to them - which is fantastic for certian physics and such.

thats a good example of them he's posted

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Dr OcCuLt
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 11th Feb 2003 01:03
matrix4 is a bit like a vector.a vector4 has 4 rows and 1 column where a Matrix4 has 4 rows and 4 columns.

vector=|x| matrix=|cos(a) -sin(a) 0 0|
|y| |sin(a) cos(a) 0 0|
|z| | 0 0 1 0|
|w| | 0 0 0 1|

there is a way of multiply a vector and a matrix to get a vector at the end.in a odd mathematical way "is to hard to type that sorry" the new vector is affet by all the coordinates in the old one.

if you look at the matrix up there it is the matrix for rotate about the Z-axis,if you multiply a vector and this matrix the new vector will be the same as the old one but
rotate about the Z-axis A degres.

if you then what to rotate the new vector about the x-axis you can make a new matrix and multiply by the new vector to get a 3th vector or you can multipl the two matrix to start whit, and then multiply the 1st vector by the new matrix.this is more uesful then just multiply vector and matrixs becos u can reues the matrix if more then one vector needs the same rotateon and it faster if you have to do it to a lot of vectors.

two more thing you have to now about matrix you can multiply at enay time ie A*(B*C)=(A*B)*C but you can`t in enay odder ie A*B<>B*A.

i think these a lot of bad spell here so sorry.

--Dr 0--
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 12th Feb 2003 13:21
Dr OcCuLt, thanks for the really great efforts of
making the "bad spell" much more soft one...

I feel that finally i see the light. A little more help
and i belive that this post will be a really huge step
of understanding the vector/matrix method, and could serve
any reader that was avoided of using those methods.


In generally, what are the Matrix4 rows and columns stand for?
I know that a math book has the answers for HOW to
use claculations based on matrix, but i've missed
the WHAT implementation of 3D graphics.
If belive if i understand what does the matrix describe, i get the WHY should i use it.

Correct me if i'm wrong, but is the Matrix only an helper for vectors calculations, and is not usable by its own?

Now, about that vector's W.
Whats his role? what is the LENGTH VECTOR4 command and
is it connected with this W?

Hope to hear you soon,

[solo]

Dr OcCuLt
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 12th Feb 2003 20:26
well rows and columns in a Matrix do not stand for eney thing real it just the Matrix is a abstract mathematical ider it ownle work on VECTORS.

the best way to think about it is to think all a Matrix is,is a way to TRANSFORM a VECTOR then all you need to do is think of what the TRANSFORM is and not what it is made up of.so the Matrix i post last is the (sorry but it did not come out right) is the rotate about the Z-axis Matrix you just have to now that if you ues TRANSFORM COORDS VECTOR3 then the VECTOR will be rotate about the Z-axis.

as for w yes it is the 4th column in the in a VECTOR4 but LENGTH VECTOR4 will give u a the LENGTH of the VECTOR ie
LENGTH=SQRT(x^2+y^2+z^2+w^2)

--Dr 0--
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 13th Feb 2003 14:00
Thanks. That was a good starting point.


[solo]

Login to post a reply

Server time is: 2025-05-18 02:59:52
Your offset time is: 2025-05-18 02:59:52