angle

Find if an angle is within X degrees from another

I need an algorithm to figure out if one angle is within a certain amount of degrees from another angle. My first thought was (a-x < b) && (a+x > b), but it fails when it has to work with angles that wrap around from -179 to 180. In the diagram above, the region (green) that the angle must be between wraps between the negative and po...

Comparing cross point between 2 images in MATLAB

Hello, I took 2 images with a cross point and now I'm trying to compare these 2 images and find out what is the distance and angle moved. How can I use MATLAB to do this? Thank you very much! ...

How do I display an arrow positioned at a specific angle in MATLAB?

I am working in MATLAB and I'm stuck on a very simple problem: I've got an object defined by its position (x,y) and theta (an angle, in degrees). I would like to plot the point and add an arrow, starting from the point and pointing toward the direction defined by the angle. It actually doesn't even have to be an arrow, anything graphical...

Get the slope from one point and an angle in degrees.

In javascript, I am trying to draw a line that is at an angle that is user defined. Basically, I have a point (x,y) and an angle to create the next point at. The length of the line need to be 10px. Let's say that the point to start with is (180, 200)... if I give it angle "A" and the (I guess)hypotenuse is 10, what would my equation(s...

The smallest difference between 2 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 ...

how can we get x-y-z parameters from webcam via matlab?

Hi There, I am using web-camera to capture real-time image via matlab, and succeeded to preview the video using simple videoinput, getsnapshot, and preview functions. To be honest, I am not really satisfied with the result though, because the view-angle is still too wide and I can not set the position of my webcam manually, means I ca...

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 radians. Mathematically, radians are more elegant than degrees in every respect. They also have practical a...

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 that can tell me the minimum angle to rotate from a to b. A positive sign indicates a ...

Flipping an angle using radians

Hello all you math whizzes out there! I am struggling with a math problem I am hoping you can help me with. I have calculated an angle of direction using radians. Within OpenGL ES I move my guy by changing my point value as such: spriteLocation.x -= playerSpeed * cosf(playerRadAngle); spriteLocation.y -= playerSpeed * sinf(playerRad...

XNA 2D vector angles - what's the correct way to calculate ?

what is in XNA in 2D the standard way vector angles work ? 0 degrees points right, 90 points up, 180 left, 270 down ? What are the 'standard' implementations of float VectortoAngle(Vector2 vec) and Vector2 AngleToVector(float angle) so that VectortoAngle(AngleToVector(PI)) == PI ? ...

Finding the angle of a fleeing dodo.

I'm coding some critter AI for a game i am working on for my Unity 3D project. I have no programming background and have been stumbling through this using tutorials and other peoples scripts. My problem is that i want my critter to run directly away from the player when the player kicks it. I need the dodo to run directly away from the...

How to detect if device is headed towards a specific point direction

Hi, I have my current location from CLLocation, and I have another location- also an CLLocation. I would like to detect when my device is heading towards that other location. (I can calculate the distance in meters between this points- but can't workout the calculation of an accurate angle to compare with the device current headin...

How do you calculate the reflex angle given to vectors in 3D space?

I want to calculate the angle between two vectors a and b. Lets assume these are at the origin. This can be done with theta = arccos(a . b / |a| * |b|) However arccos gives you the angle in [0, pi], i.e. it will never give you an angle greater than 180 degrees, which is what I want. So how do you find out when the vectors have gone pa...

How can I handle weird errors from calculating acos / sin / atan2?

Has anyone seen this weird value while handling sin / cos/ tan / acos.. math stuff? ===THE WEIRD VALUE=== -1.#IND00 ===================== void inverse_pos(double x, double y, double& theta_one, double& theta_two) { // Assume that L1 = 350 and L2 = 250 double B = sqrt(x*x + y*y); double angle_beta = atan2(y, x); dou...

Calculate direction angle from two vectors?

Hi, Say I have two 2D vectors, one for an objects current position and one for that objects previous position. How can I work out the direction of travel? This image might help understand what I'm after: Thanks -James ...

Interview Q: 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 is. Solution in any language is welcome (but do explain it a bit if you think it's nece...

Angles between two n-dimensional vectors in Python

In 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]. Can anybody help me? Thanks in advance! ...

Inner angle between two lines

Hi folks, I have two lines: Line1 and Line2. Each line is defined by two points (P1L1(x1, y1), P2L1(x2, y2) and P1L1(x1, y1), P2L3(x2, y3)). I want to know the inner angle defined by these two lines. For do it I calculate the angle of each line with the abscissa: double theta1 = atan(m1) * (180.0 / PI); double theta2 = atan(m2) * (18...

Is there a ready-made formula to get Pitch/Roll values from iPhone 3GS's Accelerometer's X/Y/Z?

Just started to realize an augmented reality based project, got GPS location, heading, and the two missing variable to manipulate virtual camera is Pitch/Roll. I'm wondering if there is a ready-made formula I can merge into the project. Could spare me a lot of time. Thanks in advance. ...

Math Problem: Getting Coordinates From Position And Angle

let me begin by stating that's i'm dreadful at math. i'm attempting to reposition and rotate a rectangle. however, i need to rotate the rectangle from a point that is not 0,0 but according to how far its coordinates has shifted. i'm sure that doesn't make much sense, so i've made some sketches to help explain what i need. the image...