A mathematical concept that can be used to express position, direction or velocity and which can simplify or outright trivialise spatial problems.
12
votes
4answers
8k views
How can I calculate the angle between two 2D vectors?
I am working on some movement AI where there are no obstacles and movement is restricted to the XY plane. I am calculating two vectors, v, the facing direction of ship 1, and w, the vector pointing ...
7
votes
7answers
597 views
What's the best way of translating a 2D vector into the closest 8-way compass direction?
If you have a 2D vector expressed as x and y, what's a good way of translating that into the closest compass direction?
e.g.
x:+1, y:+1 => NE
x:0, y:+3 => N
x:+10, y:-2 => E // closest ...
3
votes
1answer
2k views
How do I find rotation in 3D based on a vector/normal?
I've been playing with Blender and Python, doing basic things like accessing vertices/normals,etc.
I can get the normal of each face of a mesh. I was wondering, how can I get the rotation of a face ...
1
vote
1answer
580 views
Bukkit shoot tnt & help with vectors
I want to shoot a piece of tnt from the players face and then let it explode when it hits the target block.
if (cmd.getName().equalsIgnoreCase("cannon")) {
...
14
votes
6answers
3k views
Vectors in game development
I'm new to programming and game programming.
I've reading something about vectors and math, but I have a question - where do I use vectors in game programming? Maybe anyone can give a simple example ...
12
votes
1answer
2k views
Determine arc-length of a Catmull-Rom spline
I have a path that is defined by a concatenation of Catmull-Rom splines. I use the static method Vector2.CatmullRom in XNA that allows for interpolation between points with a value going from 0 to 1.
...
12
votes
5answers
2k views
Do I need the 'w' component in my Vector class?
Assume you're writing matrix code that handles rotation, translation etc for 3d space.
Now the transformation matrices have to be 4x4 to fit the translation component in.
However, you don't actually ...
2
votes
1answer
160 views
Turning to face mouse
Given three points on the same Y plane;
A ship
A point along the ships heading
A mouse cursor
How can I find which direction and angle the mouse cursor is from the ships heading?
I have a limited ...
2
votes
1answer
802 views
Make objects follow a strict path (Xna)
I am making a defence game. Naturally, this means that there needs to be objects following a path on the screen. I want to make it a strict path from one point to another to another. I could use an ...
2
votes
3answers
1k views
Get points on a line between two points
I'm making a simple space game in JavaScript, but now I've hit a wall regarding vectors.
The game view is top-down on a 2d grid. When the user clicks on the grid, the space ship will fly to that ...
6
votes
2answers
330 views
Vector problem: which one is the left / centre / right one?
In aviation, runways are named according to their magnetic orientation seen from the pilot's perspective. For example: a strip of asphalt oriented along the east-west axis will be named 9 for the ...
5
votes
2answers
2k views
How do I find the angle between two vectors?
I have 3 points on my screen:
a = a point which is (c.x, 0) makes a line pointing straight up
b = a user input touch, can be anywhere on the screen
c = a moving object
a
_______.________
| ...
4
votes
1answer
1k views
How do I rotate a sprite so that it is 'pointing' in the direction it is moving
I have a sprite, e.g a missile, heading in a certain direction (using a velocity vector).
How do I figure out its how much to rotate it so that it gets drawn 'pointing' in the direction it is ...
4
votes
2answers
2k views
Drawing a texture line between two vectors in XNA WP7
I want to create a simple graph maker in WP7.
The goal is to draw a texture line between two vectors what the user defines with touch. I already made the rotation, and it is working, but not ...
1
vote
1answer
460 views
Rotate triangle so that its tip points in the direction of the point on the screen that we last touched
OpenGL ES - Android.
Hello all, I am unable to rotate the triangle accordingly in such a way that its tip always points to my finger.
What i did : Constructed a triangle in by GL.GL_TRIANGLES. Added ...
1
vote
1answer
400 views
Transform 3d viewport vector to 2d vector
I am playing around with 3d transformations and came along an issue.
I have a 3d vector already within the viewport and need to transform it to a 2d vector. (let's say my screen is 10x10)
Does that ...
8
votes
1answer
385 views
Downprojecting an imaginary 4D mesh to the screen
As a mental exercise, I'm trying to imagine projecting an arbitrary 4D mesh onto the screen (2D).
I'm guessing a single 4D triangle would still consist of only 3 points, however each of those 3 ...
5
votes
1answer
2k views
How do I calculate collision response between a sphere and a plane?
I'm trying to create a simple 3D game and need to constrain the player within the limits of the game world. When the player hits the sides of the world I want the player's ship to bounce off slightly.
...
5
votes
1answer
961 views
Rotate object to face player
This is probably a simple vector question, but I'm not sure how to do it.
I have an object at vector position (ox,oy). Potentially every update, the user walks around the screen, and will be at ...
3
votes
3answers
266 views
Tetris - Rotations using Linear Algebra (Rotation Matrices)
I'm making Tetris in Java and am at the point of rotations... Originally I was hardcoding each rotation:
if (direction.equals("right")) {
if (shape.equals("Bar")) {
if ...
3
votes
2answers
84 views
Need the co-ordinates of innerPolygon
Let say I have this diagram,
Given that i have all the co-ordinates of outer polygon and the distance between inner and outer polygon is d is also given. How to calculate the inner polygon ...
3
votes
2answers
2k views
Vector images (SVG or other formats) support in libgdx or other Android framework?
I'm looking for a website to create games for Android. I'm interested in something that supports vector images. Do you know if libgdx supports them or is there a convenient way to use them in libgdx?
...
2
votes
2answers
440 views
How to calculate vector that is perpendicular to the direction of moving in Flash?
In flash i have a class that extends movieclip and i am moving it forward, up and down, and rotating it. How can i calculate the vector that is perpendicular to this movieclip?
2
votes
2answers
377 views
Swapping axis labels between 2D and 3D coordinates
My game world is 3D.
The map is only 2D, however.
It is natural to think of the map as having an X and Y axis.
And it is natural to think of the world has having an X, Y and Z axis, where Y is ...
1
vote
1answer
151 views
How do I get the axes for SAT collision detection
In SAT collision detection how do I calculate the axes for projection?
0
votes
1answer
251 views
Vector reflect problem
I'm testing some vector reflection and I want to check what happens when
a ball collides with a paddle.
So if I have:
Vector2 velocity = new Vector2(-5, 2);
position_ball += velocity;
if ...
0
votes
1answer
1k views
The normal vector to a plane ax+by+cz+d=0?
I am calculating the normal vector to a plane ax+by+cz+d=0
According to the book:
The normal vector N is often normalized to unit length because in that case
the equation
d = N ⋅Q + D
gives the ...