trigonometry

calculating intersection point of quadratic bezier curve

╄→гoц情女王★ 提交于 2019-12-23 09:38:38
问题 This is definitely pushing the limits for my trig knowledge. Is there a formula for calculating an intersection point between a quadratic bezier curve and a line? Example: in the image below, I have P1, P2, C (which is the control point) and X1, X2 (which for my particular calculation is just a straight line on the X axis.) What I would like to be able to know is the X,Y position of T as well as the angle of the tangent at T. at the intersection point between the red curve and the black line.

Number of Sides Required to draw a circle in OpenGL

家住魔仙堡 提交于 2019-12-22 12:58:36
问题 Does anyone know some algorithm to calculate the number of sides required to approximate a circle using polygon, if radius, r of the circle and maximum departure of the polygon from circularity, D is given? I really need to find the number of sides as I need to draw the approximated circle in OpenGL. Also, we have the resolution of the screen in NDC coordinates per pixel given by P and solving D = P/2, we could guarantee that our circle is within half-pixel of accuracy. 回答1: What you're

How to create Java GUI program for complex mathematical equations

你说的曾经没有我的故事 提交于 2019-12-22 11:29:24
问题 I am going through Java AWT & Swings and came to know on how to create the basic GUI elements and I was able to work on some programs with it. But when I am trying to understand how to create Graphs for some complex mathematical equations then I was not able to find some documentation or any examples. For example, in this post - How to solve the trigonometric equation cos(πθ/β)−cos(2πθ/β)=0? the user has given some complex equation and also shown how the graphs looks like. But how can we

Taylor series expansion as constexpr

一个人想着一个人 提交于 2019-12-22 08:47:33
问题 I'm trying to build a simple sine function using taylor series expansion that can be evaluated at compile time using C++14 constexpr . My code is compiling, but the compiler doesn't generate a constant. sine is defined as follows: template <int P, typename T = double> constexpr T sine(T x) { T result = x; for (int i = 1; i < P; ++i) result += power<T>(-1, i) * power<T>(x, 1 + 2 * i) / factorial<T>(1 + 2 * i); return result; } I can provide code for power and factorial if needed. They are

How to “snap” a directional (2D) vector to a compass (N, NE, E, SE, S, SW, W, NW)?

北城以北 提交于 2019-12-22 05:24:14
问题 I have a bunch of vectors normal to window surfaces in a 3D modelling software. Projected to the XY-Plane, I would like to know in which direction they are facing, translated to the 8 compass coordinates ( North , North-East , East , South-East , South , South-West , West and North-West ). The vectors work like this: the X axis represents East-West (with East being positive) the y axis represents North-South (with North being positive) thus (0, 1) == North (1, 0) == East (0,-1) == South (-1,0

Calculation sine and cosine in one shot

旧街凉风 提交于 2019-12-22 04:08:53
问题 I have a scientific code that uses both sine and cosine of the same argument (I basically need the complex exponential of that argument). I was wondering if it were possible to do this faster than calling sine and cosine functions separately. Also I only need about 0.1% precision. So is there any way I can find the default trig functions and truncate the power series for speed? One other thing I have in mind is, is there any way to perform the remainder operation such that the result is

Finding real roots of quartic equation using ferrari's method

非 Y 不嫁゛ 提交于 2019-12-21 21:10:52
问题 I am currently trying to solve a quartic equation using Ferrari's method from Wikipedia. I want to retrieve only the real roots, discarding the imaginary one. My implementation does not return the good value for real roots. I can't find the mistakes in the formula. My CubicEquation works as expected, and my bi-quadratic solving either. Now, I am only missing the Ferrari's method to be done but I can't make it work! Here's my class: public class QuarticFunction { private final double a;

Calculate center of SVG arc

为君一笑 提交于 2019-12-21 09:14:58
问题 I have the following information: radiusX (rx) radiusY (ry) x1 y1 x2 y2 The SVG spec allows you to define an arc by specifying its radius, and start and end points. There are other options such as large-arc-flag and sweep-flag which help to define how you want the start-point to reach the end-point. More details here. I am not mathematically inclined, so understanding all of this is near impossible. I guess I am looking for a simple equation that results in me knowing the centerX and centerY

Getting angle back from a sin/cos conversion

浪子不回头ぞ 提交于 2019-12-21 06:58:17
问题 I want to reverse a sin / cos operation to get back an angle, but I can't figure out what I should be doing. I have used sin and cos on an angle in radians to get the x/y vector as such: double angle = 90.0 * M_PI / 180.0; // 90 deg. to rad. double s_x = cos( angle ); double s_y = sin( angle ); Given s_x and s_y , is it possible to get back the angle? I thought atan2 was the function to use, but I'm not getting the expected results. 回答1: atan2(s_y, s_x) should give you the correct angle.

How to look up sine of different frequencies from a fixed sized lookup table?

依然范特西╮ 提交于 2019-12-20 19:59:07
问题 I am sampling a sine wave at 48 kHz, the frequency range of my sine wave can vary from 0 to 20000 Hz with a step of about 100 Hz. I am using a lookup table approach. So I generate 4096 samples for a sine wave for 4096 different phases. I think the general idea behind this to increment the step size and use different step sizes for different frequncy. So I do the following (pseudo code). But I am not sure how the step size is going to be related to the frequency I want to generate the samples