Share Your Experience: Take the 2024 Developer 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.

263 questions
Filter by
Sorted by
Tagged with
1 vote
19 views

### Pan orthographic non-axis-aligned camera

I'm trying to create a panning control for a camera in bevy, but I can't seem to get the panning logic right when the camera is rotated. It works fine if the camera transform is directly facing the XY ...
• 111
1 vote
25 views

### Orbit Camera In vulkan

I've been having trouble trying to make a solidworks style Orbit Camera, nothing I do seems to work even though apparently it should (I've tried multiple methods and this seems to be the most ...
• 11
25 views

### Matrix parent-child transformation for 2D positioning

I am working with matrix math for parent / child transformations. I have to modify existing calculations to keep child scale constant while also keeping child position relative to its parent. Here's ...
53 views

### Why doesn't my Raycast detect AABB collision?

I have the following struct that calculates Raycasting: ...
64 views

### How to tell when calculating an Intercept Point between two moving objects, when it will never intercept?

I'm not a maths person and the formulas you see on maths type questions/answer with all the symbols is completely beyond me - I'm sorry. However I had help about 18 months ago to turn a provided ...
91 views

### Calculate Up Vector of Object on Surface Given Points and Normals

Context I want to find the up vector an object would have if it were leaning on a surface, given a large amount of points on that surface and their associated surface normals (i.e., an equation that ...
• 21
1 vote
36 views

### 3D transform hierarchy rotation applied in wrong order

I'm following in the footsteps of this blog in implementing a transform hierarchy to my game engine scenes. I have a fairly similar implementation for a 3D transform: ...
• 11
1 vote
169 views

### Calculate path segments size

I have a problem more closely described on a picture below. The idea is that I have my agent in point A and I want to get to the point B. The problem is, that agents rotation towards point B is alpha ...
• 13
33 views

### Ray-Sphere Intersection Always States Ray Origin Is Point Nearest Sphere Center

I am writing a simple graphics engine using Rusts WGPU. I have a Sphere rendering at the origin of my scene like so: ...
33 views

### What is the relation between the magnitude of the cross product and dot product of two vectors?

If I have an equation: |A×B|=A.B What would be the angle in between A and B?
• 1
61 views

### Is this gimbal lock I'm hitting even with rotation matrices / quaternions?

I'm spawning a trigger box relative to another object using local offset. The engine I'm using does not provide a native function to make that conversion (at least in a way accessible to me), so I am ...
• 176
47 views

### Getting the scalar speed from an X and Y velocity [duplicate]

Given a Vector2(x,y) that represents an object's velocity, like so: ...
• 101
135 views

### Inconsistent Speed Of A Projectile Traveling On A Bezier Curve

What I'm doing: I'm moving a projectile to it's target along a Bézier curve with one control point. The projectile moves from Transform A to ...
• 190
267 views

### How do I use these Unity math functions in Godot C#?

Here's a list of math functions I'm having trouble finding a direct function match for in Godot C#: ...
• 145
8k views

### How do game engines avoid recalculating normals upon mesh rotation?

Assume that a face of a mesh is defined by vertices A, B, C and that the normal of the face ...
• 326
154 views

### Generating tris for concave polygon 2D

I have an arbitrary array of points that describe vertices of the polygon 2D, they ar in order. To generate plane mesh for that, I need to generate tris. For something like circle/hexagon/square it is ...
170 views

### Finding the closest point on a circle to end of a ray in 3D

I have a circle in 3D space, so we have center C with radius r, and the normal of plane the circle lies on, N. There is also a normalized vector V that I am modifying to go far past the circle's ...
104 views

### How to calculate shadow position below arcing projectile in Isometric 2d tilebased grid?

I have an Isometric 2D grid-based tilemap, and am firing a projectile (at Vector P1 in image below) from the player (at Vector A) to a location "above" a target location (at Vector B). This ...
• 101
49 views

### Calculate direction to push player away from wall

I'm trying to write a common 2D game and using vectors for physics. I have 1 wall and 1 player object that can move diagonally (both are squares without rotation). When the player object collides with ...
• 1
146 views

### Convert terrain vertex position to global position

I am trying to set the terrain's heights data at runtime with a simplex noise function, while stumbling with converting the local position of the vertices to global position to use as input to keep ...
• 165
1 vote
161 views

### Deflecting projectiles back towards enemies

I am working on a 2D side scroller. I have created an enemy character that shoots at my player randomly within a specific time interval. So, I want to deflect the projectiles back toward the enemy ...
• 15
351 views

### How to set up view and model matrices for 3D rendering?

For various reasons I am building a very simple graphics engine. I have a pretty good 2D thing using plain SDL2 and C that essentially boils down to a single "putpixel" function. I can ...
• 235
33 views

### Error in directional light shadow projection matrix

I have VC++ code for DX9 that draws shadows perfectly. ...
• 205
135 views

### How to find the distance to the middle of the road from the car's current position?

I have the car's current position Vector3 and an API that gets me the closest point on the middle of the road to any Vector3 ...
• 117
1 vote
186 views

### What's the purpose of this cross product and dot product in triangle clipping code?

I have this code that inserts a triangle into the drawing list. The PHD_VBUF structure stores one x,y,z vertex. If the vertex is behind the front plane, then ...
• 205
38 views

### Predict whether projectile is coming at a teammate

Related to this question How to project a Vector3 onto the xz plane? ...
• 117
1 vote
833 views

### How to project a Vector3 onto the xz plane?

I have this code that tries to check whether a lobbed grenade will head toward a teammate: ...
• 117
71 views

### Align two meshes given 2 faces

I have two meshes (A and B) and I know that a triangle in A has the same size and same angles as a triangle in B. For simplicity, suppose A is an octahedron and B is a tetrahedron. And suppose the ...
• 961
123 views

### Find where two (mirrored) 2d vectors intersect a rectangle bounds

I've created a 2d gradient shader which uses an absolute start/end point to determine how an arbitrary amount of colors are positioned along the gradient line. I now am creating an api to create a ...
53 views

### How to encode homogeneous transformations on the root node of a gltf

Let us say we have a gltf asset. Let us say we want to apply an arbitrary linear transformation to the root node. We will say that the root node has a rotation, translation and scaling components. For ...
• 260
1k views

### Aim projectile to intercept moving target from a moving ship

So I have created spaceship shooter game where ships have turrets on them . Now I want those turrets to shoot a moving target meaning I want the projectile to intercept and hit the target that is ...
1k views

### Using atan2 vs dot product to get an angle in 2D games

I have some confusion that I need to be cleared up about the atan2 function. I am making a game in Godot where a 2D ship rotates to face some object in space by ...
191 views

### 2D turret aiming at the player, but only within a certain arc and with a defined angular velocity

I have a turret game object and a player game object, say it's a spaceship. Right now, every frame the turret updates its rotation, so it's always pointing at the player, giving it potentially ...
302 views

### Cue ball direction after collision

I am trying to figure out the velocity of ball A after collision, which is V2.A as seen in the figure. I know that the velocity of ball A is perpendicular to the line connecting centre of ball A and B ...
• 57
1 vote
1k views

### How to divide a Vector3 to recover a scale factor?

I have object I'm scaling by setting its localScale to (1, 1, 1) multiplied by a float size. ...
1 vote
154 views

### Given a quad in 3D space with two diagonally opposite points and normal, how would I find the other two points?

Image attached below for clarification: So here we have a plane with a random rotation in 3D space, and we have the values for P1, P2, and the plane normal. How do I find the points X1 and X2? This ...
• 23
104 views

### Move object on World's XYZ axes

I'm trying to move my Character on the world's XYZ Axes, but how do I get them? I'm trying to do this because my Player is sort of a Sphere and is rolling around, so its xyz directions are rotating. I ...
60 views

### Compute thrust applied to ship's sails depending on sailSize, sailState and relative angle of wind

I'm trying to calculate the speed of a ship, depending on many factors. the speed of the wind the relative angle between the sails forward and the wind forward. transformed into ...
134 views

### Get component of velocity parallel to a normal

I would like to transform a rigidbody's world velocity into a local velocity based on a normal direction. When the rigidbody is moving towards and within a range of a object, I use a raycast to ...
81 views

### 2D Vector local to global space without trig/sqrt

Per this answer to this question, a cheap way (i.e., without trig/sqrt) to convert from global to local space, given LocalOrigin, LocalI, LocalJ, and GloablPoint is (in rough pseudo code) ...
• 101
1 vote
54 views

### How to insert a new control point on 3D cubic Bézier spline, without deforming current shape?

I have a spline generation system using a cubic Bézier algorithm. I created a tool that splits the spline and adds a new point where the user clicked on the spline, but it causes the spline to deform ...
• 31
798 views

### Is it possible to calculate a direction vector without sqrt?

I'm not using Unity or any other library for making game logic. I'm making a basic game logic that needs to do basic vector math on the backend side. I just wrote a direction function that needs to do ...
• 2,628
1 vote
1k views

### Calculate normal and plane orientation using 4 3D points

I have 4 points as Vector3 in 3D space that shape a plane. How can I calculate the plane normal direction these four points create together, and express it as a <...
• 31
94 views

### I cannot understand this change of basis problem

I know we need to get the inverse of transformation matrix first to get the coordinate relative to other frames. Explanation is in this video. I am reading directx11 book. And the following ones are ...
142 views

### How does this 4 by 4 matrix (about 4 points are coplanar) come up with this equation?

I have just begun learning some 3d mathematics and OpenGL (trying to implement skeleton animation). I am stuck here when reading a book(Advanced Methods in Computer Graphics). I understand the first ...
443 views

### How to find vector representing altitude of a triangle?

I'm trying to find this green vector and I've got three points A, B, C. How can I find that vector in Unity code-wise?
270 views

### How to navigate a moving 2d spaceship under newtonian mechanics to a point in space?

I am creating a real-time game where ships move through space using basic laws of motion. The ships move by rotating (instantly for our purposes) to an angle and then firing their engine to accelerate....
• 41
191 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 ...
• 376
1 vote