trigonometry

R: Generate sine wave with variable frequency

巧了我就是萌 提交于 2019-12-24 06:32:07
问题 This might be more of a math question than an R question but here it goes... I'm trying to generate a low frequency oscillator (LFO2) where the frequency is controlled by another low frequency oscillator (LFO1). LFO1 has a frequency of 0.02 Hz while I want LFO2 to have a frequency that oscillates between 0.00 and 0.11 Hz dependent on the output of LFO1. # length in seconds track_length <- 356 upsample <- 10 # upsample the signal # LFO rates (Hz) rate1 <- 0.02 rate2_range <- list(0.00, 0.11) #

Java: Plotting points uniformly on a circle using Graphics2d

浪尽此生 提交于 2019-12-24 05:56:20
问题 I'm trying to draw a number of points on a circle such that each point is the same distance from the next. Eventually I'll be drawing lines between all of the points to make a little drawing. The current hurdle I am dealing with is the points don't come out on the circle uniformly. The way I am figuring the points is, for a given point with angle theta, the X coordinate and Y coordinate are calculated as follows xc = radius * (Math.cos(theta)) + horizontal center yc = radius * (Math.sin(theta

Implementing Table-Lookup-Based Trig Functions

安稳与你 提交于 2019-12-24 03:28:08
问题 For a videogame I'm implementing in my spare time, I've tried implementing my own versions of sinf(), cosf(), and atan2f(), using lookup tables. The intent is to have implementations that are faster, although with less accuracy. My initial implementation is below. The functions work, and return good approximate values. The only problem is that they are slower than calling the standard sinf(), cosf(), and atan2f() functions. So, what am I doing wrong? // Geometry.h includes definitions of PI,

Get angle from matrix

和自甴很熟 提交于 2019-12-24 03:27:19
问题 I know a matrix [x scale, y skew, x skew, y scale, trans x, trans y], and would like to get the angle in degrees. thanks! 回答1: Consider the following matrix | x_sc y_sk 0 | | x_sk y_sc 0 | | x_tr y_tr 1 | with sk indicating skew, sc indicating scale and tr indicating translation. This only represents a pure rotation if all three are true y_sk == -x_sk y_sc == x_sc x_sc * y_sc - x_sk * y_sk == 1 In this case, if theta is the angle of rotation, then theta == arcos(x_sc) This will give you the

uniform generation of points on 3D box

六月ゝ 毕业季﹏ 提交于 2019-12-24 01:55:09
问题 I would like to generate random points on a 3D box defined by its (minx, miny, minz) and (maxx, maxy, maxz) corners. I was thinking of generating a random point inside of the box and then somehow projecting it onto one of the box sides. However, I don't have explicit plane information for the box sides and this seems like it will not produce a uniform distribution of points since if some sides of the box are bigger than others, those sides should have more points generated on them. Any

uniform generation of points on 3D box

偶尔善良 提交于 2019-12-24 01:55:08
问题 I would like to generate random points on a 3D box defined by its (minx, miny, minz) and (maxx, maxy, maxz) corners. I was thinking of generating a random point inside of the box and then somehow projecting it onto one of the box sides. However, I don't have explicit plane information for the box sides and this seems like it will not produce a uniform distribution of points since if some sides of the box are bigger than others, those sides should have more points generated on them. Any

How do i render and detect a line of sight?

坚强是说给别人听的谎言 提交于 2019-12-24 00:56:10
问题 If you look at the top right you'll see on a radar an enemy unit line of sight. I was wondering what is the most efficient or easiest way (little code, fairly accurate. doesnt need to be perfect) to detect if something is in your line of sight? I may or may not need to render it (i likely wont). I dont know the formula nor used any math libs/namespaces in C# -edit- Basically this is a 2d prototype. nothing has to be perfect and it will have movable camera, units and it will only look left

Trigonometric functions in Swift [duplicate]

房东的猫 提交于 2019-12-23 15:45:01
问题 This question already has answers here : Value of sine 180 is coming out as 1.22465e-16 (4 answers) Closed 4 years ago . I'm beginner developer for iOS. I use some online tutorials to learn Swift and now I'm trying to develop my own calculator. There is task to down "sin" and "cos" buttons by my own, which would return sine or cosine function for entered value. Of course, there is sin() and cos() functions in the Swift, but I've found, that it returns values in radians, not degrees. I did

How to get rotated svg text bounds in javascript programmatically

六月ゝ 毕业季﹏ 提交于 2019-12-23 12:23:37
问题 I am rendering SVG image dynamically and created rotated text. If the rotated text is overlap with other text, i need to remove that text. But i can't measure the rotated text to create bounds and check with next label text region. I have created 3 SVG element to explain. SVG-1 Shows the overlapped text. SVG-2 Shows the rotated text with overlapped (Angle-10) SVG-3 Shows the rotated text without overlapping (Angle-50) I will rotate the text to any angle dynamically. If it is overlapped while

Tanimoto coefficient distance measure

北战南征 提交于 2019-12-23 11:39:48
问题 Can two objects have identical cosine and Tanimoto coefficient distance measure, where Tanimoto distance measure, d(x,y) = x.y / (|x|*|x|) + (|y|*|y|)- x*y and cosine measure, d(x,y) = x.y /(|x|* |x|) * (|y| *|y|) 回答1: The Tanimoto similarity coefficient (which is not a true distance measure) is defined by d(x,y) = x.y / ((|x|*|x|) + (|y|*|y|)- x.y) for bit vectors x and y. Now compare that with the cosine similarity coefficent, d(x,y) = x.y / (|x| * |y|) The denominators differ by a x.y term