angle

Inner angle between two lines

落花浮王杯 提交于 2019-11-28 23:33:27
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) * (180.0 / PI); After to know the angle I calculate the following: double angle = abs(theta2 - theta1); The problem or doubt that I have is: sometimes I get the correct angle but sometimes I get the complementary angle (for me outer). How can I know when subtract 180º to know

Calculate angle (clockwise) between two points

妖精的绣舞 提交于 2019-11-28 20:32:24
问题 I have been not using math for a long time and this should be a simple problem to solve. Suppose I have two points A: (1, 0) and B: (1, -1). I want to use a program (Python or whatever programming language) to calculate the clockwise angle between A, origin (0, 0) and B. It will be something like this: angle_clockwise(point1, point2) Note that the order of the parameters matters. Since the angle calculation will be clockwise: If I call angle_clockwise(A, B), it returns 45. If I call angle

How to calculate an angle from points?

↘锁芯ラ 提交于 2019-11-28 18:35:00
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 this value? Christian Mann You want the arctangent: dy = ey - cy dx = ex - cx theta = arctan(dy/dx) theta *= 180/pi // rads to degs Erm, note that the above is obviously not compiling Javascript code. You'll have to look through documentation for the arctangent function. Edit: Using Math.atan2(y,x) will handle all of the special cases and extra logic for

Combine two segments on the same circle if they overlap or intersect

我们两清 提交于 2019-11-28 12:53:14
问题 I am try to combine two segments if they overlap or intersect.My question is similar to this and this. However, what I want is to combine two segments. public class Segment { private readonly double _from; private readonly double _to; public Segment(double from, double to) { _from = Normalize(from); // 0 <= x < 360 _to = Normalize(to); } public bool Inside(double target) { if (_from < _to) return _from <= target && target <= _to; return _from <= target || target <= _to; } } I am trying to

Fastest way to sort vectors by angle without actually computing that angle

ε祈祈猫儿з 提交于 2019-11-28 07:32:27
Many algorithms (e.g. Graham scan ) require points or vectors to be sorted by their angle (perhaps as seen from some other point, i.e. using difference vectors). This order is inherently cyclic, and where this cycle is broken to compute linear values often doesn't matter that much. But the real angle value doesn't matter much either, as long as cyclic order is maintained. So doing an atan2 call for every point might be wasteful. What faster methods are there to compute a value which is strictly monotonic in the angle, the way atan2 is? Such functions apparently have been called “pseudoangle”

Angle Measurer in C#

好久不见. 提交于 2019-11-28 06:49:33
问题 I want to make a tool that can measure angles between two user defined spots on a form. I have no code to do this at the moment, so any code would be appreciated. Thanks UPDATE It needs to be in Degrees and my points are 3 pictureboxes, each with different colours on each of the three points for the angle to be measured. UPDATE This is my new current code: namespace Angle_Measurer_Tool { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int Dotter = 0; private void

Calculate rotations to look at a 3D point?

余生颓废 提交于 2019-11-28 03:52:15
I need to calculate the 2 angles (yaw and pitch) for a 3D object to face an arbitrary 3D point. These rotations are known as "Euler" rotations simply because after the first rotation, (lets say Z, based on the picture below) the Y axis also rotates with the object. This is the code I'm using but its not working fully. When on the ground plane (Y = 0) the object correctly rotates to face the point, but as soon as I move the point upwards in Y, the rotations don't look correct. // x, y, z represent a fractional value between -[1] and [1] // a "unit vector" of the point I need to rotate towards

Rotating an image, and displaying angle of rotation

↘锁芯ラ 提交于 2019-11-28 02:11:18
I am making a virtual speedometer in android. I use the RotateAnimation() to rotate the speedometer needle. Is there any way to get the angular position of the needle during the rotation? That is, if the needle is rotating from 0 to 360 degree, I want to display the needles angle at each point during the period of animation. I use the following code to perform the animation. RotateAnimation rpmNeedleDeflection = new RotateAnimation(-32, 213, (float) 135, needle.getHeight()/2); rpmNeedleDeflection.setDuration(1500); rpmNeedleDeflection.setFillAfter(true); needle.startAnimation

check if two segments on the same circle overlap / intersect

时光总嘲笑我的痴心妄想 提交于 2019-11-28 01:21:26
Given two circle segments of the same circle: A=[a1, a2] and B=[b1, b2], with: a1, a2, b1, b2 values in degree between -inf and +inf a1 <= a2 ; b1 <= b2 a2-a1<=360; b2-b1<=360 How can I find out if these two circle segments overlap? (i.E. if they intersect or touch in at least one point) Examples: A=[ -45°, 45°]; B=[ 10°, 20°] ==> overlap A=[ -45°, 45°]; B=[ 90°, 180°] ==> no overlap A=[ -45°, 45°]; B=[ 180°, 360°] ==> overlap A=[ -405°, -315°]; B=[ 180°, 360°] ==> overlap A=[-3600°, -3601°]; B=[ 3601°, 3602°] ==> overlap (touching counts as overlap) A=[ 3600°, 3601°]; B=[-3601°,-3602°] ==>

Calculating angle between two points - java

早过忘川 提交于 2019-11-27 16:39:00
问题 I need to calculate the angle in degrees between two points, with a fixed point that is connected with the given two points by a line. Here is an image that illustrates what I need: Here is what I have tried so far: public static float GetAngleOfLineBetweenTwoPoints(float x1, float x2, float y1, float y2) { float xDiff = x2 - x1; float yDiff = y2 - y1; return (float) (Math.atan2(yDiff, xDiff) * (180 / Math.PI)); } It's pointless to say that it doesn't provide the correct answer. 回答1: You can