trigonometry

Recursive program to compute Taylor approx of cosine not functioning in Prolog

这一生的挚爱 提交于 2020-02-15 10:25:45
问题 I'm still pretty new to Prolog, and i'm not sure why this code isn't working. I believe it is most likely a problem with the base case or in the last 3 lines of the recursive case. Everything else works just fine. This program determines cosine calculated with series approximation, to do so it needs to calculate the factorial of 2K, also -1 ^ K, and then uses these 2 calculations in the final equation (this is done in % Recursive Case). % Factorial from class fact(0, 1). fact(N, F) :- N > 0,

Find the arc of the intersection between circle and rectangle

末鹿安然 提交于 2020-01-24 21:08:44
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Find the arc of the intersection between circle and rectangle

只愿长相守 提交于 2020-01-24 21:06:28
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Find the arc of the intersection between circle and rectangle

…衆ロ難τιáo~ 提交于 2020-01-24 21:06:05
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Solving trignometric terms with maxima

走远了吗. 提交于 2020-01-24 08:57:05
问题 I try to get all roots of cos(x) with wxMaxima (%i29)solve(cos(x)=0,x); solve: using arc-trig functions to get a solution. Some solutions will be lost. (%o29) [x=%pi/2] The solution gets solved by using arccos. How can i get all solutions for a given domain? e.g. [0; 5*pi] 回答1: Using to_poly_solve you can obtain all solutions: to_poly_solve(cos(x)=0,x); 来源: https://stackoverflow.com/questions/44872011/solving-trignometric-terms-with-maxima

Solving trignometric terms with maxima

本小妞迷上赌 提交于 2020-01-24 08:56:28
问题 I try to get all roots of cos(x) with wxMaxima (%i29)solve(cos(x)=0,x); solve: using arc-trig functions to get a solution. Some solutions will be lost. (%o29) [x=%pi/2] The solution gets solved by using arccos. How can i get all solutions for a given domain? e.g. [0; 5*pi] 回答1: Using to_poly_solve you can obtain all solutions: to_poly_solve(cos(x)=0,x); 来源: https://stackoverflow.com/questions/44872011/solving-trignometric-terms-with-maxima

Rotate plotted points to re-project relative to another set of points

╄→尐↘猪︶ㄣ 提交于 2020-01-24 04:27:05
问题 I have a data frame of points that plot outlines of two polygons, one at right angles to the other, like so: Here are the data that make that plot: outlines <- structure(list(sample_ids = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,

How to bend a cylinder in three.js?

一世执手 提交于 2020-01-23 11:56:20
问题 How would you arc or bend a cylinder type geometry (that has distortion) in three.js? Id like to specify these parameters: Bend Start - at what percent of the cylinder's height the bend starts Bend End - at what percent of the cylinder's height the bend ends Angle - how strong the bend is I'll be controlling them with sliders. My cylinder shape is created from an extrusion of a bezier curve that the user draws (extension of geometry class in three.js). I'd also like to be able to layer

How do I generate a Sine Sweep in Java (Android)

纵然是瞬间 提交于 2020-01-21 13:37:25
问题 I found Playing an arbitrary tone with Android to be helpful when I was generating a frequency tone. Now I want the frequency to change while the tone is playing. I modified the genTone to be similar to this: private void genTone(double startFreq, double endFreq, int dur) { int numSamples = dur * sampleRate; sample = new double[numSamples]; double currentFreq = 0, numerator; for (int i = 0; i < numSamples; ++i) { numerator = (double) i / (double) numSamples; currentFreq = startFreq +

How do I generate a Sine Sweep in Java (Android)

百般思念 提交于 2020-01-21 13:36:57
问题 I found Playing an arbitrary tone with Android to be helpful when I was generating a frequency tone. Now I want the frequency to change while the tone is playing. I modified the genTone to be similar to this: private void genTone(double startFreq, double endFreq, int dur) { int numSamples = dur * sampleRate; sample = new double[numSamples]; double currentFreq = 0, numerator; for (int i = 0; i < numSamples; ++i) { numerator = (double) i / (double) numSamples; currentFreq = startFreq +