angle

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

放肆的年华 提交于 2019-12-02 19:31:35
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 ? To answer your first question, 0 degrees points up, 90 degrees points right, 180 degrees points down, and 270 degrees points left. Here is a simple 2D XNA rotation tutorial to give you more information. As for converting vectors to angles and back, I found a couple good implementations here : Vector2 AngleToVector

Why does OpenGL use degrees instead of radians?

冷暖自知 提交于 2019-12-02 18:40:51
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 advantages: The C standard library uses radians. Pretty much any other library out there uses radians as well. Radians are more convenient in some computations, e.g. the length of a circular arc. Why, then, did the OpenGL designers decide to specify functions

Rotating speedometer needle gauge around its center as the speed changes

*爱你&永不变心* 提交于 2019-12-02 09:22:05
Hi all, I have written an application where I have a speedometer with a needle vertically set at 90 degree and I am trying to rotate the needle around its center with the speed that changes for every one second(I am displaying the speed in a text view that changes randomly from 0 to 120) I am getting the speed from a remote service and displaying in a textview. so as the speed changes the speedometer needle gauge should change accordingly around its center. I mean If speed is 30 the needle should be at 30 and so on in speedometer. My code is not working exactly, How to get around this problem?

How to find out if the angle between two vectors is external or internal?

旧街凉风 提交于 2019-12-02 05:00:51
问题 I know how to find out angle between 2 vectors, but it always gives me internal angle, but I want it to give me always the angle in anticlockwise direction, even if it is greater then 180. I'm using C++ but it is not really important because I need to get the theory. This is what I am using now 回答1: You're looking for the atan2(y,x) function (http://en.wikipedia.org/wiki/Atan2). If you give it the two components of a 2D vector, it will give you the angle of the vector from the x axis, in the

Marshalling “EGLRenderResolutionScaleProperty” to ANGLE from C# using P/Invoke

天大地大妈咪最大 提交于 2019-12-02 04:22:15
I am trying to get ANGLE working in C# using P/Invoke. Basically, I am creating a simple 2D surface, and then passing that off to skia (using SkiaSharp). Everything is working and all that, but I am having a problem marshalling PropertySet to the unmanaged code. This bit works fine: // the properties var props = new PropertySet(); props.Add("EGLNativeWindowTypeProperty", swapChainPanel); // the surface attributes int[] surfaceAttrs = { EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, EGL_NONE }; // create the surface surface = eglCreateWindowSurface(eglDisplay, eglConfig, props, surfaceAttrs

How to find out if the angle between two vectors is external or internal?

隐身守侯 提交于 2019-12-01 22:46:13
I know how to find out angle between 2 vectors, but it always gives me internal angle, but I want it to give me always the angle in anticlockwise direction, even if it is greater then 180. I'm using C++ but it is not really important because I need to get the theory. This is what I am using now You're looking for the atan2(y,x) function ( http://en.wikipedia.org/wiki/Atan2 ). If you give it the two components of a 2D vector, it will give you the angle of the vector from the x axis, in the counter-clockwise direction. To solve your specific problem try: atan2(v_y, v_x) - atan2(u_y, u_x) Then

Incorrect conversion from quaternions to euler angles and back

僤鯓⒐⒋嵵緔 提交于 2019-12-01 20:45:13
I am converting angles-axis representation to Euler angles. I decided to check and make sure that the Euler angles I got from the conversion would lead back to the original axis-angle. I print out the values, but they do not match! I have read http://forum.onlineconversion.com/showthread.php?t=5408 and http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles as well as similar conversion questions on this website. In the code below I start with angle 'angle' and axis (rx,ry,rz), then I convert it to quaternions (q0,q1,q2,q3). I convert the quaternions to euler angles (roll,

Android SensorManager.getOrientation() returns pitch between -PI/2 and PI/2

大兔子大兔子 提交于 2019-12-01 11:41:30
I am designing an app that needs to check the device's orientation (Azimuth, Pitch and Roll). I use the following code to achieve this: @Override public void onSensorChanged(SensorEvent event) { if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) gravityMatrix = event.values.clone();// Fill gravityMatrix with accelerometer values else if(event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) geomagneticMatrix = event.values.clone();// Fill geomagneticMatrix with magnetic-field sensor values if(gravityMatrix != null && geomagneticMatrix != null){ RMatrix = new float[16]; IMatrix = new float

Can't limit the camera pitch angle between [-90º, 90º] in OpenGL using vectors!

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 11:09:31
I'm having a big problem limiting the camera pitch angle (between -90º and 90º) with the code below. This is somewhat a follow up to this question . The problem, it seems, is that the camera rotates more than -90º or more than +90º and when that happens, I'll be looking down (or up) but but the view just rotated 180º around the Y axis. Example: I'm facing north looking at the horizon and I start to look down until I can't go down anymore (limited by the code below). Then I start to look up and I'll be facing south. void Camera::Rotate(Vector3D angle) { angle = angle * CAMERA_ROTATION_SPEED;

Intersection between two Arcs? (arc = distance between pair of angles)

左心房为你撑大大i 提交于 2019-12-01 10:33:37
I'm trying to find a way to calculate the intersection between two arcs. I need to use this to determine how much of an Arc is visually on the right half of a circle, and how much on the left. I though about creating an arc of the right half, and intersect that with the actual arc. But it takes me wayyy to much time to solve this, so I thought about asking here - someone must have done it before. Edit: I'm sorry the previous illustration was provided when my head was too heavy after crunching angles. I'll try to explain again: In this link you can see that I cut the arc in the middle to two