Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 1649 times)
0 Members and 1 Guest are viewing this topic.
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« 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 Smiley

The world is big, so learn it in small bytes.
Offline 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.
Offline Orangy Tang

JGO Kernel


Medals: 56
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!
Legends of Yore - The Casual Retro Roguelike
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« Reply #3 - Posted 2012-10-13 13:45:17 »

OpenGL vectors which are mathematical vectors Smiley

The world is big, so learn it in small bytes.
Offline 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. Smiley

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.
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« 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.
Offline matheus23

JGO Kernel


Medals: 106
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
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« 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.
Offline 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.
Offline 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!
Legends of Yore - The Casual Retro Roguelike
Offline 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? Smiley  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.
Offline 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.
Offline 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));

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


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

Snarf

Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« 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.
Offline Nate

JGO Kernel


Medals: 145
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. Wink

Offline 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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (24 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!