trigonometry

Assembly code for sin(x) using Taylor expansion

孤街醉人 提交于 2019-12-20 14:07:04
问题 In x86 Linux, how can I implement sin(x) in assembly code using Taylor Expansion ? 回答1: Would this article help you? http://www.coranac.com/2009/07/sines/ It has a couple of algorithms for computing approximate sin(x) values, with both C and assembly versions. Granted, it's ARM assembly, but the gist of it should translate easily to x86 or similar. 回答2: You don't state which CPU architecture so I'm assuming x86. The simplist (and possibly most inefficient) way would be to write the formula in

Assembly code for sin(x) using Taylor expansion

 ̄綄美尐妖づ 提交于 2019-12-20 14:06:53
问题 In x86 Linux, how can I implement sin(x) in assembly code using Taylor Expansion ? 回答1: Would this article help you? http://www.coranac.com/2009/07/sines/ It has a couple of algorithms for computing approximate sin(x) values, with both C and assembly versions. Granted, it's ARM assembly, but the gist of it should translate easily to x86 or similar. 回答2: You don't state which CPU architecture so I'm assuming x86. The simplist (and possibly most inefficient) way would be to write the formula in

rotating a quaternion on 1 axis?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 10:34:35
问题 I have a model rotated by a quaternion. I can only set the rotation, I can't add or subtract from anything. I need to get the value of an axis, and than add an angle to it (maybe a degree or radian?) and than re-add the modified quaternion. How can I do this? (answer on each axis). 回答1: You can multiply two quaternions together to produce a third quaternion that is the result of the two rotations. Note that quaternion multiplication is not commutative, meaning order matters (if you do this in

How to create an “intercept missile” for a game?

对着背影说爱祢 提交于 2019-12-20 08:49:52
问题 I have a game I am working on that has homing missiles in it. At the moment they just turn towards their target, which produces a rather dumb looking result, with all the missiles following the target around. I want to create a more deadly flavour of missile that will aim at the where the target "will be" by the time it gets there and I am getting a bit stuck and confused about how to do it. I am guessing I will need to work out where my target will be at some point in the future (a guess

Custom math functions vs. supplied Math functions?

和自甴很熟 提交于 2019-12-20 05:56:17
问题 I am basically making a Java program that will have to run a lot of calculations pretty quickly(each frame, aiming for at least 30 f/s). These will mostly be trigonometric and power functions. The question I'm asking is: Which is faster: using the already-supplied-by-Java Math functions? Or writing my own functions to run? 回答1: The built-in Math functions will be extremely difficult to beat, given that most of them have special JVM magic that makes them use hardware intrinsics. You could

R: Strange trig function behavior

梦想的初衷 提交于 2019-12-20 01:09:04
问题 As a Matlab user transitioning to R, I have ran across the problem of applying trigonometric functions to degrees. In Matlab there are trig functions for both radians and degrees (e.g. cos and cosd, respectively). R seems to only include functions for radians, thus requiring me to create my own (see below) cosd<-function(degrees) { radians<-cos(degrees*pi/180) return(radians) } Unfortunately this function does not work properly all of the time. Some results are shown below. > cosd(90) [1] 6

Java Math.cos() Method Does Not Return 0 When Expected

拟墨画扇 提交于 2019-12-19 16:55:15
问题 Using Java on a Windows 7 PC (not sure if that matters) and calling Math.cos() on values that should return 0 (like pi/2) instead returns small values, but small values that, unless I'm misunderstanding, are much greater than 1 ulp off from zero. Math.cos(Math.PI/2) = 6.123233995736766E-17 Math.ulp(Math.cos(Math.PI/2)) = 1.232595164407831E-32 Is this in fact within 1 ulp and I'm simply confused? And would this be an acceptable wrapper method to resolve this minor inaccuracy? public static

How to calculate the area under each end of a sine curve

南楼画角 提交于 2019-12-19 10:44:14
问题 Given this data set: y<-c(-13,16,35,40,28,36,43,33,40,33,22,-5,-27,-31,-29,-25,-26,-31,-26,-24,-25,-29,-23,4) t<-1:24 My goal is to calculate two areas. The first area would integrate only data from the first part of the curve found above the Zero line. The second area would integrate data from the second part of the curve found below the zero line. First I would like to fit a sine wave to this data. Using this excellent answer: https://stats.stackexchange.com/questions/60994/fit-a-sinusoidal

Javascript: Find point on perpendicular line always the same distance away

自古美人都是妖i 提交于 2019-12-19 10:05:34
问题 I'm trying to find a point that is equal distance away from the middle of a perpendicular line. I want to use this point to create a Bézier curve using the start and end points, and this other point I'm trying to find. I've calculated the perpendicular line, and I can plot points on that line, but the problem is that depending on the angle of the line, the points get further away or closer to the original line, and I want to be able to calculate it so it's always X units away. Take a look at

Android get normalized acceleration

爱⌒轻易说出口 提交于 2019-12-19 06:50:09
问题 I wish to get the acceleration vector of an Android phone. The problem is, the accelerometer coordinates are relative to the phone's rotation. What I want is the "absolute" acceleration, i.e., it should return the same values whichever way the phone is facing. (I want to detect if a user that is skiing is sliding down a slope without using GPS. I also need to be able to differentiate sliding and going up the chairlift.) I can probably get those values by combining the accelerometer with the