# Questions tagged [trigonometry]

A branch of mathematics that studies triangles and the relationships between their sides and the angles between these sides.

109 questions
Filter by
Sorted by
Tagged with
120 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 ...
31 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 ...
72 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 }
9k views

### How to detect if object is moving in clockwise- or counterclockwise direction?

I've read this one, but I need more info: rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise? I have a ball. The user is able to drag the ball in any ...
25 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 ...
23 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 ...
7 views

### How to convert from one coordinate on a 2D screen, to the same position but mapped to a scaled, translated, and rotated 2D screen

I have two overlapping items. Item 1 is where the input coordinate occurs, Item 2 is scaled translated and rotated. I want to get the coordinate directly underneath the input using Item 2's x-y axes. ...
854 views

### getting direction of x and y… north,south,east,west

I have a player in the center of the screen, where I also have my mouse position origin. (0,0) I would like to know the direction of the mouse, imagine splitting the screen with a X, so the top ...
61 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, ...
149 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....
123 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. ...
1k views

### How to find the point on a hypotenuse divinging triangle into two right triangles?

Consider the following image: Knowing the (x,y) coordinates of A, B, and C; how would one find the point D? D being the point where line CD cuts the triangle into two smaller right triangles? I feel ...
71 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 ...
60 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 ...
41 views

I am trying to give an object a velocity spread (e.g. shotgun bullets or particle effect). ...
83 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 ...
865 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 ...
117 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: ...
50 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: ...
33 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, ...
51 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 ...
102 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 ...
28 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 ...
175 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— ...
28 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 ...
349 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; ...
163 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 ...
93 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?
42 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 ...
655 views

### How to make a sprite blink with Libgdx?

I want to make a sprite blinking like this: ...
45 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 ...
199 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. ...
940 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 ...
83 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 ...
65 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 ...
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: ...
124 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 ...
422 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, ...
85 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 ...
377 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. ...
443 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?
500 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 ...
11k views

### How to calculate a direction vector for camera?

I have a vector that describes change in movement, and I have a 3d-vector, m_rot, that describes a rotation given to an object. I want to calculate a direction vector using both this data. How to ...
78 views

### Rotation of rectangles offsets render position

I have an unknown number "Bricks" that must follow a straight, but not always level, path. Each brick is rotated around one central point properly to form a shape of intersecting paths. My problem ...
150 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)...
622 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: ...
2k 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 ...
50 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 ...