2022 Developer Survey is open! Take survey.

# 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.

213 questions
Filter by
Sorted by
Tagged with
62 views

### X axis intersection with inverted Y axis coordinates

I'm making a visual clue for the player to know where (and more or less when) an asteroid is going to enter the screen. For this I'm using a triangle pointing at the incoming object and color ...
• 13
36 views

### Why does this obstacle avoidance steering behaviour get stuck going left and right?

I am studying obstacle avoidance steering behaviour. So far I got arrive seek flee, and wander behaviours working, so the math should be right. Why doesn't this avoid steer behaviour work, though? It ...
• 217
22 views

### Draw a plane in fragment shader using determinant?

I'd like to use the determinant of a matrix to draw a plane in the fragment shader. But I don't understand how to come up with the matrix. Let's say that I have 3 points that lie on the plane: A, B, ...
38 views

### Calculate the angle of rotation between two vectors relative to the first vector

I'm trying to get the angle between two 2D vectors relative to the first vector input. Every method I've tried has given me a value between 0-180 degrees but doesn't tell me whether it was a clockwise ...
1 vote
120 views

### How to slide along a wall at full speed?

I was reading this answer, and while it works for that use-case, mine is slightly different (simpler?), but I can't figure out how to do it. What I'm looking for is a way for the player to retain ...
• 175
21 views

### writing a custom Quaternion.FromTo

I'm using the new Unity.Mathematics library. I'm trying to to replace Quaternion.FromTo(Vector3 from, Vector3 to) which returns a quaternion with what it would take ...
• 723
1 vote
49 views

### What is the correct way to combine transforms together?

I have a type called transform in my game engine: ...
27 views

### Torque orientation when changing the coordinate system

I have some Unity application, where the user can input a torque that will be apply to a given rigidbody. Nonetheless, the sophistication comes from the fact that the input from the user is in a given ...
• 103
1 vote
46 views

### How to solve for the angle of a axis/angle rotation that gets me closest to a specific orientation

I’m using a 3D affine transform (a 4x4 matrix of floats) to represent a combination of translations and rotations in 3D space doing a sort of 3D turtle graphics kind of thing. From this state I know ...
• 138
76 views

### Planar projection texture mapping algorithm to UV coordinates algorithm explanation

I am using an engine that uses a texture mapper where instead of providing per-vertex UV coordinates a 3D point(P) and 2 vectors(M, N) is provided, the texture coordinates can be directly computed ...
• 119
65 views

### Converting UV coordinates to planar projection algorithm

I'm using an engine that implements a texture mapping technique where the texture map for each triangle is defined by a point(P) and 2 vectors(M, N) instead of per-vertex texture coordinates P defines ...
• 119
12 views

### How to convert local location to global location given orientation?

I'm working with Unreal Engine and I've come across a scenario where I have a location vector point in local coordinates and I need to transform it to global ...
175 views

### Make object follow another object like a dog sled

I'm trying to achieve the effect of a dog sled for a small prototype. All my attempts failed until now. I have the following code (inspired from this) ...
• 113
69 views

### confusion on desired velocity

In one of the videos of the dead earth game dev series , the author mentions of calculating a local desired velocity of a NavMeshAgent. My point of confusion was, ...
1 vote
64 views

### How to rotate a 3D object based on stick Input and the normal of the ground's surface? (Unity3D)

I am making a game where I want to view an object from any angle and use an analog stick to rotate it according to this input and the surface the object is currently resting on. Here's a visualization ...
83 views

### Calculating child world translation, rotation and scale

I'd like to know if it's possible to calculate a child's world translation, rotation and scale individually. I'm used to seeing devs resorting to matrix multiplication and then decomposition, like so: ...
257 views

### Difference between World matrix and Model matrix?

My current understanding of the Model matrix is that it is per object and stores the transformation, rotation, and scale of the object in local object space. What I'm not sure about, is that whether ...
• 149
3k views

### What are some good examples of the practical usages of cross product in game development?

I know how to calculate cross product, and know that the cross product of 2 vectors is a third vector that is perpendicular to a plane created by the first 2 vectors. However, I have not seen any good ...
50 views

### How do I create surfing?

I want to know how I can lerp from my current position, to another position, while hugging the terrain. Imagine I'm doing something like surfing, or skateboarding, where I need to follow the rail......
27 views

### Do vectors have to be normalized for dot product to be useful? [duplicate]

Why do I get two entirely different answers when I do and do not normalize my vectors. When I don't normalize them, they give me some very large numbers which aren't useful.
56 views

### Struggling with 3D math concepts. Would like practice [closed]

Hello fellow game developers! I graduate this October with my Bachelor’s of Game Programming and Development. I took the required Calculus and Linear Algebra. While I passed the classes I feel like I ...
178 views

### Writing a sphere-sphere intersection function

I am writing a function where I have two 3d points with coordinates {x, y, z} both with a line segment of a given length. I am trying to find a common endpoint between the two line segments closest to ...
27 views

### How to check if a line casted from one point to another point passes through a mesh?

Let's say we have two vectors A and B. Is there a way to use Three.js' Ray or Raycaster classes to cast a line between vector A and vector B and check is it passes through a mesh in the scene? I know ...
1 vote
55 views

### Linear algebra: Are vectors that define a game object considered to be a subspace?

In Linear-algebra a subspace is a collection of vectors that when added with each other or scaling would result in another vector in that same subspace. How does subspaces relate to objects/players ...
• 77
33 views

### How to check if a particular vector is pointing at X-Y plane or Y-Z plane

As you can observe from the diagram, Vector A is pointing at the Y-Z plane and Vector B is pointing at X-Y plane. Is this possible to find? Am I missing some logic or concept? EDIT: Suppose, Vector B ...
• 301
1 vote
58 views

### Given its direction, and another vector that begins at the same point, how can I find the magnitude of that vector using only vector math?

I've solved this using the law of sines, but I was wondering if there's a way to do this with just vector math. Here's a diagram that will hopefully help illustrate what I'm trying to do: Given ...
189 views

### Transforming Vector3 points to Vector2

I'm trying to convert a list of Vector3 on Vector2 because I need to put them in a graph like this: The graph is easy to do having the Vector2 list, but I have a non-trivial problem obtaining the ...
50 views

### Rotating a cube with arrow keys

I have a list of rotations (on a cube in 3d space with the y-Axis pointing upwards, x-Axis pointing righthand and z-Axis pointing towards you) for example +90 deg around x-Axis followed by +90 deg ...
• 1
22 views

### Scaling transforms by time, Eigen Decomposition of Affine Transforms

I posted this question in mathematics, but that sight gets flooded with homework problems... 8 views total, most of them me. Plus, I think this question is more geared to game development anyway. I am ...
210 views

### Invert parent transform (doesn't work for combination of rotation and scale)

My problem I'm working with Qt3D and my problem is almost exactly like this one: https://stackoverflow.com/q/60995155/3405291 Suggested solution A solution is suggested here: https://stackoverflow.com/...
• 141
1 vote
119 views

### Find projecting triangle for UV mapping in RuneScape model format

I am using an old Runescape model format, also used by Thief and Quake. In this format, instead of specifying UV coordinates for each vertex ABC, we specify a second trio of vertices PMN. Those ...
• 119
162 views

### How to detect direction of rotation?

I have a character with a camera behind him. The head of the character rotates with the LookAt function on the character's head rig. The ...
79 views

### How to get correct axis for scaling from transformed space?

I have scaled and non-scaled representation of model so that I don't destroy verticis information if model will be scaled to plane, for example. Now I trying implement scaling on model elements (face, ...
• 13
1 vote
397 views

### How to Make GameObject move in Circular Motion

I've been trying to work an enemy that moves in a circular motion for my RPG game, but for some reason, whenever I press play the GameObject instantly goes hundreds of units in the X and Y coordinates....
• 474
1 vote
42 views

### Find point along x axis where yz plane flips to back facing after perspective projection. Have a solution but don't know why it works

I am trying to find the point along the x axis where a plane with normal pointing along the x axis would flip to back facing after perspective projection. Essentially the red line in this image. My ...
48 views

### How to re-calculate orientation vectors when one of them is being changed?

I want to implement a Unity-like API for my transforms, with the ability to set forward, right, up vectors directly and change object's rotation quaternion accordingly. I got stuck at the math behind ...
• 163
305 views

### Understanding use of dot product in speed boost pad

I am trying to understand the dot product. I have found a website that gives you intuition about this topic and one of the examples involves a speed boost pad: Imagine the red vector is your speed (x ...
330 views

### LibGDX Efficient way to reduce a vector's value gradually until it reaches 0,0

I can manage to achieve this but the code seems to be much longer than it should be. Velocity is given an initial value, either positive or negative and then is ...
• 185
269 views

### How to scale major and minor radius of a quarter torus

I am dealing with quarter tori as in the image below. My issue is that I need to be able to scale its major radius and minor radius separately using a scale matrix. However, when I use a regular ...
• 143
386 views

### Ordering vertices of a face for correct triangle definition

I'm trying to ascertain the appropriate order of vertices for the face of a mesh that is programmatically created. Currently the face is always a quadrangle, but eventually a face can consist of any ...
• 1,309
186 views

### What is the signifigance of the Dot Product in World to Local Transformations?

Looking for help understanding why this World to Local Space function works. I'm working my way through Buckland's Programming Game AI By Example The following function is used in the book to convert ...
1k views

### Should 3D transformations be represented by a 4x4 matrix or a 3x4 matrix?

Since 3D transformations are represented by 4x4 homogeneous matrices we know that their last row is always (0,0,0,1), and as such the behavior of this final row is implied so long as we know whether ...
• 167
79 views

### Check if point is inside convex hull

I first tried with a simple axis aligned bounding box to test my algorithm (later shape will be different but always convex 6 faces), but even this case did not work, it always tells me that the point ...
• 334
132 views

### Rotation of a 3D ball on a plane

This used to be on the physics stack exchange but I was told to put it here: I'm making a game (with physics) and I have a 3D ball rolling down a flat plane. It moves perfectly fine, but the rotation ...
287 views

### XNA Rotate Vector2 around Origin

I have a Rectangle and a Vector2 position, my sprite is being drawn at this position. The rectangle is meant to be a collision system with the cursor, when I rotate my sprite around the origin and ...
140 views

### OBB Frustrum Culling in Clip Space

I've been trying for a while to implement a frustum culling method using a per-computed AABB in object space and transforming it's corners into clip space. ...
• 101
434 views

### Arc length between two angles

As I calculate the length of the arc (green) between two angles; I need a method like: arc_lenght (xpos, ypos, radius, ang1, ang2) { return arc_lenght }
• 101
296 views

### Project 3D points to a plane, then project their bounding box back to 3D

I have a table in 3D space, represented by a plane. I want to project arbitary points representing an object (cup, toy, etc) onto that table, run 2D principal components analysis to get an oriented ...
• 101
1 vote
1k views

### THREE.JS - How to know the shortest rotation direction an object must do to look at other?

I am trying to understand a way in THREE.JS (and the mathematical foundation) to get the direction an object should rotate to lookAt other but without actually rotate it. I've tried to use ...
• 143
1 vote