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
1 vote
0 answers
411 views

What is the correct way to combine transforms together?

I have a type called transform in my game engine: ...
Guillaume Racicot's user avatar
0 votes
1 answer
117 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 ...
lufydad's user avatar
  • 103
1 vote
2 answers
476 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 ...
heckj's user avatar
  • 138
0 votes
1 answer
316 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 ...
Suic's user avatar
  • 119
0 votes
1 answer
179 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 ...
Suic's user avatar
  • 119
0 votes
1 answer
407 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) ...
Disco Fever's user avatar
0 votes
1 answer
535 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, ...
BumbleBee's user avatar
2 votes
1 answer
573 views

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

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 ...
SpermesePython's user avatar
0 votes
1 answer
344 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: ...
Daniel Marques's user avatar
2 votes
1 answer
2k 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 ...
GabeTheApe's user avatar
14 votes
2 answers
5k 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 ...
Job_September_2020's user avatar
0 votes
0 answers
101 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......
Ryan Glenn's user avatar
0 votes
0 answers
42 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.
Ryan Glenn's user avatar
2 votes
0 answers
108 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 ...
Megan Bohland's user avatar
0 votes
1 answer
37 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 ...
Rick Stanley's user avatar
1 vote
1 answer
74 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 ...
user438454534's user avatar
0 votes
0 answers
90 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 ...
MrRobot9's user avatar
  • 321
1 vote
2 answers
270 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 ...
Ginger and Lavender's user avatar
0 votes
1 answer
146 views

Measure a distance between the start and end of a drag

I tried to measure a distance from one point to another point on my phone screen by using following code: ...
vito's user avatar
  • 107
0 votes
1 answer
547 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 ...
Nakel's user avatar
  • 3
0 votes
0 answers
124 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 ...
Jan's user avatar
  • 1
2 votes
3 answers
2k views

How to fix diagonal velocity being greater than axis-aligned?

I have a 2D top-down RPG type game, with movement in 8 directions (N/E/S/W/NE/NW/SE/SW) involving both x and y velocity. I'm finding when I'm moving in the diagonal directions, I'm building both x and ...
kite's user avatar
  • 207
0 votes
0 answers
118 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 ...
user148279's user avatar
0 votes
1 answer
681 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/...
Megidd's user avatar
  • 141
1 vote
1 answer
189 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 ...
Suic's user avatar
  • 119
0 votes
1 answer
1k 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 ...
Daniele Pappalardo's user avatar
0 votes
1 answer
94 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, ...
Akros's user avatar
  • 15
1 vote
1 answer
4k 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....
OKprogrammer's user avatar
1 vote
1 answer
49 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 ...
Kaitlyn Emmons's user avatar
0 votes
1 answer
65 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 ...
IC_'s user avatar
  • 163
0 votes
1 answer
719 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 ...
JungleCoder's user avatar
2 votes
2 answers
536 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 ...
Hasen's user avatar
  • 194
4 votes
1 answer
340 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 ...
Ali Kanat's user avatar
  • 143
0 votes
1 answer
993 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 ...
Jesse Williams's user avatar
1 vote
1 answer
381 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 ...
Ty Miles's user avatar
2 votes
1 answer
3k 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 ...
Ryoku's user avatar
  • 187
0 votes
1 answer
262 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 ...
codymanix's user avatar
  • 364
0 votes
1 answer
234 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 ...
user5074736's user avatar
0 votes
3 answers
678 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 ...
vK31RON's user avatar
0 votes
0 answers
327 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. ...
BioAbner J's user avatar
0 votes
1 answer
679 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 }
jony alton's user avatar
0 votes
1 answer
470 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 ...
user3180's user avatar
  • 101
1 vote
1 answer
2k 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 ...
Rui d'Orey's user avatar
1 vote
1 answer
160 views

2D Collision detection: rewinding to moment of first intersection

I am working on a collision system in a Platformer tile-based game. All tiles are AABB. I am trying to implement "Rewind to Moment of First Intersection" mentioned in this post's second point. The ...
weno's user avatar
  • 541
0 votes
1 answer
3k views

How to set rotation of object using angle between two points?

I have a LineRenderer that draws a line between two points, Vector3 startPos and Vector3 endPos. How can I get the angle between these points, and apply it to an objects transform rotation, so that it ...
Green_qaue's user avatar
  • 1,903
0 votes
0 answers
83 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 ...
Roderick's user avatar
  • 121
0 votes
2 answers
591 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 ...
venom007's user avatar
1 vote
0 answers
69 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: ...
ken's user avatar
  • 125
1 vote
1 answer
358 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 ...
Jacob's user avatar
  • 2,532
0 votes
1 answer
666 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,...
FSic's user avatar
  • 176