Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Linear algebra is the branch of mathematics concerning vector spaces and linear mappings between such spaces. The tag is generally used for questions regarding calculations over vectors.

0
votes
1answer
27 views

How can I add acceleration to the movement of an object in a game

Below is the code that I'm using to move an object: ...
0
votes
1answer
24 views

How to get 60fps animation in terms of rounding/truncating position/alpha floats

I am wondering what gives the best animation performance running at 60fps with lots of objects. I have seen in a few places such as this that you should round or truncate your values so you don't get <...
0
votes
1answer
61 views

Define a circle from a point on its circumference and an angle

I'm working on a 2D, top-down driving game with some basic AI vehicles. The AI Vehicles move along a bidirected graph of positions. Each vehicle has a current position (from the graph) and a target ...
0
votes
1answer
51 views

Check whether a vector is to the left or right of another position

I don't know how to decide if my point is on the left or right side of another object. My first thought was to check if x-axis of object1 is bigger or smaller than object2's, but if my objects rotate ...
1
vote
0answers
63 views

How do I create the formula for calculate the damage of a skill

I'm trying to calculate the output damage of a skill. The skill can go up from level 1 to 100, it can scale with own levels and the attack of the character. Here some parameters Edit: I need a ...
0
votes
0answers
56 views

Constrain x and y with linear programming

I want to make a modular 2D spaceship game. The user can use building blocks to create the ship. Blocks can be squares but also other shapes that do not fit in a grid. To calculate what thrusters ...
2
votes
2answers
92 views

Find extreme points of a rotated ellipse function on a given axis

How to find the points where it is most extreme on the X and Y axis? For example lets say I have an equation that describes an ellipse that is rotated: ...
3
votes
7answers
2k views

Benefit of using Vector2 data type over separate x & y variables

I'm really curious about why a lot of people and game engines use Vector2 as its coordinate system instead of the traditional x and y value. Is there any benefit to this? I feel like it's just slow ...
0
votes
1answer
42 views

Calculating the shadow cast by triangle onto the YZ plane

So, one of the exercises for my computer graphics class is as follows: Calculate the shadow cast by triangle T onto the YZ plane P. given: Triangle T coordinates: A=(30,10,16) B=(32,11,18) C=(31,...
1
vote
3answers
59 views

How to determine if an object is within field of view given xyz of object, player position, and 3D vector for player view?

I only have the object's position, the player position, and the vector representing the player's view, and I have the FoV (120 degrees horizontal/60 on each side, and 60 degrees vertical/30 on each ...
-1
votes
1answer
54 views

detecting if a chess move is valid for a given pawn , preferably using Linear algebra

I'm making a chess game, where you simply drag and drop a pawn on the board with respect to each player's turn. when it comes to dropping a pawn we need to validate weather the move is allowed. for ...
3
votes
1answer
403 views

What does a linear transformation preserve?

They say an affine transformation preserves points, lines, parallel lines etc. I can see this if I think in terms of translation [Is there any other affine transformation you can give as an example, ...
0
votes
1answer
70 views

Trying to use 3D vectors for a 2D ping pong game

I am trying to setup a virtual ping pong table, and am getting a little stuck in trying to understand how to do 3D vector math and render it in 2D. So far, my plan is for the ball: X = up/down, Y = ...
0
votes
0answers
46 views

Calculate smooth transition between local space angles

I'm trying to calculate direction of moving character (to rotate it's animation). I have something like this: Character can have 4 cardinal directions. The rotation is calculated from the current ...
0
votes
1answer
217 views

OpenGL calculate circle rotation around a given point

I'm trying to rotate an object around a certain point. If this point is the center of my world space I use the following algorithm: glm::vec3 center is the center ...
0
votes
1answer
37 views

How to Calculate Caridnal Direction from Unit Vector

I have unit Vector of acceleration in local space of object. Now I want to calculate Cardinal Direction from (North, East, South, West). So Far I tried to: ...
0
votes
0answers
35 views

How do I calculate a point between two points with a given distance percentage? [duplicate]

I've made a simple drawing: The distance between these two points is calculated with a simple formula: Which gives: 5,38 I need to calculate the green point's coordinates, which is set at 80% ...
0
votes
1answer
217 views

What is FRotationMatrix in Unreal engine 4?

I am working on FPS shooter example in Unreal engine 4 documentation. One of the lines for forward movement of pawn is ...
0
votes
2answers
89 views

Turret aiming code

I'm currently working on turret aiming code. If I can't hit the center of the object (due to an obstacle), I want to see if I can hit any of the object. To do this i'll get it's bounds, and check in ...
3
votes
1answer
173 views

2d Scale width and height based on distance

I'm drawing a health bar on top of each player. I transform 3d position to 2d. I would like to draw it smaller when distance increases. Any simple math for that? Let's say bar width is 30 and height ...
0
votes
0answers
321 views

How do we rotate the camera around x axis 360 degrees?

How do we rotate the camera around x axis 360 degrees, without having to flip the axis, meaning without having the strange flip after we go over +-90 degrees on x axis? Mine behaves exactly the same ...
1
vote
1answer
1k views

How to mirror/reflect/flip a 4D transformation matrix

I am importing my animation keyframe joint data from Blender to my game engine. The joint data is a set of 4D matrices. Things are looking good except a remaining issue where the animation is facing ...
0
votes
1answer
60 views

How to calculate a normalized direction of two rotations?

In Vector math and translations we can do: dir = (v1 - v2).norm and then v1.translate(dir * 50) so ...
3
votes
4answers
225 views

How to determine if the player between two points?

I'm making a skating game and I'm having trouble figuring out how to snap the player onto grinds and rails in between multiple points. My plan was to snap the player onto a point in between the two ...
0
votes
1answer
74 views

Intersection point of two lines with given formula

I have following formula to check the intersection of two line segments: ...
1
vote
0answers
67 views

interace between C and Lua function with 3D vector arguments [closed]

I have C++ function (which runs some physical simulation inside my game engine) which looks like this: ...
0
votes
3answers
611 views

Calculating the distance from a line to a point in 2D

I have a simple setup: How do I calculate the orange distance? It's the distance between the block on the left to the white line in the center (X & Z axes combined). I don't have the ...
4
votes
2answers
469 views

How can I make players move diagonally at equal speeds?

In a tile-based 2D RPG, a character is supposed to walk into all eight directions. However, if we blindly tell the player to move in the direction (1, 1), he will be around 41% (√2-fold) faster. Thus,...
0
votes
3answers
96 views

Determine if the player should be able to interact with a door

You know the drill, standard first person door mechanics. How do they do it? My most noticeable and frustrating problem is when there is a door within range and in view, but the closest door is ...
2
votes
2answers
150 views

Why Change from one coordinate system to another?

When dealing with affine transformations, why do we need to change from one frame to another? What are some reasons. What are the pros and cons of doing this and the limitations if this was not ...
3
votes
1answer
59 views

Scaling a sphere to give identical result, regardless of rotation

how can I maintain a consistent scaling of a sphere regardless of the rotation of the model? For example, take the following (scaled) sphere: In this image, we start with a sphere, looking at it ...
1
vote
2answers
1k views

Need help with getting a direction vector between two given points

I need to find the angle of rotation from a bullet traveling from point A to point B, like in my attached diagram. I tried searching, but I got a little lost in which exact formula to use. I want to ...
0
votes
1answer
139 views

Problem calculating screen point for a point in a 3D world with view matrix and projection matrix

I am trying to calculate the 2D screen point of a 3D world position. For this I use the multiplication ViewMatrix * ProjectionMatrix. But I am not getting good ...
0
votes
1answer
39 views

Can't understand why transformation doesn't work

To make a simple transformation like a rotation I want to use linear algebra -multiplying the vec4 vertex_position by a ...
0
votes
1answer
48 views

Recognize that user has traced a path of vector points with mouse

How can I check if a player has traced a closed vector shape from an arbitrary starting point all the way around to the beginning? Setup Given are the vector points A through E, which form a closed ...
1
vote
1answer
440 views

Why does a unit vector show direction?

If I have two objects, Person A and Person B, and I want to know if Person B is facing the same direction as Person A; once I have the vectors, how do I use the normalized vector to show direction? ...
25
votes
3answers
3k views

How can I rotate an object based on another's offset to it?

I have a 3D model of a turret that con rotate around the Y-axis. This turret has a cannon that is significantly off the center of the object. I want the cannon, not the turret, to aim at a specified ...
0
votes
1answer
315 views

Calculate distance from the centre to the edge of a cube in OpenGL

I'm trying to calculate the distance between a central point on a cube and anywhere on the surface of the cube, depending on the location of a second 3D point. I have two vertices in 3D; ...
0
votes
2answers
68 views

Rotating Object parallel to other object

I try to rotate objects in the same direction as a reference object. Normaly this would be easy: object1.rotation = reference.rotation But the same rotation ...
1
vote
1answer
202 views

Project 3d lines onto plane

I'm trying to wrap my head around coordinate projection, and can't seem to solve the problem I am having. Here is an illustration of it: The cubes represent 3d space, and the 2 red lines represent ...
1
vote
1answer
163 views

How to get the 2d field of view using dot or atan2?

I tried to implement from this site linear-algebra on how do I check the field of view using dot product. But when I check the angle to the given fov angle, I am not getting the desired result. ...
1
vote
1answer
163 views

Pitch/Yaw in circle causes undesired Tilt [duplicate]

I've made my own Camera object, with a forward vector as well as a up vector. I happen to be programming in Android using OpenGL ...
0
votes
3answers
266 views

Scaling a rotated rectangle in a given direction

I'm facing an issue when trying to scale a rotated rectangle in a given direction. In my context, the width and height of the rectangle are based on the texture size multiplied by a scale factor (...
1
vote
1answer
295 views

given the position and velocity of an object how can I detect possible Collision?

I'm trying to detect Collision between autonomous moving objects and steer direction if collision is detected. so far I've been following a tutorial and I'm having a hard time to fully understand how ...
1
vote
1answer
935 views

Calculate initial velocity for trajectory given duration, launch angle, and distance

I need my entity to go from point A to point B with a given launch angle over a given time. I've been able to figure out the initial velocity without the constraint of the launch angle, but I can't ...
0
votes
0answers
370 views

Dot product not working as expected

Recently I am learning dot product, While below code works from Unity's documentation, http://docs.unity3d.com/ScriptReference/Vector3.Dot.html ...
1
vote
1answer
81 views

What are projection independent ways of determining whether a normal is facing the viewer?

A position v and normal n are given in world coordinates. Also there is a view matrix V for ...
0
votes
3answers
61 views

Velocity Relative To A Vector

So I have a velocity vector b in world space and I have a "pointing" vector a in world space. I need to know how to make the ...
0
votes
1answer
887 views

Convert transform from world to local space

I have a hierarchical node system. Given a world space transform, I need to obtain the transform for a specific node in local space. My Node class has the ...