trigonometry

Change value programmatically

坚强是说给别人听的谎言 提交于 2019-12-12 02:39:22
问题 I am using this color wheel, and I want to change the color of the color wheel programmatically. So if I have a color value (rgb, hsv etc.) I want to change the color wheel to that specific color? For example, if I have rgb(255, 255, 80) , how can I change the color wheel to show that? JSFiddle Relevant code: Custom code: function changeColor() { var redColor = 255; var greenColor = 255; var blueColor = 80; //currentX = //currentY = redraw(0); // The following line is redundent if I'm calling

Errors while converting np.array to decimal in Python

半腔热情 提交于 2019-12-12 02:14:09
问题 This is a continuation of the question asked here: Exponential of large negative numbers. The reason I want to use decimal is that np.exp(-large_numbers) return 0.0. Using Eric's answer to this question: https://stackoverflow.com/a/7771210/6943476, I tried converting my np.array to decimal but I still get the data-type numpy.ndarray. Coding ability: Beginner My final goal is to have a function return a damped sinusoid: def waveform(mass_sm, amplitude, F, Q, phi, Time): w = F/mass_sm print

Drawing filled circle using trigonometry [duplicate]

若如初见. 提交于 2019-12-12 00:29:08
问题 This question already has answers here : How to draw a filled circle? (2 answers) Closed 4 years ago . Is there any function I can create in order to draw a filled circle using the base drawing functions: putpixel(x, y); lineto(x, y); ? Note that it must use trigonometric functions (videlicet sin , cos etc..) so I can easily turn it into a hexagon and even further - a square or another type of polygon. And finally, not necessarily but always appreciated if it isn't very slow in drawing (one

repeat loop in R to compute the cosine of 2.345 correct to 5 decimal places

与世无争的帅哥 提交于 2019-12-11 19:03:16
问题 I want to compute the cosine of 2.345 correct to 5 decimal places using Taylor series. My code is given below. I am not sure what is wrong with that. Any help is appreciated! > x<-2.345 > count<-0 > repeat{ + count<-count+1 + initial = (-1)^(n-1) + numerator = x^(2*(n-1)) + denominator = factorial(2*(n-1)) + total=(initial*numerator)/denominator + if(abs((cos(x)-total)/cos(x))*100 <= 0.00001) break + sum=sum+total + } 回答1: It's a simple matter of correcting what is wrong in your code. x <- 2

Determining Vector points on a circle [closed]

家住魔仙堡 提交于 2019-12-11 18:18:45
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have a problem it is like trig and pre calc. We are given vector points for OA which is (6 0) and vector OB (-6 0) and OC (5 root11) and they are all points on a circle with a radius of 6. How exactly do you determine or show that these points lie on the circle? 回答1: For any three points which are not mutually

Trying to implement The inverse of a dct 8*8 matrix

自古美人都是妖i 提交于 2019-12-11 18:16:36
问题 I have managed to calculate the dct of an 8*8 matrix and I am having trouble doing the inverse. Can anyone have a look at this code and tell me what I am doing now. I should be getting the exact same values as before but im getting different values. I am reading in the input from a csv file and out putting it to anther csv file. Its programmed in c void idct_func(float inMatrix[8][8]){ double idct, Cu, sum, Cv; int i, j, u, v; float idctMatrix[8][8], greyLevel; FILE * fp = fopen("mydata.csv",

I am trying to calculate sine of an angle without using the Math.sin() in java

无人久伴 提交于 2019-12-11 17:54:38
问题 I am trying to calculate sine of an angle without using the Math.sin(). I got stuck in it's equation as I keep getting the wrong results note I have a method that changes the angle from degrees to radians public static double sin(double x, int precision) { //this method is simply the sine function double answer = 1, power = 1; int n = 2,factorial = 1; while (n<=precision) { power = (power * x * x *-1) +1 ; factorial = (factorial * (n +1))* (n-1); answer = answer + ((power/factorial )); n = n

Calculate the slope of a tangent of an arbitrary point on a quadratic curve in Javascript

泪湿孤枕 提交于 2019-12-11 15:38:10
问题 I've never been a trig champion and after about 4 hours of searching, I decided to ask here: I use Javascript to draw a quadratic curve (not a cubic bezier curve) onto a HTML5 Canvas like so: this.shape.moveTo(50,80).curveTo(100,120,40,190); where moveTo specifies x and y of the first point, the first two parameters of curveTo specify the x and y of the control point, and the 3rd and 4th parameter of curveTo specify the x and y of the end point. I need to craft a function that allows me to

sin(pi) not returning exact zero? [duplicate]

醉酒当歌 提交于 2019-12-11 15:09:36
问题 This question already has answers here : Is floating point math broken? (31 answers) Closed 2 years ago . #include <math.h> #include <stdio.h> int main(int argc, char* argv[]) { double pi = acos(-1); for(int i = 0; i<65;i++) { double resultD = sin( pi * (2.0 *i / 128.0 )); float resultF = sin( pi * (2.0f*i / 128.0f)); printf("sine[%d]\n %.25f\n %.25f \n", i,resultD,resultF); } } In the above code, I would expect to get last value to be clean zero. However, it is something like 0

How to get user friendly values for trigonometric functions?

给你一囗甜甜゛ 提交于 2019-12-11 13:42:49
问题 I am developing an android app. for mathematical calculations. There I have some buttons like sin,cos,tan which should show their respective trigonometric values, for that I am using corresponding methods of java.lang.Math class and that works fine. But after some tests I came to know that, it shows some results as follows sin(90)=0.89399........ //I want it to show 1 cos(90)=-0.44807........ //I want it to show 0 tan(90)=-1.995200...... //I want it to show Infinity as sin(90)/cos(90)=1/0