trigonometry

math.cos(x) not returning correct value?

拜拜、爱过 提交于 2020-07-03 16:59:10
问题 I just started using python, and am having difficulty with a very basic program. I want to calculate the cosine of -20 degrees. It is my understanding that the default value is in radians, so this is the following code i tried: import math print math.cos(math.degrees(-20)) This outputs (-.7208...), where the answer is actually (.9397...). I'm sure this has a pretty basic solution but I've tried so many different things and it will not output the correct results. Thanks in advance! 回答1: Per

math.cos(x) not returning correct value?

两盒软妹~` 提交于 2020-07-03 16:57:43
问题 I just started using python, and am having difficulty with a very basic program. I want to calculate the cosine of -20 degrees. It is my understanding that the default value is in radians, so this is the following code i tried: import math print math.cos(math.degrees(-20)) This outputs (-.7208...), where the answer is actually (.9397...). I'm sure this has a pretty basic solution but I've tried so many different things and it will not output the correct results. Thanks in advance! 回答1: Per

Maximize zoom distance to fit 2 objects

被刻印的时光 ゝ 提交于 2020-06-28 00:18:29
问题 Objective: Move the camera position ONLY on the Z axis so the frustrum fit 2 objects. Conditions: One of the objects will be allways aligned with the camera X position Camera is set on perspective mode , not ortographic. the 2 spheres have no parent The result seen in ortographic mode from top-view should look like this: What I've done so far: Using trigonometry this can be seen it as: Knowing that, the objective is to find the Adjacent side, which will be the distance between the camera and

Inverse of math.atan2?

旧时模样 提交于 2020-05-11 04:12:48
问题 What is the inverse of the function math.atan2 I use this in Lua where I can get the inverse of math.atan by math.tan . But I am lost here. EDIT OK, let me give you more details. I needed to calculate angle between 2 points (x1,y1) and (x2,y2) and I did, local dy = y1-y2 local dx = x1-x2 local angle = atan2(dy,dx)* 180 / pi Now if I have the angle, is it possible to get back dy and dx? 回答1: Given only the angle you can only derive a unit vector pointing to (dx, dy) . To get the original (dx,

sin, cos, tan not accurate

泪湿孤枕 提交于 2020-04-29 15:52:13
问题 Why does sinl give incorrect results when the argument is near a non-zero multiple of pi? Why does sinl give incorrect results when the argument is large? The following code illustrates that. Note that the digits used to initialize variable pi do not exactly match any 64-bit long double value. The compiler chooses the nearest value, which is 3.14159265358979323851280895940618620443274267017841339111328125 . The expected sine value can be found using libquadmath, gnu MPFR lib, or an online

sin, cos, tan not accurate

柔情痞子 提交于 2020-04-29 15:51:26
问题 Why does sinl give incorrect results when the argument is near a non-zero multiple of pi? Why does sinl give incorrect results when the argument is large? The following code illustrates that. Note that the digits used to initialize variable pi do not exactly match any 64-bit long double value. The compiler chooses the nearest value, which is 3.14159265358979323851280895940618620443274267017841339111328125 . The expected sine value can be found using libquadmath, gnu MPFR lib, or an online

How to plot sine wave in Python with sudden amplitude change?

柔情痞子 提交于 2020-04-18 03:59:11
问题 I was wondering if anyone knows how to plot a sine wave with let's say amplitude of 0.1 as a start and then continuing on as usual. Until at one point, the amplitude change to 1.0. Like a sudden surge of change in amplitude. It's like I was an oscillatory system that was stable, and becoming unstable at one point. The plot that I am expecting is as follow: Regards, Anis 回答1: You could plot a piece-wise sin function where the second part defines the surge happening and you can change the

Translating Screen Coordinates [ x, y ] to Camera Pan and Tilt angles

帅比萌擦擦* 提交于 2020-04-16 03:50:22
问题 I have a IP Camera which can PTZ. I am currently streaming live feed into the browser and want to allow user to click a point on the screen and the camera will pan and tilt so that the user clicked position will now become the center point of view. my Camera Pan 360 degrees and Tilt from -55 to 90. any algorithm that will guide to me achieve my goal ?? 回答1: Let's start by declaring a 3D coordinate system around the camera (the origin). I will use the following: The z-axis points upwards. The

Centering polar plot [closed]

自闭症网瘾萝莉.ら 提交于 2020-02-26 04:13:29
问题 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 7 days ago . I am trying to transform sine wave to circle in the polar plot so the circle was in the center of the polar plot in Octave and I would like to ask you for help. clc clear all x=0:0.01:2*pi; y=sin(x); subplot(3,1,1) plot(x,y) grid subplot(3,1,2) polar(x,y) theta=0:0.1:2*pi; rho=ones(size(theta));

Centering polar plot [closed]

人盡茶涼 提交于 2020-02-26 04:13:25
问题 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 7 days ago . I am trying to transform sine wave to circle in the polar plot so the circle was in the center of the polar plot in Octave and I would like to ask you for help. clc clear all x=0:0.01:2*pi; y=sin(x); subplot(3,1,1) plot(x,y) grid subplot(3,1,2) polar(x,y) theta=0:0.1:2*pi; rho=ones(size(theta));