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

1278 questions
152
votes
9 answers

How can I find the difference between two angles?

Given 2 angles in the range -PI -> PI around a coordinate, what is the value of the smallest of the 2 angles between them? Taking into account that the difference between PI and -PI is not 2 PI but zero. Example: Imagine a circle, with 2 lines…
Tom J Nowell
  • 8,415
  • 16
  • 57
  • 88
87
votes
11 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
  • 873
  • 1
  • 7
  • 4
86
votes
9 answers

Direct way of computing clockwise angle between 2 vectors

I want to find out the clockwise angle between 2 vectors(2D, 3D). The clasic 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 angle I need or its complement. Do…
Mircea Ispas
  • 18,498
  • 26
  • 109
  • 202
69
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
  • 150,847
  • 41
  • 308
  • 421
54
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,071
  • 4
  • 40
  • 66
53
votes
3 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,397
  • 10
  • 45
  • 57
50
votes
7 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
  • 882
  • 2
  • 8
  • 18
40
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…
x4000
  • 2,717
  • 3
  • 25
  • 24
39
votes
15 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
  • 393
  • 1
  • 3
  • 4
36
votes
4 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
34
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
  • 47,653
  • 87
  • 281
  • 523
34
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
  • 50,711
  • 81
  • 269
  • 459
33
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
  • 348,637
  • 121
  • 546
  • 611
31
votes
9 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
  • 351
  • 1
  • 4
  • 5
30
votes
5 answers

How to know the angle between two points?

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…
1
2 3
85 86