Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (565) Games in Android Showcase (151) games submitted by our members Games in WIP (606) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
Pages: [1]
 ignore  |  Print
 Help with understanding uses of vectors  (Read 1958 times) 0 Members and 1 Guest are viewing this topic.
Joshua Waring
 « Posted 2012-10-13 11:49:26 »

I've been recently exploring the world of vectors to see how they can make life easier when it comes to games programming. I was wondring how they would be put into pratical use, if i was to use a voxel render (like minecraft) would it be easier to use a vector for each cube or each face when it comes to lighting aswell.

I'm yet to truely explore vectors in pratical use, so my question is really, how would you use vectors in daily game programming of many game styles.

Thank you, in advance for any help

The world is big, so learn it in small bytes.
Regenuluz
 « Reply #1 - Posted 2012-10-13 13:12:10 »

You can use a vector to define which direction an object is moving, what velocity it has, and what acceleration it has, and it's easy to add other vectors to the acceleration/velocity, to make the object move as if it were under the effects of gravity or wind blowing, etc.
Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

 « Reply #2 - Posted 2012-10-13 13:40:58 »

Do you mean mathematical vector (eg. x,y,z) or vector collection (eg. java.util.Vector)?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
 Games published by our own members! Check 'em out!
Joshua Waring
 « Reply #3 - Posted 2012-10-13 13:45:17 »

OpenGL vectors which are mathematical vectors

The world is big, so learn it in small bytes.
Regenuluz
 « Reply #4 - Posted 2012-10-13 13:51:56 »

Java.util.Vector is a mathematical Vector too. It's just meant to be extended, e.g. as in Vector2d. ^^

The uses is still like what I wrote earlier.

This is how I use them:

 1  2  3 `this.acceleration.add(this.force);this.velocity.add(this.acceleration);this.location.add(this.velocity);`

They are all instances of Vector2d.
Joshua Waring
 « Reply #5 - Posted 2012-10-13 14:01:04 »

Wouldn't it be easier to use an array?

The world is big, so learn it in small bytes.
matheus23

JGO Kernel

Medals: 121
Projects: 3

You think about my Avatar right now!

 « Reply #6 - Posted 2012-10-13 14:06:14 »

Wouldn't it be easier to use an array?

Personally I think it would even be easier to use:
 1  2  3  4 `public class Vector2D {    public float x;    public float y;}`

Or even just use org.lwjgl.util.vector.Vector2f, if you're using LWJGL.

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Joshua Waring
 « Reply #7 - Posted 2012-10-13 14:25:31 »

I use the lwjgl vectors, but I was more conserned on how one would use them in everyday programming for models, maps and lighting or finding the normal to faces.

The world is big, so learn it in small bytes.
sproingie

JGO Kernel

Medals: 202

 « Reply #8 - Posted 2012-10-13 16:29:36 »

A vector is just a Nx1 or 1xN matrix, typically interpreted as representing a direction in a N-dimensional space, but it can be anything you want it to be.  Any linear algebra textbook will tell you how to use vectors, though you might want a book that specializes in 3d graphic.  This book is pretty decent.  There's a second edition available now, but the first edition is still pretty good and quite a bit cheaper.
Roquen
 « Reply #9 - Posted 2012-10-13 16:54:02 »

Pretty much everyone ignore me: but a 1xn or nx1 is 'a' notion of a vector, which is different from 2D, 3D and some other notions of vectors.  Vector is a very overloaded term.  Specifically they are typically homomorphic but not isomorphic to the LA representation.
 Games published by our own members! Check 'em out!
sproingie

JGO Kernel

Medals: 202

 « Reply #10 - Posted 2012-10-14 01:58:08 »

homomorphism includes isomorphism.  But let's not derail the topic into category theory ok?   It suffices to say that vectors have different interpretation (even in GLSL -- vertices get passed in as vectors after all) but that you'll do well to study the linear algebra interpretation.
Roquen
 « Reply #11 - Posted 2012-10-14 06:19:55 »

Yeah, keep ignoring me.  It's deeper than interpretations.  Dot(a,b) = Trace(A*Transpose(B)) ??  That's jumping through hoops...now consider the cross product without reverting to a formal matrix (i.e. only matrix ops over only reals).

I think most people would be better off with basic understanding of geometry and vectors before jumping into LA.  Really I think understanding complex number before vectors & LA would be a very good thing.
DrHalfway
 « Reply #12 - Posted 2012-10-14 07:29:32 »

Vector is a very vague term.. we use vectors for

1) to represent some point in space
2) to represent some direction in space
3) to represent some direction and speed in space

 1  2  3  4  5 `Vector position = new Vector2(0,0);Vector velocity = new Vector2(10,10);Vector newPosition = new Vector2(position.tmp().add(velocity));`

Nate

« JGO Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

 « Reply #13 - Posted 2012-10-15 06:17:43 »

Snarf

Joshua Waring
 « Reply #14 - Posted 2012-10-15 08:54:12 »

Thank you, vectors really are easy to understand and provide nice features that may be useful.

Snarf?

The world is big, so learn it in small bytes.
Nate

« JGO Bitwise Duke »

Medals: 164
Projects: 4
Exp: 14 years

Esoteric Software

 « Reply #15 - Posted 2012-10-16 05:35:38 »

Yes, my addition to the discussion, being at least as useful.

sproingie

JGO Kernel

Medals: 202

 « Reply #16 - Posted 2012-10-16 06:02:51 »

narf! poit! egad!
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 ags1 (21 views) 2015-03-31 10:55:12 theagentd (13 views) 2015-03-27 23:08:20 wxwsk8er (54 views) 2015-03-20 15:39:46 Fairy Tailz (47 views) 2015-03-15 21:52:20 Olo (29 views) 2015-03-13 17:51:59 Olo (32 views) 2015-03-13 17:50:51 Olo (39 views) 2015-03-13 17:50:16 Olo (44 views) 2015-03-13 17:47:07 ClaasJG (60 views) 2015-03-10 11:36:42 ClaasJG (43 views) 2015-03-10 11:33:01
 BurntPizza 21x LiquidNitrogen 21x basil_ 19x KevinWorkman 18x EgonOlsen 17x theagentd 16x Roquen 16x wessles 11x Varkas 11x 65K 11x Riven 11x Rayvolution 9x phu004 8x SHC 8x princec 8x Ashedragon 8x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org