Skip to main content

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
3 votes
6 answers
2k views

How can I rotate a 16-bit signed integer vector?

I am trying to rotate a vector made of two signed 16-bit coordinates (-32768 to 32767). Using a LUT for sin/cos, I can use the standard method for rotating a vector: ...
IanLarson's user avatar
  • 811
0 votes
1 answer
71 views

Variable subdivision creating artifacts

I'm currently implementing a method for subdividing an icosahedron found here that isn't quite working as expected due to the artifacts created (and the way the triangles are oriented) The problem ...
Chillzy's user avatar
  • 47
0 votes
1 answer
44 views

Calculating semicircle points of a scaled CapsuleCollider2D

I have a very simple code that draws the shape of a pre-defined capsule. It handles everything well, except the case when the GameObject to which the ...
Digika's user avatar
  • 1
0 votes
1 answer
40 views

2D orbit an orbiting body without ellipse

I have a monster (boss) that spawns a minion (m1) which orbits the boss. m1 can spawn its own minion (m2) which orbits m1. This creates a situation where m2 is orbiting m1 and m1 is orbiting the boss. ...
gabriel__'s user avatar
0 votes
0 answers
84 views

How do I move a point in a specific direction in 3D Space?

I know how to move a point in a direction in 2D space it's like this: pointX += sin(angle) * movementSpeed; pointY += cos(angle) * movementSpeed; How do I do the ...
Earthmars643's user avatar
0 votes
0 answers
36 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
72 views

Why are my angle calculations not working properly?

I am using this code: ...
Stan's user avatar
  • 3
0 votes
1 answer
48 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
45 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
77 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
102 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
2 votes
1 answer
318 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
222 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
103 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
249 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
65 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
66 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
336 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 ...
Loospie's user avatar
  • 191
0 votes
1 answer
249 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
2k 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
169 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
279 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
97 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,055
1 vote
1 answer
95 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
221 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
105 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
53 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
75 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
104 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
980 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
195 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,317
0 votes
1 answer
66 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
94 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,552
1 vote
1 answer
88 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
95 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
151 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
372 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
  • 103
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
592 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
76 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
104 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
756 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
214 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
711 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
661 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
93 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
587 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