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
2answers
485 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
241 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
136 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
126 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
721 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
249 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
244 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
455 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
266 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
112 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 ...
2
votes
3answers
2k views

How to find the entity I'm looking at?

I am currently making a mod for Minecraft but I have come to a stop because I am lacking in some knowledge. I need to get data for the entity I am looking at, which I believe requires the use vectors, ...
-2
votes
1answer
105 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 ...
3
votes
1answer
141 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: ...
5
votes
1answer
152 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
274 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 ...
0
votes
2answers
183 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 ...
1
vote
1answer
196 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 ...
2
votes
0answers
256 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) * ...
-1
votes
2answers
398 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 ...
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
856 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 ...
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
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 ...
0
votes
1answer
231 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 ...
-1
votes
1answer
115 views

Optimization of Storage of Spells a Character Knows

I need to store which spells a character knows. While the game is executing I have them stored in a vector. Obviously storing this many values is either going to take a lot of computing to get the ...
8
votes
3answers
610 views

Collision detection problems using AABB's

I implemented a simple collision detection routine using AABB's between my main game sprite and various platforms (Please see code below). It works great, but I'm now introducing gravity to make my ...
-1
votes
2answers
143 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 ...
4
votes
5answers
1k views

Implementing vector based movement in a 2d environment

Good evening. I apologize if the title is a bit vague, I really could not come up with anything better. I am currently reading a book called the nature of code and as a side project, I am working on ...
3
votes
2answers
169 views

What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?

I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library. To project a single vector (X,Y,Z) ...
2
votes
1answer
165 views

front and back face detection

I am trying to implement a dynamic shadow system for a 2d game using this tutorial : ...
0
votes
3answers
168 views

Keeping raycast on the same level

I want my raycast to end at certain height(red line). But as the game is 3D and the camera rotates I can't use a fixed magnitude. What I thought was a stroke of genius, I figured I'd project the ...
4
votes
3answers
1k 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 ...
4
votes
2answers
259 views

Getting an angle in degrees from north

This may have been asked already, but I was unable to find it, because I don't really know what I'm looking for. I drew a picture: I need theta. I've seen various solutions using Vector.Dot, and ...
0
votes
2answers
371 views

Asteroids Movement

I have been making an asteroids clone, in C#. However, the ship's movement is... not quite right. My plan is this: there is a speed, and two directions, namely the direction the ship is facing ...
2
votes
2answers
602 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 ...
2
votes
1answer
564 views

2D Top down acceleration vector

I have been wanting to solve the issue of movement once and for all... with all that I have learnt and read through, should be a piece of cake one would have thought... , seems it isn't. Having ...
4
votes
1answer
508 views

Why game engines usually don't offer a vector3.rotate method? [closed]

Game engines like Three.js, Ogre3d and Unity3d often don't provide a default rotate method on their vector class. You usually have to do something like: rotated = vector.applyQuaternion( new ...
9
votes
3answers
5k views

What are normal, tangent and binormal vectors and how are they used?

I would like to find out the following information: What are they? Example usage in game development (the area they are used in) About the following vector types: Normal Tangent Binormal A ...
1
vote
0answers
104 views

Rotate Points with Object in world space

I posted this in the original stack overflow then realized that a game-dev specific one exists. I am working on personal project that requires me to have 4 points surrounding an object (1 at each of ...
3
votes
3answers
2k views

Getting correct angles between Vector3s

I'm working on a project where you can draw lines between points. You select one point and drag the mouse onto another point and a line is drawn between them. The line itself is a 3d object which is ...
5
votes
1answer
411 views

Rotating plane to be parallel to given normal via change of basis

I have two planes and their respective normals. I would like to rotate the second plane, planeB, so that it is parallel to the first, planeA. To do this, I am using a change of basis to rotate each ...
2
votes
2answers
359 views

Why does handedness matter at all?

I'm really trying to understand this from a mathematical viewpoint. After all, numbers are numbers, the chirality or handedness depends on how one interprets it. Say I've three basis vectors x (1, 0, ...
0
votes
1answer
75 views

How to change Vectors due to change in it's dependent Base Vector?

PLOT : I have been developing a game where the player falls down on Y axis and the camera is a Top-Down view camera. The camera, player (main character in the game) movements etc. have all been ...
0
votes
1answer
179 views

Character movement relative to cursor position

I want my top-down shooter character to move towards the mouse when pressing the up arrow and strafe relative at right angles to it when pressing the left and right arrow keys. I can't figure out how ...
1
vote
1answer
117 views

Movement constrained to the faces of a cube

The basic setup I'm working with is a cube rendered in-Engine (Panda3d, although I only am looking for a generalized solution) as well as a 2d square on one face of the cube. The eventual outcome I'm ...
2
votes
1answer
379 views

Shooting Bullets Around a Sphere

I currently have a ship that can orbit around a sphere freely controlled by a joystick. There is a separate joystick that controls the gun and starts shooting when it is touched. Right now the ...
8
votes
7answers
2k views

What's the best way of transforming 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 transforming that into the closest compass direction? e.g. x:+1, y:+1 => NE x:0, y:+3 => N x:+10, y:-2 => E // ...
0
votes
3answers
1k views

Lerp vs Vector math: one better than the other?

In Unity3D (all versions, I believe), there is a static function for the Vector3D class called "lerp". It interpolates a point between two points a point, based off a provided percentage related to ...