angle

Converting from Cartesian to Spherical matlab?

允我心安 提交于 2019-12-08 12:20:44
问题 I'm getting confused with the variety of names for angles in Spherical Coordinates. According to Matlab documentation that "azimuth and elevation are angular displacements in radians. azimuth is the counterclockwise angle in the x-y plane measured from the positive x-axis. elevation is the elevation angle from the x-y plane. r is the distance from the origin to a point." Ok, I will call azimuth angle as Theta and elevation angle as Phi. Now, I want to build a function that convert Cartesian

How to calculate a point on a rotated axis?

天涯浪子 提交于 2019-12-08 12:00:17
问题 How can I calculate a point (X,Y) a specified distance away, on a rotated axis? I know what angle I'd like the point "moving" along (in degrees). 回答1: x = cos(a) * d y = sin(a) * d where a is the angle and d is the distance. If the trigonometry functions takes radians intead of degrees, you have to convert the angle by dividing by 180/pi. 回答2: Convert to polar coordinates and then rotate the point through the angle you want: x = r * cos( theta ); y = r * sin( theta ); Note: theta in radians (

Android: Determining the angle of tilt using only accelerometers

ぃ、小莉子 提交于 2019-12-08 11:22:49
问题 I am trying to compute the angle of a leg instantaneously regarding an initial position using accelerometer readings. As I approached this, I decided I needed to record an averaged gravity vector and compute some angle between my current reading and that. Theoretically it seems plausible: the reading of gravity is different on each position of the leg, so in stationary positions the readings should converge to a vector I can use to find the angular displacement of the leg, with respect to the

Swift-Making an SKNode simply “move forward” on an angle

半城伤御伤魂 提交于 2019-12-08 08:16:49
问题 I've already asked this question in a different way here; Swift-Setting a physics body velocity by angle but the three attempts to answer it were unfortunately not exactly what I'm looking for, although I'm grateful for what they taught me anyway. I decided that I should simply rephrase my question with an example and further explanation instead of perpetuating a discussion via comments. So here it is. Imagine I have an SKNode positioned in the centre of the screen. Let's say this is a ball,

Calculating the angle between three points in android

橙三吉。 提交于 2019-12-08 06:40:25
问题 I have trouble understanding what's wrong with my code. Point A = new Point((int)CENTER_X, (int)CENTER_Y); Point B = new Point((int)me.getX(), (int)me.getY()); Point C = new Point((int)CENTER_X, (int)B.y); double AB; double AC; double BC; AB = Math.sqrt(Math.pow(B.x - A.x, 2) + Math.pow(B.y - A.y, 2)); AC = Math.sqrt(Math.pow(C.x - A.x, 2) + Math.pow(C.y - A.y, 2)); BC = Math.sqrt(Math.pow(C.x - B.x, 2) + Math.pow(C.y - B.y, 2)); degre = (AB * AB - AC * AC - BC * BC) /( 2 * AC * AB); degre =

How to make an object move towards another object in C# XNA

偶尔善良 提交于 2019-12-08 05:13:36
问题 I'm currently trying to make an object move towards another. I have this code so far to try and achieve it. double angleRad = Math.Atan2(mdlPosition.Z+treeTransform.Translation.Z, mdlPosition.X-treeTransform.Translation.X); enemyPos.X += (float)Math.Cos(angleRad) * 0.2f; enemyPos.Z += (float)Math.Sin(angleRad) * 0.2f; Whenever I move my player character, the object moves, but not towards the characters current position. How can I direct it towards current position? 回答1: Normally you should

3D Vector (X, Y, Z) look at Vector

删除回忆录丶 提交于 2019-12-08 03:06:08
问题 Im working with the source sdk (Which uses c++) and I want to rotate a entity's angle so it looks at another entity. A entity can be looked at as a gameobject or similar and has a position (Vector) in the world as well as a angle (Vector). I can rotate the entity by using SetAbsAngles which takes a QAngle (Basically a Vector) as parameter. 回答1: Here is some pseudo-code: vec3 p = entity2->getPosition(); vec3 r = entity1->getPosition(); float xdistance = p[0] - r[0]; float ydistance = p[1] - r

Unity - Clamp Rotation between arbitrary angles

微笑、不失礼 提交于 2019-12-08 01:35:11
问题 I have a task where I have to clamp an angle between other two angle. The catch is that the limits can be >360 or <0 (ex. [-45,45] or [275,45]). Is there a clean way to do this taking into account all the special cases? (ex. range [-45,45] and input angle of 225 should be -45). Thanks in advance! P.S. I am using unity, so I have all the default Quaternion methods at hand. Current Code: Quaternion inputAngle = Quaternion.identity; if (Character.IsFacingRight) inputAngle = Quaternion

Rotating an image in all browsers (canvas in IE?)

纵饮孤独 提交于 2019-12-07 18:25:50
问题 I finally got to work with canvas only to find out that it is not implemented in IE. I tried explore canvas from google to use it in Internet Explorer, but it's not working for my code (http://uptowar.com/test.php - little bug though that it is not removing the old image when rotating). So, is there an other way to smoothly rotate an image around it's bottom center angle? Maybe javascript? Or is there a way to do it with IE and canvas anyway? Edit: Google Chrome also seems to add an ugly

Android: axes vectors from orientation/rotational angles?

心已入冬 提交于 2019-12-07 16:48:37
问题 So there's a couple methods in the Android SensorManager to get your phone's orientation: float[] rotational = new float[9]; float[] orientation = new float[3]; SensorManager.getRotationMatrix(rotational, whatever, whatever, whatever); SensorManager.getOrientation(rotational, orientation); This gives you a rotation matrix called "rotational" and an array of 3 orientation angles called "orientation". However, I can't use the angles in my AR program - what I need is the actual vectors which