How can we map output of atan2() to [90 to +90]?
I have output from complementary filter which uses atan2() function but the outputs are in range [pi to +pi] as they are given by atan2.
See also questions close to this topic

Move color filter WooCommerce under breadcrumb
I want to make a product filter option by color, and I want to show product only after a user click on x color by list. Right now, that's my website and is not ok for me
I want to make my website like this, i modifed photo. Please, can anyone help me with that problem?

Multiplying a sparse matrix by an array without copying
I have a 1d array (vector of size
M
), a pretty large one, and I definitely don't want to be copying it in memory. I also have a sparse matrix of windowN
(arbitrary size, basically all elements except the diagonal &N
pseudo diagonals are zero).I want to multiply this sparse matrix by the vector, without having to copy the vector in memory. What's the easiest and most efficient way of doing this? There has to be a neat solution, but I don't know the proper literature and I'm not educated enough to figure this out.
There is a solution for
N=1
(where matrix is:a
on the diagonal, andb
on two closest pseudo diagonals). The solution looks smth like this (e.g., in python):tmp2 = array[0] i = 1 while (i < len(array)  1): tmp1 = b * (array[i  1] + array[i + 1]) + a * array[i] array[i  1] = tmp2 i += 1 tmp2 = b * (array[i  1] + array[i + 1]) + a * array[i] array[i  1] = tmp1 i += 1
But I can't manage to generalize this for an arbitrary
N
.Notes: I absolutely don't want to be copying the size
M
vector in memory. However, using a temporary array of size2N+1
is ok, sinceM >> N
. I'm looking for an actual algorithm description, not a smart custom library that does the job.Thanks in advance!

the main array gets affected by array.filter
I have the following code which gets data from a server:
ngDoCheck(): void { this._data.subscribe(data => { this.data = data; this.dataHolder = JSON.parse(JSON.stringify(data)) }); }
When I want to filter products I need each time to pass the whole products list, I'm doing that by using the dataHolder object, but the problem is the dataHolder object gets filtered too. I know there's a problem with reference, but since I'm using
JSON.parse(JSON.stringify(data))
it shouldn't be a problem there.this.data.products = this.dataHolder.products .filter((product: any) => brandsIds.includes(product.brand));

I want to extract a sin function from a sting in python
I have a string like "4+5+6+sin(30)"
I want 30 from this string

How to apply a cosine tapering window to a dataset?
I am trying to apply a tapered cosine window (hanning method) to a sea level height anomaly data set, but I am unsure how to apply the cosine window to each axis in the data set. The data set containing time, latitude, longitude. I would like to taper the ends of the data set to be zero before performing a complex FFT. Thank you!
Code:
#creating arrays lat = a.variables["latitude"][:] lon = a.variables["longitude"][:] time = a.variables["time"][:] sla = a.variables["sla"][:,:,:] #t, y, x time = Yearmin + (year_len * (time  np.min(time)) / ( np.max(time)  np.min(time))) #standardize sla data along time by removing trend, subtracting mean, and normalizing to unit stdev sla_detrend = signal.detrend(sla, axis=0) sla_mean_remove = sla_detrend  np.mean(sla_detrend,axis=0) #normalizing sla_normed = sla_mean_remove/np.std(sla,axis=0) #tapering (apply hanning cosine window) dims = sla.shape N = dims[0] # Number of time steps (length of time axis) n = int(N/100) # Sample length of one half cosine (one percent of length time series) t = np.arange(n) w = 0.5*(np.cos(np.pi*t/(n1)) + 1) # Windowing function y = sla if y.ndim == 1: y[n1::1] = w * y[n1::1] y[n:] = w * y[n:] elif y.ndim == 2: y[n1::1,:] = w[:, None] * y[n1::1,:] y[n:,:] = w[:, None] * y[n:,:] elif y.ndim == 3: y[n1::1,:,:] = w[:, None, None] * y[n1::1,:,:] y[n:,:,:] = w[:, None, None] * y[n:,:,:] print(y[n:].shape) print(sla.shape)

Only some points inside of triangle are considered 'inside' the triangle
I've been attempting to make a simple pygame program that checks to see whether or not the cursor is inside or outside of a triangle. I'm doing this by finding the area of the larger triangle, and then making three interior triangles from the mouse position to all three points and finding their areas.
From my understanding, if the sum of the areas of the three internal triangles is equal to the sum of the total area, then the point is inside the triangle. However, my code is only returning that it's inside the triangle on specific pixels inside the triangle, and not the area overall.
I'm not sure whether this is a math error or a programming error, but here's the code regardless:
import pygame from math import sqrt pygame.init() DISPLAY = pygame.display.set_mode((400, 400)) def drawTriangle(pointA, pointB, pointC, color): pygame.draw.polygon(DISPLAY, color, [pointA, pointB, pointC], 5) def getLine(pointA, pointB): return sqrt((pointB[0]  pointA[0])**2 + (pointB[1]pointA[1])**2) def getArea(pointA, pointB, pointC): AB = getLine(pointA, pointB) BC = getLine(pointB, pointC) CA = getLine(pointC, pointA) s = (AB + BC + CA) / 2 return sqrt(s*(sAB) * (sBC) * (sCA)) A = [100, 100] B = [200, 100] C = [150, 200] Color = (255, 255, 255) while(True): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() break mpx, mpy = pygame.mouse.get_pos() posArray = [mpx, mpy] drawTriangle(A, B, C, Color) Area = getArea(A, B, C) trigA = getArea(A, B, posArray) trigB = getArea(posArray, B, C) trigC = getArea(A, posArray, C) if(trigA + trigB + trigC == Area): Color = (0, 255, 0) else: Color = (255, 255, 255) pygame.display.update()
So far my best guess is that it's a rounding issue, but I'm not certain how to address that if it is. I thought that by making the first if statement a <= would fix rounding errors, and it did improve the results, but it still wasn't perfect. Any help is appreciated.