A mathematical concept that can be used to express position, direction or velocity and which can simplify or outright trivialise spatial problems.

learn more… | top users | synonyms

1
vote
1answer
106 views

3D vector graphics - maintaining correct Z 'length'

So I'm trying to build myself a 3D display 'engine', or whatever it ought to be called. I've been experimenting with PyGame, as it's familiar to me. In a way this has almost been more an excuse to ...
4
votes
2answers
962 views

How do I use the dot product to get an angle between two vectors?

I am learning to use normalized vectors in my games. I've learned that in order to know the angle between two vectors, I can use the dot product. This gives me a value between -1 and 1, where 1 ...
1
vote
3answers
647 views

How to move an object along a vector

Let's say I got an object A and object B in a 2D game. I create a vector leading from A to B. It's name is AB. How can I make A move along the vector AB and reach B? One way I was thinking of doing ...
17
votes
4answers
13k views

How can I calculate the angle and proper turn direction 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 ...
0
votes
1answer
46 views

What does it mean to cross a scalar with a vector in a 2D plane?

At the moment, I'm following this page to create a physics engine. As per that page, I need to cross angular velocity by a distance vector to get relative torque and such, but I'm not sure how (in a ...
2
votes
1answer
126 views

How do I compute the point of a triangle-ray intersection?

I have a line (the direction vector of the player) and a triangle representing the face of a model (so composed of 3 points). I can't find the mathematical operation to check if that vector is ...
0
votes
1answer
110 views

Creating a textured object infront of the current character in unity 3d

I've spent about half a day trying to get my head round this and i'm not having too much luck, essentially what I want to do is play an animation and then once the animation has finished create a flat ...
0
votes
1answer
69 views

How to modify normal vectors with a tranformation matrix

Transformation is quite simple when it comes to Position or Color of the vertex, for Position just multiply matrix * vector and for color just don't do anything, but my question now is: How to handle ...
3
votes
4answers
294 views

Why not use vectors to represent orientation?

From what I've read, people mostly use either quaternions or 3x3 matrices to represent 3D orientations, while plain vectors are used for angular velocity/momentum. Since we can use vectors to ...
1
vote
1answer
114 views

Does a 2D Vector or 2x2 Matrix play any role in 2D Transformations?

I'm having trouble trying to figure out if a vec2 or mat2 class are used at all in transformations for 2D rendering. Vec2, apart from representing UVs, AFAIK, is relatively pointless in regards to ...
11
votes
2answers
462 views

How do I find a point on a line?

I have two points (A, B) and the length of d. How can I find point C?
2
votes
1answer
299 views

Rotate Camera as an Object Manoeuvres

There are loads of questions (all of which I have looked at) on here about cameras following objects. Using them, I have successfully got my camera to follow my car when driving, but I am unable to ...
5
votes
1answer
3k 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 ...
-1
votes
1answer
100 views

Can not seem to adjust the speed of my Car

I'm programming in C++, rendering in OpenGL and using GLM for matrix/vector manipulation and I have implemented very (very) basic car controls; ignoring many forces that are present in reality. Since ...
2
votes
2answers
632 views

Relative cam movement and momentum on arbitrary surface

I have been working on a game for quite long, think sonic classic physics in 3D or tony hawk psx, with unity3D. However I'm stuck at the most fundamental aspect of movement. The requirement is that I ...
3
votes
1answer
142 views

Moving sprite from one vector to the other

I'm developing a game where enemy can shoot bullets towards the player. I'm using 2 vector that is normalized later to determine where the bullets will go. Here is the code where enemy shoots: ...
0
votes
1answer
198 views

Circle-Rectangle collision velocity adjustment

I created my circle vs. rectangle method based on this algorithm: http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection Currently, I have a dynamic ball with ...
2
votes
1answer
316 views

Vector normalization gives very imprecise results

When I normalize vectors I receive very strange results. The lengths of the normalized vectors range from 1.0 to almost 1.5. The functions are all written by me, but I just can't find a mistake in my ...
2
votes
4answers
271 views

How do I rotate a camera around the Y axis of the object it's looking at? [duplicate]

I'm making a camera that can currently rotate freely from the back to the front of a target object by giving it an angle and a distance. I do the above with the following code directionVector = ...
19
votes
3answers
934 views

What's so different/complicated/useful about vectors?

Forgive me if this isn't considered a real question, but it is something I am genuinely confused about. I constantly hear other game developers talk about how using vectors are very useful, but also ...
3
votes
4answers
293 views

How do I find the 2D direction to a 3D location?

I'm writing a 3D space flightsim, and I'm trying to display a 2D arrow on screen that points to the player's selected target. To clarify, the arrow needs to point in the direction that the player has ...
-1
votes
2answers
417 views

XNA Creating a directional vector from two other vectors

Could somebody please tell me what I'm missing? I have a scene where the camera is fixed in the sky looking down on a plane. On that plane is a 3D model. I want to move the 3D model in the direction ...
5
votes
3answers
768 views

Why is this code producing jittery movement?

I have a new project, all settings default with a simple cube on a plane. Cube is not kinematic but is a rigid body under the effects of gravity. I'm trying to normalize the direction before I ...
0
votes
0answers
104 views

Bouncing objects against the side of the screen

I want to have certain circular objects bounce against all four sides of the screen. After searching a lot on the internet, I found the following formula: Vout = Vin - ((1+e) *dot(Vnormal, Vin) * ...
1
vote
2answers
542 views

What is the camera direction vector for an isometric view?

What values correspond to a 3D vector for screen-normal from within an isometric game? It needs to be in game coordinates. It is a standard isometric where tiles are rotated 45 degrees and half ...
0
votes
0answers
254 views

Finding a normal vector

I'm trying to replace my old integer based movement and collision system with a vector system, because its more precise and more flexible. I want to implement wall sliding, such that if a player hits ...
1
vote
2answers
139 views

Twitchy sprite movement

I'm having an issue with sprite movement, and I'm not sure how to deal with it. When I set a destination for my player sprite (by clicking the screen), it sets the player moving in that direction. ...
3
votes
1answer
131 views

How to calculate where specular highlights converge with an anisotropic shader?

If you look at a rendering with an anisotropic shader applied you will notice that there are special spots on the 3D surface/mesh where the lights seems to converge, a point where a given vector ...
1
vote
1answer
120 views

Explaining vector problem

I'm trying to simulate a centipede game, and I'm doing the snake movement. I have seen that piece of code, but can't get it, I know it gets the different between the current, previou's nodes ...
14
votes
5answers
723 views

Can I simplify the inequality “distance(p1, p2) < distance(p1, p3)?”

I am working on some vector logic, so am asking: can I save processor time by simplifying this inequality: distance(vector1, vector2) < distance(vector1, vector3) I see that vector1 is repeated ...
0
votes
0answers
29 views

Move object forward based on it's direction(1D rotation) [duplicate]

I have 2D game where I want my object to move forward based on it's direction. This is what I've tried: position.x+=Math.Cos(rotation)*speed; position.y+=Math.Sin(rotation)*speed; However this ...
2
votes
1answer
258 views

How to correctly represent a bone system?

I'm currently representing my bone system as follows, in pseudocode: root = {} root.rot = v3(0,0,0) root.pos = v3(0,0,0) function create_child(parent,rot,length): child_bone = {} ...
0
votes
0answers
250 views

Space Strategy Ship Movement Math

This is similar to a question I asked a while ago, but I phrased it so terribly so might as well start over. I am trying to implement ship movement in 3D space, but confined to a 2D plane at y=0 (see ...
0
votes
2answers
520 views

How do I calculate speed given two xy vectors?

I have some code that returns the x and y linear velocities of a moving space ship. How can I combine these to give me total speed? x = self.player._box2dBody.GetLinearVelocity().x; y = ...
1
vote
1answer
297 views

How to simulate acceleration and then deceleration?

Currently I am only using deceleration. Here is how I do it I need to cover Vector(x,y) unit distance to reach B from A. I simply do - rendering loop-> position = A + Vector(x,y).scale(factor); ...
0
votes
1answer
113 views

2D vector to Quaternion

I have a 2D vector (with only X and Y), and my engine only supports orientation through Quaternions. How do I translate a 2D vector to a quaternion? The X and Y represent the direction (so X = 0 ...
0
votes
2answers
197 views

Finding vectors with two points

We're are trying to get the direction of a projectile but we can't find out how For example: [1,1] will go SE [1,-1] will go NE [-1,-1] will go NW and [-1,1] will go SW we need an equation of ...
-2
votes
1answer
107 views

2D Vector Compass Direction [duplicate]

Relating to this question; What's the best way of translating a 2D vector into the closest 8-way compass direction? My query is if this would work in the following order(below) and if so, how ...
5
votes
1answer
154 views

Vector Math question

Suppose I have two game object located at two Vector3s v1 and v2, respectively. If I wanted to locate a position between v1 ad v2, but 3 units away from v2, how would I manage that in terms of ...
1
vote
1answer
295 views

Calculating projectile velocity from moving object

I'm working on a top down space shooter and am having trouble with calculating/understanding the physics for projectiles launched from the space ship. The ships have a velocity vector and a turret ...
1
vote
1answer
198 views

When to use an Array vs When to use a Vector, when dealing with GameObjects?

I understand that from other answers, Arrays and Vectors are the best choices. Many on SE claim that Linked Lists and Maps are bad for video game programming. I understand that for the most part, I ...
0
votes
1answer
235 views

Sharp DX Identity Matrix, Matrix.Forward vector pointing at negative Z

I'm trying to take a steady grip on Sharp DX. Already done some work like translating, scaling and rotating objects. Now i have to calculate the rotation matrix using only direction vector and ...
2
votes
0answers
284 views

Quaternion to direction vector - flipping

I've kinda solved this myself by adapting the Camera::setDirection code from OGRE to work for my need: Now I have the following code: Vector3 boneDir = getBoneWorldOrientation(mEntity, mHips) * ...
10
votes
4answers
1k views

How does normal mapping really work?

I'm trying to grasp the concept of normal mapping, but I'm confused by a few things. In short, I'm not sure whether a normal map is viewpoint dependent or not (i.e. whether you'll get a different ...
1
vote
2answers
930 views

Libgdx: Am I abusing Vector2? Is there a better way to do my position updates and rendering?

I'm simulating hair in a game. Currently I have a HairField object, which has a position defined by a Vector2. Each HairField has multiple Hair objects in a list, each with a position defined by a ...
-1
votes
2answers
145 views

JavaScript “Floats”, or ThreeJS wrong positioning? [closed]

I want to learn how to use Vectors with 3D. Here is a strange Error I have encountered today. Instead of stopping exactly on the other Cube, I get this: When I change the IF to (cube.position.y ...
15
votes
1answer
3k 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. ...
0
votes
1answer
89 views

Rotating sprites

I'm a beginner at making games, i'm currently only working in 2D using XNA. So far all of my games i've been using the following logic for sprite movement: if(left key pressed) sprite_x_position ...
3
votes
4answers
833 views

Is it better to track rotation with a vector or a float?

In XNA, you can see that to draw a rotated sprite with SpriteBatch, you'll need a float describing the angle in radians. I'm used to making games in OpenGL. I just want a rapid prototyping ...
3
votes
4answers
2k views

How to smoothly rotate a vector in a direction?

I'm looking for an easy way to achieve the following: Object A, B { Vector2D position; Vector2D orientation; } update(elapsed) { //rotate A's orientation in B's direction by x * elapsed ...