angle

How to find reflection vector when the object doesn't sit on an axis?

泄露秘密 提交于 2020-01-16 19:31:30
问题 How do I calculate the reflection vector to this problem? Using the formula r = v - 2 (v.n)n I can get the reflection when the object is sat on the x or y axis however when using this formula when it isnt seems to give strange results. Any help would be greatly appreciated. Example of the problem 回答1: The normal vector n needs to be normalized. In your example, n should be (1/sqrt(2), 1/sqrt(2)) . 来源: https://stackoverflow.com/questions/58699100/how-to-find-reflection-vector-when-the-object

atan2 - find angle between two points (360deg)

◇◆丶佛笑我妖孽 提交于 2020-01-16 02:05:24
问题 I have a game where there is a Player and some enemies . These enemies, just as the player itself, can shoot bullets . But the angle of bullets don't change as it is supposed to; The newly created bullet is supposed to find the angle between itself and the player, then just go in that direction - this has to be done in 360° . I have followed this answer but I believe that I have done something incorrect. because this is what happens: and this is how it should be: currently it only goes like

ScenKit eulerAngles strange values during rotation

↘锁芯ラ 提交于 2020-01-14 10:22:54
问题 I'm rotating a SCNNode using the following lines: let rotate = SCNAction.rotateByAngle(CGFloat(M_PI), aroundAxis:SCNVector3Make(0, 1, 0), duration: NSTimeInterval(10.0)) let repeat = SCNAction.repeatActionForever(rotate) node.runAction(repeat) and i print the eulerAngles.y of the node in the render method: let rad = Double(node.eulerAngles.y) var angleInDegrees = fmodf(360.0 + -Float(rad) * (180.0 / Float(M_PI)), 360.0) println("eulerAngles.y rad:\(rad) degree:\(angleInDegrees)") but I get

Average of two angles with wrap around [duplicate]

拟墨画扇 提交于 2020-01-14 07:13:35
问题 This question already has answers here : Closed 10 years ago . Possible Duplicate: How do you calculate the average of a set of angles? I have two angles, a=20 degrees and b=350 degrees. The average of those two angles are 185 degrees. However, if we consider that the maximum angle is 360 degrees and allows for wrap around, one could see that 5 degrees is a closer average. I'm having troubles coming up with a good formula to handle that wrap around when calculating average. Anyone got any

Average of two angles with wrap around [duplicate]

 ̄綄美尐妖づ 提交于 2020-01-14 07:11:05
问题 This question already has answers here : Closed 10 years ago . Possible Duplicate: How do you calculate the average of a set of angles? I have two angles, a=20 degrees and b=350 degrees. The average of those two angles are 185 degrees. However, if we consider that the maximum angle is 360 degrees and allows for wrap around, one could see that 5 degrees is a closer average. I'm having troubles coming up with a good formula to handle that wrap around when calculating average. Anyone got any

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

佐手、 提交于 2020-01-11 06:59:08
问题 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

ggplot2: How to rotate a graph in a specific angle?

谁都会走 提交于 2020-01-11 05:47:26
问题 I would like to rotate a ggplot2 graph by a self-specified angle. I found how to rotate the axis text with element_text(angle = 20) . I would like to do something similar with the whole plot. Reproducible example: set.seed(123) data_plot <- data.frame(x = sort(rnorm(1000)), y = sort(rnorm(1000))) ggplot(data_plot, aes(y, x)) + geom_line() # + theme(axis.title.x = element_text(angle = 20)) This graph should be rotated: 回答1: Here's a rough idea, calling your plot p : library(grid) pushViewport

Projections' Angle of Line in Space

柔情痞子 提交于 2020-01-06 23:52:11
问题 Start of line (yellow) and axes are at [xc,yc,zc] End of line is at [xp,yp,zc] . a , b , c are the angles which line makes in space. What I need are the angles which line's projections (black line) create on xy,yz and xz planes. A_y_to_z : Projected line's angle from y axis to z axis on xz plane. A_z_to_x : Angle from z to x axis on zx plane. A_x_to_y : Angle from x to y axis on xy plane. Writing code on Matlab 回答1: You can calculate the projection angle to any plane by: Obtaining the

GvrViewerMain rotates the camera yourself. Unity3D + Google VR

99封情书 提交于 2020-01-03 19:44:05
问题 I have a problem. Using Google VR + Unity. GameObject Camera automatically changes the angle "Y". The device does not change positions. Maybe fluctuations in the hands. The editor is no problem. The device Samsung S6. Pic 0 sec Pic after ~15 sec public void Update() { text.text = cameraTransform.eulerAngles.y.ToString(); } 回答1: Sorry mate but this is a known issue and it's been there since day 1. It's called camera drift. It lives in this beautiful ecosystem of github community where the

Get tilt angle from the android accelerometer

﹥>﹥吖頭↗ 提交于 2020-01-03 08:34:19
问题 I have a class that implements SensorEventListener and I would like to get the tilt Angle of my device using the Accelerometer . I looked for examples on the internet but they use Sensor.TYPE_MAGNETIC_FIELD . I believe my device doesn't have this sensor because when I do the following check manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() , I get zero . Is there a way to get the tilt Angle by just using Sensor.TYPE_ACCELEROMETER values? 回答1: As people suggested you can use the