Questions tagged [angle]

A shape, formed by two lines or rays diverging from a common point (the vertex).

Angle is also used to designate the measure of an angle or of a rotation. This measure is the ratio of the length of a circular arc by its radius. In the case of an angle (figure), the arc is centered at the vertex and delimited by the sides. In the case of a rotation, the arc is centered at the center of the rotation and delimited by any point and its image by the rotation.

Source: mathopenref wikipedia

1421 questions
190
votes
11 answers

How can I find the smallest difference between two angles around a point?

Given a 2D circle with 2 angles in the range -PI -> PI around a coordinate, what is the value of the smallest angle between them? Taking into account that the difference between PI and -PI is not 2 PI but zero. An Example: Imagine a circle, with 2…
Tom J Nowell
  • 9,588
  • 17
  • 63
  • 91
113
votes
15 answers

Angles between two n-dimensional vectors in Python

I need to determine the angle(s) between two n-dimensional vectors in Python. For example, the input can be two lists like the following: [1,2,3,4] and [6,7,8,9].
Peter
  • 1,133
  • 2
  • 8
  • 4
112
votes
10 answers

Direct way of computing the clockwise angle between two vectors

I want to find out the clockwise angle between two vectors (two-dimensional or three-dimensional). The classic way with the dot product gives me the inner angle (0-180 degrees), and I need to use some if statements to determine if the result is the…
Mircea Ispas
  • 20,260
  • 32
  • 123
  • 211
73
votes
5 answers

How to calculate an angle from points?

I want to get a simple solution to calculate the angle of a line (like a pointer of a clock). I have 2 points: cX, cY - the center of the line. eX, eY - the end of the line. The result is angle (0 <= a < 360). Which function is able to provide…
durumdara
  • 3,411
  • 4
  • 43
  • 71
70
votes
5 answers

Why does OpenGL use degrees instead of radians?

The OpenGL designers were never afraid of mathematics, and knowledge of linear algebra is essential for all but the simplest OpenGL applications. I think it can safely be assumed that OpenGL programmers are familiar with angles in…
Thomas
  • 174,939
  • 50
  • 355
  • 478
56
votes
9 answers

Java: Calculating the angle between two points in degrees

I need to calculate the angle in degrees between two points for my own Point class, Point a shall be the center point. Method: public float getAngle(Point target) { return (float) Math.toDegrees(Math.atan2(target.x - x, target.y - y)); } Test…
Aich
  • 962
  • 2
  • 9
  • 19
56
votes
4 answers

Rotate a point by another point in 2D

I want to know how to work out the new co-ordinates for a point when rotated by an angle relative to another point. I have a block arrow and want to rotate it by an angle theta relative to a point in the middle of the base of the arrow. This is…
James
  • 3,597
  • 11
  • 47
  • 57
48
votes
17 answers

Converting wind direction in angles to text words

I have wind direction data coming from a weather vane, and the data is represented in 0 to 359 degrees. I want to convert this into text format (compass rose) with 16 different directions. Basically I want to know if there is a fast slick way to…
zacharoni
  • 483
  • 1
  • 4
  • 4
46
votes
3 answers

Angle from 2D unit vector?

Given unit vector (0.5, 0.5) how could I find the angle (its direction)? Is it cos(x) + sin(y)?
jmasterx
  • 52,639
  • 96
  • 311
  • 557
44
votes
5 answers

MinAreaRect angles - Unsure about the angle returned

From the functions for MinAreaRect, does it return angles in the range of 0-360 degrees? I am unsure as i have an object that is oriented at 90 degrees or so but I keep getting either -1 or -15 degrees. Could this be an openCV error? Any guidance…
user349026
41
votes
6 answers

Calculating point on a circle's circumference from angle in C#?

I imagine that this is a simple question, but I'm getting some strange results with my current code and I don't have the math background to fully understand why. My goal is simple, as stated in the title: I just want to find the point at some…
Chris McElligott Park
  • 3,057
  • 3
  • 27
  • 25
38
votes
7 answers

How to know the angle between two vectors?

I am making small game with pygame and I have made a gun that rotates around its center. My problem is that I want the gun to rotate by itself to the enemy direction, but I couldn't do that because I can't find the angle between the gun and the…
38
votes
2 answers

Finding Signed Angle Between Vectors

How would you find the signed angle theta from vector a to b? And yes, I know that theta = arccos((a.b)/(|a||b|)). However, this does not contain a sign (i.e. it doesn't distinguish between a clockwise or counterclockwise rotation). I need something…
Cerin
  • 60,957
  • 96
  • 316
  • 522
34
votes
10 answers

Find angle between hour and minute hands in an analog clock

I was given this interview question recently: Given a 12-hour analog clock, compute in degree the smaller angle between the hour and minute hands. Be as precise as you can. I'm wondering what's the simplest, most readable, most precise algorithm…
polygenelubricants
  • 376,812
  • 128
  • 561
  • 623
34
votes
10 answers

Normalise orientation between 0 and 360

I'm working on a simple rotate routine which normalizes an objects rotation between 0 and 360 degrees. My C# code seems to be working but I'm not entirely happy with it. Can anyone improve on the code below making it a bit more robust? public void…
JuniorDeveloper
  • 381
  • 1
  • 4
  • 5
1
2 3
94 95