Questions tagged [trigonometry]
A branch of mathematics that studies triangles and the relationships between their sides and the angles between these sides.
149 questions
0
votes
0
answers
81
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
141
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
76
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
78
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
105
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
172
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
41
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
242
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:
...
1
vote
2
answers
303
views
Algorithm to produce a 2D 'flying through space' effect like the old Windows screen saver
I am old. My high school maths is a long way in my past and I am struggling to devise an algorithm that will produce a 2D 'flying through space' effect like the old Windows screen saver. It has—
...
0
votes
1
answer
640
views
Getting an object to move in another objects direction
I have a player and an enemy, both have x and y values, and I want to move the enemy to the player and have them 'touch' over time in a speed that I can determine, I tried calculating the angle ...
1
vote
1
answer
1k
views
Move object at angle like a sine wave
I currently have this code, which moves an object in a straight line at an angle, where "dir" is the angle.
velX = (float)(Math.cos(Math.toRadians(dir))) * speed;
...
1
vote
1
answer
56
views
Aim/Scope Oscillation Algorithm
I have been struggling to find an algorithm to implement something that will make a direction oscillate within a cone constraint, in a helix-shaped fashion as in photo (it will always go back to the ...
2
votes
3
answers
319
views
Are there recursive variants for trigonometric functions to potentially improve performance?
This is perhaps a better question for mathematics SE, however, this deals more with the performance side of gaming, and software in general. When I say recursive function, I mean recurrence relation.
...
2
votes
2
answers
6k
views
How can I correct an unwanted fisheye effect when drawing a scene with raycasting?
Hello I have a game using raycasting for the TI Nspire in Lua, and when the player faces a wall so that their degree they are facing is perpendicular to the length of the wall, I am having what is ...
0
votes
0
answers
199
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
1
answer
60
views
Moving a point on a rotating sprite
I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite ...
0
votes
0
answers
17
views
How to calculate Camera “correct” position and distance to Frame all my Scene? [duplicate]
Consider I have N dynamic points on my Scene, I would like to "frame" all them, with my Camera.
How can i calculate (at runtime) Vector3 Position to correctly frame all my scene ?
This is my idea:
...
1
vote
0
answers
667
views
Help with simple 2D Lens Flare effect
I'm currently trying to do a Lens Flare effect in a 2D game (Unity 3D) and i'm having problems with element positioning.
This are my elements in hierarchy. "Camera Container" it's a GameObject, ...
3
votes
2
answers
1k
views
How to make a sprite blink with Libgdx?
I want to make a sprite blinking like this:
...
1
vote
1
answer
94
views
Why is my sprite moving 90 degrees to the right?
I have a sprite which i'm trying to move towards the top of the screen with the left and right buttons adjusting the heading.
However when my heading = 0; my ...
0
votes
1
answer
1k
views
Getting the current 'Forward' direction Vector values into code and how to use them?
Im having some trouble visualising how the maths works for this particular problem. Back when i coded in 2d only this was often a stumbling point for mine even when only dealing with an x and y axis.
...
1
vote
2
answers
861
views
Why doesn't games use CORDIC for sin and cos?
If the game devs add CORDIC sin cos calculation to their games, their games will have much better FPS. Why do they use normal sin cos function (e.g. Math.sin) instead of CORDIC?
1
vote
1
answer
1k
views
Unity Mathf.Atan2 algorithm complexity
using Unity5.5.1f;
using C#;
So I have a circle (2D) divided equally by 16 directions, and I also have a direction V which is different from the other 16.
In order to know which direction is the ...
2
votes
1
answer
211
views
Translating yaw degrees into 2D movement
I've been hitting my head on the wall for a while with this, and I'm almost sure I'm overcomplicating it.
I have a variable for yaw in degrees (and also pitch and roll, but those should be irrelevant)...
3
votes
1
answer
309
views
Math behind drawing one game object relative to another?
Let's say I have a square (a) and I want to draw another square (b) that stays on one corner of the square (a).
Square (a) can rotate and move around the game world, what math would be used to keep ...
1
vote
2
answers
173
views
Dealing with vectors in multiple planes
Say I have my main "screen" plane, where vectors can be represented
I "know"/can represent vector Q, but the only information I know about vector R is relative to Vector Q. An easy way to visualize ...
1
vote
2
answers
2k
views
Find vector tangent to circle through a point
C2 and P1 are known points. Radius of circle C2 is also constant and known. I am trying to find point T to eventually construct line p1-t, which is tangent to circle c2.
I have made an attempt ...
0
votes
1
answer
1k
views
Mapping polar coordinates to cube
I am trying map polar coordinates to points on a cube. I was able to map the front, back, left and right faces of the cube, but I am struggling with the top and bottom. Here is what I have:
...
0
votes
2
answers
3k
views
LibGDX How can I draw a line at a specific angle
I'm working on a 2D platformer, shooter game and I'm attempting to draw a line to serve as a guide to indicate where the player is shooting. The line should be drawn from the player's sprite to the ...
1
vote
1
answer
152
views
How to plot angles from the pawn's facing direction on a radar UI?
I am doodling on the Flying game template on UE4. I am making a 2D radar on top left. The radar's north direction is the pawn's forward direction. So when it approaches to an object with the dot ...
0
votes
1
answer
55
views
Coordinates of the corners of a rectangle bridging two circles
I am implementing a game that involves slingshots and circular objects. I have gotten the basic "geometric" construction down for rendering the slingshot, but I am having trouble implementing this in ...
0
votes
2
answers
94
views
How to work out the height of a point on a tilted surface?
I have a plane which gets tilted on the X and Z axis (y+ is the normal).
Given an X and Z coordinate and the X and Z rotation of the plane, how do I find out the height (Y) at that point?
I assume ...
1
vote
1
answer
11k
views
Unity 3D - Rotate (smoothly) towards a target
I wanted to know if there is a method on which I can rotate an object with an angle given (a float to be precise), I use trigonometry to calculate the angle between the two objects in a (x, z) plane ...
2
votes
3
answers
1k
views
Calculate target angle to a certain Vector
I'm developing a 3D game in LWJGL.
I have a player class and a monster class and I need the monster class to chase the player when the player is within a certain distance.
For that I have the monster ...
0
votes
1
answer
75
views
Rotating vector based on the position of another vector? [duplicate]
Sorry for terrible picture but lets say we have a unit vector A and we have vectors B and C. So for vector B I would want to rotate in a positive direction because the vector is "above A" and for ...
0
votes
1
answer
29
views
Increasing mass in ineleastic collision by orders of magnitude resultsin little change in velocity
When increasing my rocketMass from 10 to 1000 or to a 1000 or bringing my shipMass down to 1, I notice very little increase in how far the ship's final inertia is. I'm expecting that increasing from ...
0
votes
1
answer
407
views
Why doesn't JavaScript's Math.cos function match this vector tutorial?
I'm following this MATHguide lesson on combining vectors and have reached this part:
Next, we need to convert their forces to horizontal and vertical components. Let's use k for Kim's vector and n ...
0
votes
1
answer
87
views
Turning x and y difference between two points into a projectile moving between them at a fixed speed
In a libgdx project of mine, I have two units on a 2d field who want to fire at each other. They both know the x and y distance to each other by subtracting their enemies position from their own:
<...
1
vote
2
answers
105
views
Algorithm for spacing points out among a line
I'm writing an angled tile system, and my implementation is to have a starting height and an ending height inside the tile.
Like so:
The starting and ending height allow me to get the length of the ...
0
votes
0
answers
225
views
Slide along Surface
I'm very bad at Math and trigonometric functions (And I dunno if this questions fits here)
I have a surface normal as a direction vector.I want my character slide along the surface, if the angle of ...
1
vote
1
answer
198
views
Why does this whirlpool simulation not work?
I am trying to create a simple whirlpool simulation, where particles are constantly compelled to move towards a point in a whirlpool like fashion.
To do this I do the following (in sudo code)
...
0
votes
1
answer
185
views
How to avoid 2d enemy using trigonometry?
I'm making a game in Javascript & HTML5.
I have a "bullet" (let's call it so) that needs to reach the enemy (at fixed position) and that need to avoid the enemy's "bullet".
To make the bullet ...
1
vote
1
answer
136
views
Java- Trig based movement
I have been trying to create a smooth movement technique that would allow me to move in all directions, not just the 8 cardinal directions.
I have tried to use this doing trig, and while the ...
0
votes
1
answer
162
views
How to rotate a triangle to look at a point?
Lets say I have a triangle defined by 3 vertices and a center point, how do I rotate the triangle so its normal is looking at a specified point?
9
votes
2
answers
710
views
Guided Missile with Constant Time
I'm building a game with players and missiles.
I want to fire a missile from P1 to P2. The missile should always take exactly five seconds to reach P2. The missile should also track P2. If P2 moves ...
0
votes
1
answer
58
views
How does this point2LineDist() method works?
I was browsing Wolf3D JS port and bump into that method :
...
0
votes
1
answer
736
views
Require maths help calculating deflection angles of quadrants
For each quadrant, I need to find a neat way of calculating the deflection angle for a small circular object striking a circle, as shown in the diagram.
Angles a and b are already known.
Angle a is ...
1
vote
1
answer
977
views
Day/Night - Rotation from a sine wave
I recently found this question on stack exchange with a great answer that showed how to condense game time into a sine wave, where 1 = midday and -1 = midnight
Converting time of day into a smooth ...
3
votes
1
answer
189
views
Super formula on shader
I'm using Shader-toy to experiment and try to learn a bit the shader science.
As exercise I wan to replicate some of the wikipedia math plots. I've started with a Super Formula.
What I want to ...
2
votes
1
answer
3k
views
OpenGL Arc-Ball Camera Yaw Pitch GLM::Rotate
I'm currently working on a small Voxel-Editor Project. In the editor, I plan on using an Arc-Ball camera which rotate around the model. My camera is currently working but in an odd way. I can't seem ...