angle

Calculate direction angle from two vectors?

你说的曾经没有我的故事 提交于 2019-12-03 07:28:01
问题 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 angular direction of travel? This image might help understand what I'm after: (image) http://files.me.com/james.ingham/crcvmy 回答1: The direction vector of travel will be the difference of the two position vectors, d = (x1, y1) - (x, y) = (x1 - x, y1 - y) Now when you ask for the direction angle, that depends what direction you want to measure the angle against. Is

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

有些话、适合烂在心里 提交于 2019-12-03 06:05:02
问题 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 ? 回答1: 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

Rotate marker based on driving direction

ぃ、小莉子 提交于 2019-12-03 05:56:48
I have a marker in my Google Maps map that looks like this: When the user is driving, I want to rotate it based on his driving direction. How can I achieve this? I should probably use previous location and current location coords for calculation, but I have no idea how. If you use GPS for locating the user then the Location object you get in onLocationChanged contains the bearing . If you only have the two coordinates (e.g. you only have coordinates from network location provider), you can use Location.bearingTo() to calculate the bearing of two coordinates: Location prevLoc = ... ; Location

Why does OpenGL use degrees instead of radians?

爱⌒轻易说出口 提交于 2019-12-03 05:23:56
问题 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,

3D skew transformation matrix along one coordinate axis

倖福魔咒の 提交于 2019-12-03 03:29:26
Is there a way to calculate the skew transformation matrix along one coordinate axis, given the skew angle, as follows This should work for the most part for skewing an object with a transformation matrix, in particular using glMultMatrix(matrix) matrix1[] = { 1, 0, 0, 0, tan(a), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; matrix2[] = { 1, 0, 0, 0, 0, 1, 0, 0, tan(a), 0, 1, 0, 0, 0, 0, 1 }; matrix3[] = { 1, tan(a), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; matrix4[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, tan(a), 1, 0, 0, 0, 0, 1 }; matrix5[] = { 1, 0, tan(a), 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; matrix6[

get tilt angle Android

天大地大妈咪最大 提交于 2019-12-03 03:05:39
I'm trying to get the tilt angle, roll angle from my sensors from my android phone but with no success so far, when I click on my button which should give me the 3 angles, I get "results: 0.0 -0.0 -0.0" package com.example; import android.app.Activity; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.TextView; import android.widget.Button; import android.view.View; public class MyActivity extends Activity { /** Called when the activity is first

OpenCV RotatedRect with specified angle

喜欢而已 提交于 2019-12-03 01:35:45
I have the situation that I have a small binary image that has one shape, around which I want to find the best fitting rotated rectangle ( not bounding rectangle). I know that there is cv::minAreaRect() that you apply on the result found by cv::findContours() , but this has delivered poor results in my case, because the data is noisy (coming from MS Kinect, see example picture where rotation changes due to the input data (contour) being slightly different). What I did instead was to calculate the principal axis using PCA on my binary image (which is less sensitive to noise), which yields angle

Programming a smooth change of thrust from current velocity vector to a target vector

ε祈祈猫儿з 提交于 2019-12-03 00:29:42
TL;dr: "I am not sure how to calculate a smooth transition of thrust between one vector and another." I am programming a simple game where an enemy chases after the player in an open space (no walls). I was calculating the enemy's x & y velocities independently, accelerating them if they were taking them in the direction of the player and quickly slowing them if they were going the wrong way (e.g. EnemyVelocity.x > 0 & player.x < enemy.x, then EnemyVelocity.x - 2.) While the gameplay is decently fun trying to dodge the enemy, it is my desire to have the enemy behave using proper physics. What

Periodic Data with Machine Learning (Like Degree Angles -> 179 is 2 different from -179)

£可爱£侵袭症+ 提交于 2019-12-02 21:11:45
I'm using Python for kernel density estimations and gaussian mixture models to rank likelihood of samples of multidimensional data. Every piece of data is an angle, and I'm not sure how to handle the periodicity of angular data for machine learning. First I removed all negative angles by adding 360 to them, so all angles that were negative became positive, -179 becoming 181. I believe this elegantly handles the case of -179 an similar being not significantly different than 179 and similar, but it does not handle instances like 359 being not dissimilar from 1. One way I've thought of

Calculate direction angle from two vectors?

[亡魂溺海] 提交于 2019-12-02 20:58:59
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 angular direction of travel? This image might help understand what I'm after: (image) http://files.me.com/james.ingham/crcvmy The direction vector of travel will be the difference of the two position vectors, d = (x1, y1) - (x, y) = (x1 - x, y1 - y) Now when you ask for the direction angle, that depends what direction you want to measure the angle against. Is it against the x axis? Go with Radu's answer. Against an arbitrary vector? See justjeff's answer. Edit: To