trigonometry

How to concatenate sine waves without phase jumps

为君一笑 提交于 2020-01-04 01:56:54
问题 I need to make a python script which generates sine waves of a given frequency and plays them using pyaudio (blocking mode), I also need to be able to change this frequency while it runs, modulate it and plot it using pyqtgraph. For now I have a thread generating chunks of data and my approach to 'connect' those sines was to get the fft and then calculate the angle (numpy.angle), store it in a variable and use it as the phase offset to the next chunk, but I'm not getting the results I

How to use a Sine / Cosine wave to return an oscillating number

旧时模样 提交于 2020-01-03 03:08:08
问题 I'm new to Java programming, I am programming Java 1.6 with Android. I have a simple function that makes a number go up and down between 0 and 200. I would like to put this into a Sine function but keep getting errors with what I've been trying. I want my program to update an int (Number1) via a sine wave y axis. Any ideas change the following logic into a Sine function? (disregard the 2nd number) code: private int Number1 = 150; private int Number2 = 0; private int counter = 0; public void

Find corners of a rotated rectangle

空扰寡人 提交于 2020-01-03 03:01:07
问题 I'm trying to resize a rotated rectangle, you just drag the image out (or in) from 1 corner, and the corner diagonal of that 1 will stay in the old position. So I know the angle(radians) of rotation and 2 corners diagonal of each other, now I would like to find the other two corners. I've tried to calculate em with Trigonometry but I failed miserably, so how can u calculate those other 2 points. 回答1: In pseudocode: r = (x2 - x1)*sin(a) - (y2 - y1)*cos(a) x3 = x1 + r*sin(a) y3 = y1 - r*cos(a)

How do I easily convert a line angle to a navigational-bearing scale (i.e., with range of [0,360) and “North” = 0 deg)?

徘徊边缘 提交于 2020-01-02 11:03:46
问题 I have two points, (x1,y1) and (x2,y2) , that I'd like to draw a line between. I know I can figure out the angle (in degrees) of that line using arctangent and the slope: atan((y2-y1)/(x2-x1))*180/pi However, how would I convert this angle to a [0,360] scale? Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg. Thanks! 回答1: (450-atan2(y2-y1,x2-x1)*180/pi)%%360​​​​​​​​​​​​​​​ segmentToAngle <- function(x1,y1

How do I easily convert a line angle to a navigational-bearing scale (i.e., with range of [0,360) and “North” = 0 deg)?

时间秒杀一切 提交于 2020-01-02 11:03:24
问题 I have two points, (x1,y1) and (x2,y2) , that I'd like to draw a line between. I know I can figure out the angle (in degrees) of that line using arctangent and the slope: atan((y2-y1)/(x2-x1))*180/pi However, how would I convert this angle to a [0,360] scale? Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg. Thanks! 回答1: (450-atan2(y2-y1,x2-x1)*180/pi)%%360​​​​​​​​​​​​​​​ segmentToAngle <- function(x1,y1

How do I easily convert a line angle to a navigational-bearing scale (i.e., with range of [0,360) and “North” = 0 deg)?

混江龙づ霸主 提交于 2020-01-02 11:02:18
问题 I have two points, (x1,y1) and (x2,y2) , that I'd like to draw a line between. I know I can figure out the angle (in degrees) of that line using arctangent and the slope: atan((y2-y1)/(x2-x1))*180/pi However, how would I convert this angle to a [0,360] scale? Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg. Thanks! 回答1: (450-atan2(y2-y1,x2-x1)*180/pi)%%360​​​​​​​​​​​​​​​ segmentToAngle <- function(x1,y1

Calculate point and circle segment collision

你说的曾经没有我的故事 提交于 2020-01-02 10:33:33
问题 If I have calculated an intersection point between a line segment and a circle, how can I tell whether or not this intersection point lies on a segment of the circle? I have the equations to tell whether or not a line segment intersects with the circle, and I also have the intersection point on that circle, but what I need to know is whether or not this collision point on the circle lies within the bounds of a specific arg segment of that circle. I have the end points of the arc segment, the

How to get angle of point from center point?

混江龙づ霸主 提交于 2020-01-01 10:13:11
问题 If I have 2 points (x0,y0) which is the center of the circle, and another point (x,y) (this is the red dot on the circle boundary in the image). How can I get the angle of the dot? Note, it should return an angle in degrees, from [0,360). The red dot angle in the image is approximately 70 degrees. How can I do this in python? Thanks This doesn't seem to work. (dx, dy) = (x0-x, y-y0) angle = atan(float(dy)/float(dx)) if angle < 0: angle += 180 回答1: You were very close :-) Change this: angle =

Calculating angles between line segments (Python) with math.atan2

孤者浪人 提交于 2020-01-01 05:32:41
问题 I am working on a spatial analysis problem and part of this workflow is to calculate the angle between connected line segments. Each line segment is composed of only two points, and each point has a pair of XY coordinates (Cartesian). Here is the image from GeoGebra. I am always interested in getting a positive angle in 0 to 180 range . However, I get all kind of angles depending on the order of vertices in input line segments. The input data I work with is provided as tuples of coordinates.

Determine rotation direction /toward/ variable point on a circle

只谈情不闲聊 提交于 2019-12-31 06:27:08
问题 Given circle centre: vectorA and another Vector on the circle's perimeter:vectorB, how can you determine the shorter route for vectorB to translate to another point on the circle's perimeter that is variable:vectorC? Will the shorter route be clockwise or counter clockwise rotation? If it helps think of a clock. If the times is a random point on the clock's perimeter eg. 6, and the minute hand position is known, eg. 4. Does the hand need to rotate around the clock's centre point clockwise or