trigonometry Questions

1

I was playing around with Compiler Explorer and ran into an anomaly (I think). If I want to make the compiler vectorize a sin calculation using libmvec, I would write: #include <cmath> #def...
Eugine asked 20/9, 2016 at 9:54

4

Solved

Unfortunately, the standard C++ library doesn't have a single call for sincos, which gives a place for this question. First question: If I want to calculate a sin and a cos, is it cheaper to calc...
Universe asked 13/9, 2013 at 19:38

2

Solved

I had searched on the internet and I could not find the method of the Math object that returns the ctg and arcctg of an angle. Is there such a method or should I just create my own function using t...
Cabrera asked 31/8, 2016 at 8:23

10

Solved

Finding the angle between two vectors is not hard using the cosine rule. However, because I am programming for a platform with very limited resources, I would like to avoid calculations such as sqr...
Ephor asked 15/9, 2009 at 14:9

22

Solved

I am googling the question for past hour, but there are only points to Taylor Series or some sample code that is either too slow or does not compile at all. Well, most answer I've found over Google...
Lukas asked 6/9, 2013 at 16:20

12

Solved

I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back aga...
Gina asked 25/9, 2008 at 20:40

5

Solved

I have a square, where the closest points are 1 unit away from the center. See my ascii diagram below: +-----------+ | | | x | |-----+ | | | | | +-----------+ Therefore, the distance from the or...
Beauregard asked 25/1, 2011 at 0:44

6

Solved

I'm looking to calculate highly parallelized trig functions (in block of like 1024), and I'd like to take advantage of at least some of the parallelism that modern architectures have. When I compi...
Nosebleed asked 24/2, 2011 at 20:9

2

Solved

When attempting to use a trigonometric function in my programming language, I get a seemingly wildly incorrect result. For example, sin(90) = 0.8939966636005579 But I would expect sin(90) to...
Ninnyhammer asked 1/12, 2023 at 12:52

3

I want to approximate tan(x) quickly to within 1 ULP on the range -pi/4 to pi/4. I have found a solution that is almost good enough but the last factor of two eludes me even with considerable compu...
Cashier asked 23/11, 2023 at 11:41

3

Solved

I have a task to draw a specific graphic. As part of this task I need to rotate some dot's on 45 degrees. I've spent already 2 days trying to calculate a formula, but just couldn't get it right. I...
Catlin asked 4/12, 2012 at 2:47

3

Solved

I am trying to find the cosine similarity between 2 vectors (x,y Points) and I am making some silly error that I cannot nail down. Pardone me am a newbie and sorry if I am making a very simple erro...
Amalberga asked 26/9, 2011 at 20:11

4

Solved

Any fast & accurate atan/arctan approximation function/algorithm out there? Input: x = (0, 1] (minimum x requirement). Output: in radians double FastArcTan(double x) { return M_PI_4*x - x*(fa...
Alcahest asked 1/3, 2017 at 17:13

4

Solved

I need an acos() function with double precision within a compute shader. Since there is no built-in function of acos() in GLSL with double precision, I tried to implement my own. At first, I imple...
Mahau asked 10/3, 2015 at 16:33

10

Solved

I'm looking for a formula to find the shortest distance in degrees between two degree marks on a circle: for instance, 30 degrees and 170 degrees (140 degrees). The two degree marks can be virtual...
Ace asked 29/2, 2012 at 20:9

7

I need to return the sin and cos values of every element in a large array. At the moment I am doing: a,b=np.sin(x),np.cos(x) where x is some large array. I need to keep the sign information for ...
Thetic asked 4/9, 2015 at 11:48

4

I am trying to calculate the inverse of tan in python, but it does not give me the correct value, for example, if I were to do the inverse tan of 1.18, math.atan(1.18) >>>math.atan(1.18) ...
Inhambane asked 7/4, 2012 at 19:56

5

Solved

In C library math.h, there was a sincos function which was pretty efficient, because it computed both sine and cosine in a time closer to a single call to sin() or cos() than to the total time of c...
Fastigium asked 20/6, 2014 at 13:14

6

Solved

I'm working on a problem that has to do with calculating angles of refraction and what not. However, it seems that I'm unable to use the numpy.sin() function in degrees. I have tried to use numpy.d...
Arv asked 21/1, 2015 at 22:6

5

Solved

I've got a little Problem with the Math.cos() method. I know, I have to convert the angle to Radians before using Math.cos(). But if I just do: System.out.println(Math.cos(Math.toRadians(90)); I...
Sarabia asked 27/10, 2012 at 12:23

2

I am trying to learn how to calculate the XYZ coordinates of a point using the XYZ coordinates of an origin point, a horizontal and vertical angle, and 3d distance. I can make the calculations simp...
Mailbag asked 3/6, 2015 at 12:18

3

Solved

I came across some weird behavior by math.cos() (Python 3.11.0): >>> import math >>> math.cos(math.pi) # expected to get -1 -1.0 >>> math.cos(math.pi/2) # expected to get...
Cobwebby asked 26/2, 2023 at 1:35

6

Solved

Does anyone know why the below doesn't equal 0? import numpy as np np.sin(np.radians(180)) or: np.sin(np.pi) When I enter it into python it gives me 1.22e-16.
Finespun asked 5/9, 2013 at 21:45

7

Solved

I've written a a little function that gives me out a value based on a sine wave when I put in a float between 0 and 1. I'm using it to lerp things around in a game. public static class Utilities ...
Rustproof asked 27/2, 2014 at 13:35

4

Solved

I'm new to Javascript and I'm trying to use inverse tangent to find the angle in degrees between a line and the x axis on an elevated y. I don't see any command for it so I really need some help.
Phosphaturia asked 24/2, 2017 at 14:1

© 2022 - 2025 — McMap. All rights reserved.