Questions tagged [trigonometry]
A branch of mathematics that studies triangles and the relationships between their sides and the angles between these sides.
140
questions
0
votes
1
answer
24
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:
...
0
votes
1
answer
48
views
How do I determine which pixel is under the cursor when looking at an equirectangular image through a camera?
I am working on a game. The camera is freely rotatable by the user. The background is displayed from an equirectangular image. I need to know which pixel of the background image is located under the ...
0
votes
0
answers
30
views
How can i move actor's bounding box center in relative location in Unreal Engine 5?
This is my situation. I need align the center of the object (it's box) and the center of the scene component. I have only center of the box TVector type or FVector. How can i do it?
...
2
votes
1
answer
124
views
Calculation of far distance plane based on yaw and pitch for a map renderer
I'm working on a vector map renderer. I want to calculate the far plane for a protective transformation, based on the yaw, pitch, roll and height of the camera above the map. Yaw (looking to the left ...
1
vote
1
answer
66
views
How to overshoot with direction_to
I've managed to get my sprite enemies shoot at the player with
...
0
votes
0
answers
69
views
Well tuned orbit camera
I have been trying to make an orbit camera using glfw. I got a working solution which is as in the following.
...
0
votes
1
answer
141
views
rotating a sprite with mouse cursor
i am learning how to make a 2d game using sdl and c++ and am currently trying to rotate the sprite so that is always facing the cursor, my game is set up with an entity component system, i have a ...
0
votes
0
answers
33
views
How do I calculate the position and rotation where 3 given vectors would intersect 3 given points
I have 3 normalized directional vectors and 3 points.
The 3 vectors are all attached to the same object, and I would like them to keep their angles relative to each other.
I want to find a location ...
0
votes
1
answer
45
views
How do I find two points on opposite sides of a circle where the angle of the first point's position is a percent of the whole circle?
I am trying to simulate sunrise/sunset with a linear gradient. I want the gradient to rotate around a circle whose diameter is the width of the screen with the center point being the very bottom ...
0
votes
2
answers
95
views
How do I determine parallax scroll factor?
Implementing parallax scrolling is easy enough. This question is about improving its presentation.
Hand-tuning some parallax scroll factors on multiple layers works, but parallax scrolling is meant to ...
0
votes
1
answer
198
views
Finding the center of rotation in 3d knowing the start/end transformations
I need your help to solve a trigonometry problem, I'm unable to find any documentation about on the web...
For convenience, I will use "transform" to indicate a position+orientation.
Let's ...
0
votes
1
answer
833
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 ...
3
votes
1
answer
136
views
Is there a generic formula to determine the angle of deflection off of a rectangle?
I have a perfect 2D system, with no friction, elasticity, etc. A ball is colliding with a rectangle. I know the angle of the motion of the ball in degrees. I want to figure out how said angle will ...
0
votes
1
answer
1k
views
How do I calculate the direction of an object relative to the another object's view
Here is a diagram of what I'm looking for:
I am trying to find the math solution to determine where that smaller circle is relative to the bigger circle's view.
I thought that the easiest way would ...
0
votes
2
answers
133
views
How to rotate parent object to align child rotation with a separate game object?
I have attached two images with the desired start and end positions.
The Brown Circle is the target rotation. The Orange Square is the parent (the black dot is the pivot point) and the Blue Rounded ...
0
votes
1
answer
70
views
Tangent Space View Direction based factor value remap
I'm trying to setup a mask similar to what Fresnel produces. Unfortunately Fresnel gives pretty bad results at grazing angles so I ended up using this :
...
1
vote
1
answer
84
views
reposition object in circle
As you can see on the image, I have a p1 and p2 objects with (x,y) coordinates which I know the values, and I know radius of all these circle objects.
However, I want to calculate new position x,y ...
0
votes
0
answers
189
views
Moving Object "in or out" along the z axis using Sin(time) or Cos(time)
I am new to game development, and I have successfully moved an object in the x and y directions using Mathf.Sin(x) and Mathf.Cos(x). But I'm unable to move same object in the z-direction (in or out).
...
0
votes
1
answer
86
views
Is there an algorithm for a Joystick class that happens to be engine/framework independent?
I need to be able to get the given input's distance inside the joystick, bounded within -100% and 100% and an unbounded version of it, get the position of where the mouse's position projects to the ...
0
votes
1
answer
63
views
-1
votes
1
answer
48
views
Need help on finding the algorithm for getting the FlipX, Y and TextureRotation of my DirectionalAnimation class
I've created a class called DegreeAnimation, which is basically an implementation of my CustomAnimation class, but works with other directions, there are 2 constructors for this class, one where the ...
1
vote
1
answer
60
views
Trigonometry to move an arm around axis in 3D space
Hello I have a question about rotating a Rod hinged to a fixed point (so it swings all around), and targets. short form, I would like to know how to find a rotation that would point my rod (while ...
1
vote
1
answer
97
views
Could you explain how this GameObject rotating around another GameObject works?
I'm just learning Unity and I follow a tutorial for a simple game which I want to build up from.
I'm already mostly done with the course and at the end a "boss enemy" gets implemented.
Its ...
0
votes
1
answer
691
views
Pygame : problem with calculating an angle between two points
I've been struggling to calculate the angle alpha between an object and a certain point M so that I can move that object to M.
To calculate alpha, I'm using ...
0
votes
0
answers
162
views
How to decay sine or cosine wave so it takes one additional period to reach equilibrium
In many shmups, when enemies arrive, they accelerate onto screen, decelerate, and overshoot their static arrival position slightly, before backing up slowly to the position. This can be seen in many ...
0
votes
1
answer
58
views
How to find if a Ray intersects a Triangle Clockwise or Counter Clockwise
I have a Triangle with an intersecting Ray.
How can I find out if the triangle's vertices are in a clockwise or counter clockwise rotation order with respect to the Ray?
1
vote
0
answers
77
views
How to unfold a spiral of balls?
I have a spiral made of balls. It's a spiral with equally distributed balls using the following formula (see link on math.stackexchange).
This is how it looks like:
Now, the spiral is rolling ...
1
vote
1
answer
78
views
How to add zombie arms to enemies in HTML canvas
I'm making a game with HTML canvas (not WEBGL). I have zombies that go to the center of the screen, but for now they are just circles. I want to give them two arms, like the arms players have in ...
2
votes
1
answer
2k
views
Any fast alternative to sine in GLSL?
Should I just use the built-in sin() function or my custom sine function?
I'm concerned about performance here. I don't care about accuracy much here because I use it to just get wave effects in my ...
0
votes
0
answers
73
views
Get direction vector of camera in voxel game
I am currently working on a Minecraft clone (a voxel game). The feature I'm working on is the ability to break blocks. I have a ray-casting/ray tracing algorithm for traversing the voxels, but the ...
2
votes
1
answer
121
views
Position Object always at the same distance of 2 other moving Objects?
I am making a procedural animation of a worm. I have already something working:
(the green dot is the position Target, purple and red are the Head and the Tail of the Worm)
I would like to add ...
0
votes
2
answers
317
views
When are oblique triangles used in game development?
I'm working on a project that explains how trigonometry is used in video games, and I need to mention oblique triangles.
However, as far as I know, only right triangle diagrams are used in video games ...
4
votes
1
answer
946
views
space map generation
I am at the beginning of the creation of a space 4x and first of all i need to generate a galaxy of stars linked by connecting lines that changes in each new game, I'll add a few pictures to show what ...
0
votes
1
answer
499
views
Convert GPS coordinates into Unity world space?
I am developing an AR application where a number of historical buildings are spawned around the player depending on his position when a target / QR Code is recognized.
I know the Lat/Lon of these ...
1
vote
0
answers
68
views
How To Place Object On Ground Within Radius?
I'm using Unity and I'm building an object placement system where you'll be able to position objects around the player.
I'd like to place objects flush with the ground, parallel to world up, even on ...
0
votes
1
answer
88
views
3d points to rotation matrix of orientation
I have a vector in a 3D view, defined by a point p1(x1, y1, z1) and a rotation r1(x1, y1, z1). I can get a direction and a yaw. I need that vector to point another point p2 (x2, y2, z2). So I need a ...
0
votes
1
answer
615
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
}
0
votes
0
answers
180
views
Pong paddle and deflection angles
I'm trying to make a pong clone and am having trouble grasping ball deflection. The way I'm approaching it is to increase the angle by how far the ball collides from the middle of the paddle. However, ...
3
votes
2
answers
538
views
Why are rotations in 2D game engines often counter-clockwise = positive systems?
I was looking over the API for a game engine a friend was developing in her spare time. She made the decision to make positive angles rotate in a clockwise direction. This immediately struck me as odd....
1
vote
1
answer
578
views
SIMD and Inverse Tangent
I'm calculating spherical UV coordinates in a loop, trying to get GCC to vectorize the code.
Here's a compile-able example of what it looks like.
...
2
votes
1
answer
89
views
Triangular Metric
Given a point inside a unit equilateral triangle, how does one rotate it across the triangle perimeter? I.e. the triangle outline serving the same purpose as circle's circumference. That is actually a ...
-1
votes
2
answers
380
views
I need help with calculating the angle my character is aiming at
So im doing this program where i want my hero to shoot to the direction its facing , but for this job to get done i need to calculate the angle my hero is facing with Math.atan2() , atleasts thats ...
0
votes
0
answers
71
views
Adding spread to velocity Vector3D
I am trying to give an object a velocity spread (e.g. shotgun bullets or particle effect).
...
1
vote
2
answers
135
views
How to get the Javascript equivalent of GameMaker's `hspeed` and `vspeed` given only `direction` and `speed`?
I'm using a NodeJS server to control NPC movement in a multiplayer game, and when they get too close to the edge of the room I need to reverse either the horizontal or vertical components of their ...
1
vote
1
answer
71
views
Sum of FoV enemies
so what I need is to calculate the sum of players' Field of view.
Put simple, In a 2d space, I want to check how much they cover (in degrees).
So here are a couple of use cases to explain by example:
...
0
votes
0
answers
71
views
Camera LookAt position with fixed screen position
I have a perspective "lookAt-type" camera. I'm trying to compute specific focus point of the camera, which should be placed in the middle of the screen: I also have a custom 3d point in world space, ...
0
votes
1
answer
95
views
Finding Closest of 8 Possible Angles to Theta Value
I'm working on creating a gesture recognition system, and I saw one simple implementation that isn't as accurate, but is really easy to implement. The idea is that you have a unit circle with the 8 ...
0
votes
2
answers
152
views
How to panning camera on XZ axis with different angles
I have an Orthographic camera where the position is { x:0, y:100, z:0 } and is pointing/looking at { x:0, y:0, z:0 }. At this ...
1
vote
1
answer
39
views
Why does the first red-zone sometimes appear too close to the border in my battle-royale red-zone feature?
The Problem:
If you've ever played or watched some gameplay of a battle royal game (like PUBG, for example), you'll always find an event during any battle called the red zone.
Basically, at a ...
0
votes
1
answer
213
views
Combine rotation XZ (horizontal) with YZ (vertical). Math formula
I'm trying to make a rotation vertically and horizontally around a point at the same time but I'm not able to combine both.
I have this formula for the horizontal rotation:
...