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.

Filter by
Sorted by
Tagged with
0
votes
0answers
28 views

What is a good algorithm for generating a linear regression of positions in 3D space? (for getting the direction of a thrown object in VR)

I'm trying to get throwing to feel right in my VR game. I don't plan on actually using physics to do this; my idea is to accurately determine the lateral direction of the throw, then move the object ...
0
votes
2answers
140 views

How do I detect collisions between a point and a sloped line?

The character in my game constantly falls due to gravity, so i have to detect the collision between the bottom point of the character and the tile slope line on the same x coordinate. The character ...
1
vote
0answers
50 views

How to vary the initial velocity of a jump based on hold time?

What I want to do is, the longer player holds the screen, the longer distance the object will jump when they release the hold. Here is my code: ...
0
votes
0answers
13 views

Calculating the position of a third person camera from its right vector

I have a 3rd person camera, that always looks at the player from a certain distance. It updates its x and z position around the player in relation to the yaw value received from x axis mouse input. I ...
1
vote
1answer
40 views

How to mirror a vector through some other vector?

I have a player's direction (playerDirection). I want to fire two bullets, one rotated by -30f, and one by 30f, so it looks like this: Blue line is the ...
0
votes
0answers
25 views

Account for scale offset?

I have an odd situation where I know the position of an item on a mouse click and I know the panning state of a 2D camera pointing at it. So what I do is render an object at the point in which the ...
0
votes
0answers
26 views

Moving point (as line)-Polygon collision detection

i've reached a good point with my engine, with static/instant collision detection and callbacks in case of collision. By instant collision detection i mean: Object A moves from x1y1 to x2y2 Check if ...
0
votes
1answer
34 views

How to create a custom set of coordinates based on two points in Unity?

As the title says, I am having problems finding a way to create a new set of local coordinates based on two points. Here is an example: Consider that the two gameObjects are not one parent of another,...
-1
votes
1answer
143 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
91 views

Finding translation component of a 4x4 matrix inverse

I have 4x4 matrix (A) (maya softw): ...
1
vote
0answers
82 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
81 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
60 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
444 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
92 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
37 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
32 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
69 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
606 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
146 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 ...
2
votes
2answers
375 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
55 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
201 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
123 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
115 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
63 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
1k 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
108 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
43 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
847 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
112 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
543 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
5k 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
178 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
240 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
80 views

Intersection point of two lines with given formula

I have following formula to check the intersection of two line segments: ...
1
vote
0answers
144 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
1k 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
713 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
106 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
265 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
108 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
3k 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
276 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
56 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
750 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? ...