Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [linear-algebra]

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.

-1
votes
1answer
66 views

How to detect least distance to line segments calculation

I'm trying to calculate the distance of the player to a few lines that intersect two points, and return the smallest distance (i.e. tell me which of the lines the player is closest to/how far the ...
0
votes
1answer
43 views

Finding translation component of a 4x4 matrix inverse

I have 4x4 matrix (A) (maya softw): ...
1
vote
0answers
81 views

Applying multiple forces on a particle

If I have a particle, say in a polar coordinate grid, and I want to apply multiple vectors to it, how can I calculate where it's final position will be given those vectors? Ex. Imagine there's a ...
0
votes
0answers
54 views

Getting the Closet Points between Polygons with the GJK Algorithm

I am trying to implement the GJK algorithm by following this lecture. For the most part, it is working, but sometimes 1 of the 2 closest points is incorrect. Here are two examples: EXAMPLE 1: The ...
0
votes
0answers
56 views

Leading a target with edge casting

I am trying to write a movement prediction code. I have found the quadratic method with these topics: [1]: How to calculate shot angle and velocity to hit a moving target? [2]: http://...
1
vote
1answer
291 views

Convert global 3d coordinate system to a local one with specific direction

Imagine a (x,y,z) coordinate system within a solar system, with (0,0,0) beeing the center of sun where Z axis goes thru both solar poles. I'm standing on a planet inside a house within that solar ...
0
votes
1answer
42 views

2D converting absolute top-down coordinates into relative third-person coordinates

I'm working on 2D top down zombie game. I started working on it as having a static 2D map and on every tick you update the coordinates of every object, including the player itself relative to the ...
0
votes
1answer
31 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
31 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
64 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
319 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
108 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
64 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
253 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
47 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
104 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
97 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 ...
4
votes
1answer
1k 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
93 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
59 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
670 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
77 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
41 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
580 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
99 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 ...
2
votes
1answer
410 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 ...
2
votes
1answer
3k 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
109 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
235 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
76 views

Intersection point of two lines with given formula

I have following formula to check the intersection of two line segments: ...
1
vote
0answers
124 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
961 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 ...
3
votes
2answers
619 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
102 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
216 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 ...
2
votes
1answer
89 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
2k 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
227 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
41 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
54 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
678 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
5k 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
488 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
73 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
265 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
192 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
218 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
420 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 (...