trigonometry

How does trig work in JavaScript? [closed]

你说的曾经没有我的故事 提交于 2019-12-14 03:36:05
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . I have a value and its cosine as: -0.2567721374914637 Cosine: -0.04253775592822526 Compare what we get in Python: >>> import math >>> math.cos(-0.2567721374914637) 0.9672147629178562 Is there a way I can do trig in JavaScript that isn't out to lunch? Are there any math libraries or anything that

Calculating absolute differences between two angles

泄露秘密 提交于 2019-12-13 13:13:09
问题 I have two angles a and b, I want to calculate the absolute difference between both angles. Examples >> absDiffDeg(360,5) ans = 5 >> absDiffDeg(-5,5) ans = 10 >> absDiffDeg(5,-5) ans = 10 回答1: Normalize the difference, abs operation is not necessary because mod(x,y) takes the sign of y. normDeg = mod(a-b,360); This will be a number between 0-360, but we want the smallest angle which is between 0-180. Easiest way to get this is absDiffDeg = min(360-normDeg, normDeg); 回答2: When doing math with

Get rotation center of rectangle

◇◆丶佛笑我妖孽 提交于 2019-12-13 12:23:04
问题 Given the bounding box, relative rotation center, and rotation angle of a rectangle I need to find the absolute rotation center of the rectangle. Here is an image (I wouldn't mind if someone improved it): I hope that is clear enough. I need the x and y coordinates of the red dot. I've been working on this for some time now and I am lost with my trivial knowledge of trig. :/ 回答1: If the angle of rotation is a shown negative above, then the coordinates of the red dot are: rx = x + rcx*COS(a) -

Sine to radians Objective-C

試著忘記壹切 提交于 2019-12-13 08:56:41
问题 This part of an app that I am working on, I have the following equation in objective C. All variables are floats. r is a sine of an angle and I would like to convert r to radians when diplayed in the text field. r = ns/ni r = sinf(r); rr = asinf(r); textfieldRi.text = [NSString stringwithFormat:@"%.02f", rr]; I am not getting correct results. Any suggestions please? 回答1: I'm not entirely certain what you think you're gaining by executing a sine followed by an inverse sine, except possibly to

Rotate a resized rectangle with SVG and Javascript

一笑奈何 提交于 2019-12-13 07:11:50
问题 I'm using d3js and SVG to resize and rotate rectangles, I capture the mouse events on handles that are positioned in each corner of the rectangle, there are two handles in each corner, one for resizing (square) and other to rotate (circle). When I do the following process, the rectangle "jumps" from its location to another one: Rotate (it means it's not more in zero degrees) Resize (any direction) Rotate again (here is when the shape "jumps") The jump only occurs when the center of the

calculate pixel coordinates for 8 equidistant points on a circle

夙愿已清 提交于 2019-12-13 06:17:09
问题 I have a circle centred at 0 with radius 80. How using python do I calculate the coordinates for 8 equidistant points around the circumference of the circle? 回答1: r = 80 numPoints = 8.0 points = [] for index in range(numPoints): points.append([r*math.cos((index*2*math.pi)/numPoints),r*math.sin((index*2*math.pi)/numPoints)]) return points you can simplify this some if you know you are always going to have only 8 points with something like: r = 80 numPoints = 8 points = [] x = (r*math.sqrt(2))

Fortran error when calculating cosx

◇◆丶佛笑我妖孽 提交于 2019-12-13 05:20:17
问题 I was assigned the following problem: Make a Fortran program which will be able to read a degree[0-360] checking validity range(not type) and it will be able to calculate and print the cos(x) from the following equation, where x is in radians: cos(x)=1-x^2/2! + x^4/4!-x^6/6!+x^8/8!-... As a convergence criteria assume 10^(-5) using the absolute error between two successive repeats (I suppose it means do's). For the calculation of the ! the greatest possible kind of integer should be used.

VBA sin() and cos() trouble

爷,独闯天下 提交于 2019-12-13 04:03:01
问题 Im trying to make some VBA form and to calculate some simple values but I dont understand why VBA dosen't recognize Sin() and Cos() functions. For example: I wrote int() and VBA transformed it into Int(), but it doesn't do the same with sin and cos. Moreover, after I'm trying to compile my code Private Sub btn_exit_Click() Unload laborator_2 End Sub Private Sub btn_start_Click() today.Caption = Date rnb_val.Caption = Int(Rnd * 90 + 1) sqrt_val.Caption = Sqr(rnb_val.Caption) si_val.Caption =

Sinus in verilog

元气小坏坏 提交于 2019-12-13 02:57:24
问题 So I need to get sinus waveform. In cases I have wrote values of x and y axis in range of 2pi how to get the waveform of the sinus in this range? module sinus1(in,clk,res,out); input clk,res; input [7:0]in; output reg [7:0]out; always @(posedge clk) if (res) case (in) 8'b00000000: out<=8'b10000000; 8'b00000001: out<=8'b10000011; 8'b00000010: out<=8'b10000110; 8'b00000011: out<=8'b10001001; 8'b00000100: out<=8'b10001100; 8'b00000101: out<=8'b10001111; 8'b00000110: out<=8'b10010010; ... ... ...

3D Fireworks Effect in C/C++ using sine or cosine function

♀尐吖头ヾ 提交于 2019-12-13 00:20:47
问题 I am trying to implement fireworks effect in C. I have a cube with dimensions 10x10x10. A rocket starts from the ground, and when it reaches 8th floor it explodes. Here's the point I cannot do - the explosion. How can I implement this using sine or cosine function? so in point(5,0,7) //(x,y,z)// a rocket goes in the air for (j=0; j<9; j++) { setpoint(x, y, j); delay(100); clean(); //clears everything } Here comes the point to make the explosion. How this can be achieved? It can sparkle in