Questions tagged [trigonometry]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

Compensate bullets direction towards direction player is moving in

My new prototype is a top down shooting game, the player aims with the mouse and fires projectiles towards the mouse position, this works fine, when the player is standing still. When the player moves,...
Mad Hatter's user avatar
0 votes
1 answer
63 views

Why are my angle calculations not working properly?

I am using this code: ...
Stan's user avatar
  • 3
0 votes
1 answer
44 views

Checking if I am looking through a window using angles

I am developing a mod for a game with a Lua api. I am trying to detect if I am looking through from behind a window when I shoot an enemy. For context, when I shoot through this window I apply a ...
Ben R's user avatar
  • 1
0 votes
1 answer
32 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?
Zie's user avatar
  • 1
0 votes
1 answer
39 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: ...
CAOakley's user avatar
  • 101
0 votes
1 answer
77 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 ...
Matthew Carson's user avatar
0 votes
0 answers
65 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? ...
anime username's user avatar
2 votes
1 answer
210 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 ...
maxammann's user avatar
  • 123
1 vote
1 answer
113 views

How to overshoot with direction_to

I've managed to get my sprite enemies shoot at the player with ...
Ghoul Fool's user avatar
0 votes
0 answers
87 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. ...
atg's user avatar
  • 1
0 votes
1 answer
179 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 ...
user21746705's user avatar
0 votes
0 answers
40 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 ...
Jordan Kohler's user avatar
0 votes
1 answer
53 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 ...
Literal Garbage's user avatar
0 votes
2 answers
198 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 ...
Lake's user avatar
  • 191
0 votes
1 answer
223 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 ...
lightimpact90's user avatar
0 votes
1 answer
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 ...
GoldSpark's user avatar
3 votes
1 answer
150 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 ...
user avatar
0 votes
1 answer
2k 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 ...
Sawb's user avatar
  • 3
0 votes
2 answers
192 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 ...
RikuTokyoRide's user avatar
0 votes
1 answer
80 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 : ...
MaT's user avatar
  • 1,045
1 vote
1 answer
85 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 ...
Kapparino's user avatar
  • 115
0 votes
0 answers
208 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). ...
Zong's user avatar
  • 1
0 votes
1 answer
101 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 ...
random person's user avatar
0 votes
1 answer
63 views

Needs help on actually making the trigonometric function work as intended

...
random person's user avatar
-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 ...
random person's user avatar
1 vote
1 answer
70 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 ...
RhinoPak's user avatar
1 vote
1 answer
99 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 ...
pawx95's user avatar
  • 13
0 votes
1 answer
806 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 ...
Salem's user avatar
  • 226
0 votes
0 answers
184 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 ...
DyingIsFun's user avatar
  • 1,307
0 votes
1 answer
61 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?
divinci's user avatar
  • 101
1 vote
0 answers
87 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 ...
Jacob's user avatar
  • 2,532
1 vote
1 answer
81 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 ...
Justiniscoding's user avatar
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 ...
devendran's user avatar
0 votes
0 answers
88 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 ...
Serket's user avatar
  • 101
2 votes
1 answer
134 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 ...
fguillen's user avatar
  • 243
0 votes
2 answers
344 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 ...
Marwi's user avatar
  • 3
4 votes
1 answer
1k 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 ...
venom007's user avatar
0 votes
1 answer
549 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 ...
Steffan's user avatar
  • 103
1 vote
0 answers
70 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 ...
Blixkreeg's user avatar
0 votes
1 answer
95 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 ...
runs's user avatar
  • 1
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
0 answers
193 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, ...
Eric's user avatar
  • 123
3 votes
2 answers
619 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....
Yuzu's user avatar
  • 31
1 vote
1 answer
630 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. ...
tay10r's user avatar
  • 133
2 votes
1 answer
91 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 ...
SmugLispWeenie's user avatar
-1 votes
2 answers
507 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 ...
Chrissisbeast's user avatar
0 votes
0 answers
75 views

Adding spread to velocity Vector3D

I am trying to give an object a velocity spread (e.g. shotgun bullets or particle effect). ...
codecustard's user avatar
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 ...
Coco DaWhiteBerry's user avatar
1 vote
1 answer
74 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: ...
kishikaisei's user avatar
0 votes
0 answers
75 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, ...
mezox's user avatar
  • 1