angle

Calculate rotations to look at a 3D point?

前提是你 提交于 2019-11-27 00:12:21
问题 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

Rotating an image, and displaying angle of rotation

此生再无相见时 提交于 2019-11-26 22:09:06
问题 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);

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

南楼画角 提交于 2019-11-26 22:06:50
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 distance and angle from a center point. My current code: Point centerPoint = new Point ( 0, 0 ); Point result = new Point ( 0, 0 ); double angle = 0.5; //between 0 and 2 * PI, angle is in radians int distance = 1000; result.Y = centerPoint.Y + (int)Math.Round( distance * Math.Sin( angle ) ); result.X = centerPoint.X + (int)Math.Round( distance * Math.Cos(

check if two segments on the same circle overlap / intersect

牧云@^-^@ 提交于 2019-11-26 21:53:45
问题 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°];

Direct way of computing clockwise angle between 2 vectors

别等时光非礼了梦想. 提交于 2019-11-26 21:26:05
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 you know a direct way of computing clockwise angle? 2D case Just like the dot product is proportional to the cosine of the angle, the determinant is proprortional to its sine. So you can compute the angle like this: dot = x1*x2 + y1*y2 # dot product between [x1, y1] and [x2, y2] det = x1*y2 - y1*x2 # determinant angle = atan2(det, dot) # atan2(y, x)

The smallest difference between 2 Angles

放肆的年华 提交于 2019-11-26 21:21:23
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 coming out from the center, there are 2 angles between those lines, the angle they make on the inside aka the smaller angle , and the angle they make on the outside, aka the bigger angle. Both angles when added up make a full circle. Given that each angle can fit within a certain range, what is the smaller angles value, taking into account the rollover

Convert DD (decimal degrees) to DMS (degrees minutes seconds) in Python?

浪子不回头ぞ 提交于 2019-11-26 20:56:07
问题 How do you convert Decimal Degrees to Degrees Minutes Seconds In Python? Is there a Formula already written? 回答1: This is exactly what divmod was invented for: >>> def decdeg2dms(dd): ... mnt,sec = divmod(dd*3600,60) ... deg,mnt = divmod(mnt,60) ... return deg,mnt,sec >>> dd = 45 + 30.0/60 + 1.0/3600 >>> print dd 45.5002777778 >>> decdeg2dms(dd) (45.0, 30.0, 1.0) 回答2: Here is my updated version based upon Paul McGuire's. This one should handle negatives correctly. def decdeg2dms(dd): is

Finding Signed Angle Between Vectors

拈花ヽ惹草 提交于 2019-11-26 20:09:09
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 rotation from +x-axis towards +y-axis. Conversely, a negative sign indicates a rotation from +x-axis towards -y-axis. assert angle((1,0),(0,1)) == pi/2. assert angle((0,1),(1,0)) == -pi/2. If you have an atan2() function in your math library of choice: signed

Rotating Image on A canvas in android

旧街凉风 提交于 2019-11-26 19:46:51
I want to Rotate Image according to a specific angle in android ,some thing like a compass... I have this code...it works on drawPath() but i want to replace the path and the Drawing thing with image.. I tried to create a bitmap image ,DrawBitmapImage , but the image does not Rotate like the path..Any Help PLease? public void draw(Canvas canvas) { double angle = calculateAngle(currentLongitude, currentLatitude, targetLongitude, targetLatitude); //Correction; angle-=90; //Correction for azimuth angle-=azimuth; if((getContext() instanceof Activity) && ((Activity)getContext()).getWindowManager()

Angles between two n-dimensional vectors in Python

喜欢而已 提交于 2019-11-26 17:19:23
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] . Alex Martelli import math def dotproduct(v1, v2): return sum((a*b) for a, b in zip(v1, v2)) def length(v): return math.sqrt(dotproduct(v, v)) def angle(v1, v2): return math.acos(dotproduct(v1, v2) / (length(v1) * length(v2))) Note : this will fail when the vectors have either the same or the opposite direction. The correct implementation is here: https://stackoverflow.com/a/13849249/71522 Note : all of the other answers here will