trigonometry

Fit sine wave with a distorted time-base

落爺英雄遲暮 提交于 2019-12-04 23:13:57
问题 I want to know the best way to fit a sine-wave with a distorted time base, in Matlab. The distortion in time is given by a n-th order polynomial (n~10), of the form t_distort = P(t) . For example, consider the distortion t_distort = 8 + 12t + 6t^2 + t^3 (which is just the power series expansion of (t-2)^3 ). This will distort a sine-wave as follows: I want to be able to find the distortion given this distorted sine-wave. (i.e. I want to find the function t = G(t_distort) , but t_distort = P(t

Plot the sine and cosine functions

狂风中的少年 提交于 2019-12-04 22:43:32
问题 I'm currently having some problems regarding my homework. Here's the Exercise: (Plot the sine and cosine functions) Write a program that plots the sine function in red and the cosine function in blue. hint: The Unicode for Pi is \u03c0 . To display -2Pi, use g.drawString("-2\u03c0", x, y). For a trigonometric function like sin(x), x is in radians. Use the following loop to add the points to a polygon p for (int x = -170; x <= 170; x++) { p.addPoint(x + 200, 100 - (int)(50 * Math.sin((x / 100

math.sin incorrect result

空扰寡人 提交于 2019-12-04 22:21:19
问题 >>> import math >>> math.sin(68) -0.897927680689 But sin(68) = 0.927 (3 decimal places) Any ideas about why I am getting this result? Thanks. 回答1: >>> import math >>> print math.sin.__doc__ sin(x) Return the sine of x (measured in radians). math.sin expects its argument to be in radians, not degrees, so: >>> import math >>> print math.sin(math.radians(68)) 0.927183854567 回答2: by default angle in Python is calculated in radians. So, you can try to multiply the angle ( degrees ) by 0.01745 - to

3D coordinate of 2D point given camera and view plane

丶灬走出姿态 提交于 2019-12-04 21:33:27
问题 I wish to generate rays from the camera through the viewing plane. In order to do this, I need my camera position ("eye"), the up, right, and towards vectors (where towards is the vector from the camera in the direction of the object that the camera is looking at) and P, the point on the viewing plane. Once I have these, the ray that's generated is: ray = camera_eye + t*(P-camera_eye); where t is the distance along the ray (assume t = 1 for now). My question is, how do I obtain the 3D

Calculating vertices of a rotated rectangle

寵の児 提交于 2019-12-04 13:45:47
问题 Hey guys, I am trying to calculate the vertices of a rotated rectangle (2D). It's easy enough if the rectangle has not been rotated, I figured that part out. If the rectangle has been rotated, I thought of two possible ways to calculate the vertices. 1) Figure out how to transform the vertices from local/object/model space (the ones I figured out below) to world space. I honestly have no clue, and if it is the best way then I feel like I would learn a lot from it if I could figure it out... 2

sine wave glissando from one pitch to another in Numpy

こ雲淡風輕ζ 提交于 2019-12-04 13:16:13
问题 I have been working on a program where I need to slowly and smoothly change the pitch of a sine wave from one pitch to another. I am able to get an array of the frequency the pitch should be at any given moment (for instance, [440, 526.5, 634.2 794.8, 880], though much, much longer) but it seems I am unable to actually apply that frequency to a wave. My best attempt is: numpy.sin(2*math.pi*x*freq/self.sample_rate) where "freq" is the array of frequencies and x is an enumeration array ([0,1, 2

Rotate rectangle around a point

江枫思渺然 提交于 2019-12-04 12:12:01
问题 How would I get 4 points rotated a certain degrees around a pointer to form a rectangle? I can rotate a point around a point, but I can't offset it to make a rectangle that isn't distorted. 回答1: If you can rotate a point around a point then it should be easy to rotate a rectangle - you just rotate 4 points. Here is a js function to rotate a point around an origin: function rotate_point(pointX, pointY, originX, originY, angle) { angle = angle * Math.PI / 180.0; return { x: Math.cos(angle) *

Finding point on sphere

不问归期 提交于 2019-12-04 11:35:21
So I need to find the point on a sphere's surface using the radius, the center of the circle and the rotation vector. I have this equation right now: x = position.x + radius * Math.cos(rotation.x) * Math.sin(rotation.y) y = position.y + radius * Math.sin(rotation.x) * Math.sin(rotation.y) z = position.z + radius * Math.sin(rotation.y) This formula produces crazy results that are totally not what I need at all. I quite honestly have no idea what I've done wrong, I tried to use the formula I found here: Finding Point on sphere But it didn't work. What have I done wrong? In your third line, you

Find the normal angle of the face of a triangle in 3D, given the co-ordinates of its vertices

99封情书 提交于 2019-12-04 08:41:30
问题 As you may be able to tell from this screenshot, I am trying to make a physics engine for a platformer I am working on, but I have run into a definite problem: I need to be able to find out the angle of any one of the triangles that you can see make up this mesh, so that I can work out the rotation and therefore angular acceleration of the player on that triangle. I can use an algorithm that I created to find the locations of all 3 points of any triangle that the player is in contact with,

Formula/algorithm to offset GPS coordinations

為{幸葍}努か 提交于 2019-12-04 06:24:18
问题 I have GPS coordinates provided as degrees latitude, longitude and would like to offset them by a distance and an angle. E.g.: What are the new coordinates if I offset 45.12345 , 7.34567 by 22km along bearing 104 degrees ? Thanks 回答1: For most applications one of these two formulas are sufficient: "Lat/lon given radial and distance" The second one is slower, but makes less problems in special situations (see docu on that page). Read the introduction on that page, and make sure that lat/lon