Questions tagged [trigonometry]

Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between sides

Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between sides. Trigonometry defines the trigonometric functions, which describe those relationships and have applicability to cyclical phenomena, such as waves.

Trigonometry can be implemented into many programming languages, such as python. Trigonometry can be used to find an angle in a triangle using the side lengths etc.

References:

3369 questions
10
votes
4 answers

JavaScript Cosine similarity function

I am trying to create a cosine similarity function and then display the results in a HTML element. I have written the following: function cosinesim(A,B){ var dotproduct=0; var mA=0; var mB=0; for(i = 0; i <…
Future
  • 191
  • 2
  • 13
10
votes
4 answers

Find Inverse Tangent?

I'm new to Javascript and I'm trying to use inverse tangent to find the angle in degrees between a line and the x axis on an elevated y. I don't see any command for it so I really need some help.
PLP123
  • 307
  • 2
  • 3
  • 11
10
votes
0 answers

Vectorization of sin and cos

I was playing around with Compiler Explorer and ran into an anomaly (I think). If I want to make the compiler vectorize a sin calculation using libmvec, I would write: #include #define NN 512 typedef float T; typedef T…
Avi Ginsburg
  • 10,323
  • 3
  • 29
  • 56
10
votes
4 answers

Given two diagonally opposite points on a rectangle, how to calculate the other two points

I'm trying to re-size a div element while dragging from top right or bottom left corners. In order to calculate the new width and height, i need to know the other two points on the rectangle how can I get this values given only two point and the…
Roey Zada
  • 663
  • 10
  • 30
10
votes
1 answer

Line Segment and Circle Intersection

I have a Line Segment (x1, y1, x2, y2) intersecting a circle of radius r. How can I determine which intersection point is closest to (x1, y1)?
Vali Rosca
  • 479
  • 2
  • 4
  • 18
10
votes
2 answers

How can I draw a circle in a data array/map in python

I have an array that will be 100 * 100, I can access any point like map[x][y] It kinda will look like this: for i in map: for ii in i: print ii, print '\n', output: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .…
p99will
  • 250
  • 2
  • 3
  • 14
10
votes
4 answers

Convert atan2 value to standard 360-degree-system value

Lets say I'm using atan2 to get the angle between two vectors. atan2 gives a value in radians. I convert it to degrees using a built in function in Java. This gives me a value between 0 and 180 degrees or between 0 and -180 (the nature of atan2). Is…
user3150201
  • 1,901
  • 5
  • 26
  • 29
10
votes
5 answers

C: Improving performance of function with heavy sin() usage

I have a C function that computes the values of 4 sines based on time elapsed. Using gprof, I figured that this function uses 100% (100.7% to be exact lol) of the CPU time. void update_sines(void) { clock_gettime(CLOCK_MONOTONIC, &spec); s…
ReX357
  • 1,199
  • 3
  • 19
  • 43
10
votes
4 answers

Converting result of Math.sin(x) into a result for degrees in java

I would like to convert the Math.sin(x), where x in radians to a result which will give me as x in degrees not radians. I have used the normal method and java built in method of conversion between degrees and radians, but any argument I pass to the…
Omiye Jay Jay
  • 409
  • 5
  • 10
  • 19
10
votes
5 answers

How to look up sine of different frequencies from a fixed sized lookup table?

I am sampling a sine wave at 48 kHz, the frequency range of my sine wave can vary from 0 to 20000 Hz with a step of about 100 Hz. I am using a lookup table approach. So I generate 4096 samples for a sine wave for 4096 different phases. I think the…
as3rdaccount
  • 3,711
  • 12
  • 42
  • 62
10
votes
2 answers

How to calculate a vector from an angle with another vector in 2D?

I know I should know this, but I just can't figure it out/find the solution. I can do it by hand, but I can't put it in an algorithm... (working in c++, but pseudocode should be fine). I have a vector, and I want to find another vector based on the…
Tessa
  • 297
  • 1
  • 3
  • 10
9
votes
3 answers

Given start point, angles in each rotational axis and a direction, calculate end point

I have a start point in 3D coordinates, e.g. (0,0,0). I have the direction I am pointing, represented by three angles - one for each angle of rotation (rotation in X, rotation in Y, rotation in Z) (for the sake of the example let's assume I'm one of…
Nick Udell
  • 2,420
  • 5
  • 44
  • 83
9
votes
2 answers

Circle to Circle Segment Collision

I'm struggling to find a rock solid solution to detecting collisions between a circle and a circle segment. Imagine a Field of View cone for a game enemy, with the circles representing objects of interest. The diagram at the bottom is something I…
9
votes
2 answers

Why did Apple flip their unit circle for UIBezierPath?

The image on the left is what a typical unit circle looks like. The one on the right is from the documentation. I haven't seen a more in depth explanation for why it was flipped anywhere online. Why is this so?
Yogurt
  • 2,913
  • 2
  • 32
  • 63
9
votes
3 answers

How to calculate (x,y) for a fixed arc length away from a point on a circumference

I've spent so many hours on this I can feel my sanity slowly slipping. So any help would be really truly appreciated. I'll try and be as succinct as possible. I have a circle on a 2D plane. I know the cartesian coordinates for it's central point(C)…
JConway
  • 569
  • 5
  • 13