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

How can I know how many data that have a different day or date in array object
Hello Everyone!
In this case, I have dataobject
insidearray
and every data have aUnix Time
or a Date, I want to count how many data that have a different day or date, the goal is to take the average value of income per day, per week, month, and also year.as you can see my code below, I have 9 data and 4 different dates or days, it's mean i have 4 counts in data that have a different date, but how can I get dynamically? And sorry for my English
let MyData = [ { date: 1592918643305, name: 'Alex' }, { date: 1592921952307, name: 'Simon' }, { date: 1592927378630, name: 'Fory' }, { date: 1592987102694, name: 'John' }, { date: 1592987102694, name: 'Erwin' }, { date: 1593422810672, name: 'Muller' }, { date: 1593424811785, name: 'Thomas' }, { date: 1593478227245, name: 'Max' }, { date: 1593478293013, name: 'Tom' } ]; function convertToRegularDate(unix) { let regularDate = new Date(unix); let year = regularDate.getFullYear(); let month = regularDate.getMonth(); let date = regularDate.getDate(); return 'Date: ' + date + '/' + month + '/' + year; } MyData.forEach(function (item) { console.log('Name: ' + item.name + ' ' + convertToRegularDate(item.date) ); });

When I try to use the filter function in D3.js, it tells me "data.filter is not a function." Why?
My data is all in one long form CSV file and I want the user to be able to choose which country's data they would like to have visualized. In order to do that, I am using the filter function in D3.js. When they choose a country as input, the program will filter out all rows that do not match the input in the CountryName column. Then, it would visualized the filtered data.
I was hoping something like this would work.
data = data.filter(function(d) { return d.CountryName === "China"});
Yet when I do this, I get "data.filter is not a function." I have seen d3.js code that successfully uses data.filter... why won't it work here?
Additional Info:
One of the comments asked what data is. Here's what I have for data:
data = d3.csv("econDataLong.csv", function(d) { return { CountryName: d.CountryName, IndicatorName: d.IndicatorName, Year: d.Year, Value: +d.Value } } ); filtered = data.filter(function(d) { return d.CountryName === "China"}); console.log(filtered);
I have been doing this to see if I can get filter working, but so far no luck.

Wordpress how to achieve?: search bar on main page, then display a table filtered by the search bar input, on a different page
this is supposed to be done in Wordpress, so if there are any plugins that do this, it would be great. If not, i'd like to code that.
I would like a search bar on the main page. When a user types something and presses enter, i want to direct him/her to a different page with a table (which is available in a wordpress plugin, and also has filtering functions), with the input word from the main page's search bar already in the table's search, and filtering the current table.
Not sure what would be the best and easiest way to achieve that.

Calculate other angles based on known rotation angle
I am making a mechanical system animation on OpenGL and having a little trouble calculating the rotations angle of the connecting rods based on a known rotation angle A and the position of the point D.
I need to calculate the angle CDE and CBG as well as the position of point E based on angle A and the position of D. But my high school is failing me right now. I have tried several ways but they all lead to nothing.
The length of segment DA is also known.
Do you have any ideas on how to do that? What should I do?

Circle degrees loop in Angular Leaflet
I am trying to create circle degrees in Angular leaflet maps In my first step i have applied formulas for 30 45 degrees and so on as
const x30: number = p.x + (radius) * (Math.cos(Math.PI / 6)); const y30: number = p.y + (radius) * (Math.sin(Math.PI / 6)); const x45: number = p.x + (radius) * (Math.cos(Math.PI / 4)); const y45: number = p.y + (radius) * (Math.sin(Math.PI / 4));
but now i want to have a for loop that starts according to my selected values of dropdown like if i select 10 then my loop should start from 10 and should have distance of 10 degree means now i have to find (x,y) for 10 20 30 degrees and so on now my question is that what should be the series of degrees that i should use in for loop? or what should be the option to get degree form Math Library?

Are trig functions that slow in modern hardware?
I have heard over and over again that trig functions are slow and should be avoided. I am heavily skeptical this is true today.
Consider the following article: https://blackpawn.com/texts/pointinpoly/default.html
That claims adding angles is slower than either testing the sides of the triangle or using a basis representation.
I implemented all 3 versions in c++:
bool TestPointInTriangle( const std::vector<Eigen::Vector3d>& triangle, const Eigen::Vector3d& point) { double angle = 0; array<Eigen::Vector3d, 3> dirs; for(uint i=9; i < 3; i++) dirs[i] = (triangle[i]  point).normalized(); for(uint i=9; i < 3; i++) angle += acos(dirs[i].dot(dirs[(i + 1) % 3])); return abs(angle  2 * M_PI) < 0.000001; } inline bool SameSide(const Eigen::Vector3d& p1, const Eigen::Vector3d&p2, const Eigen::Vector3d&a, const Eigen::Vector3d& b) { auto cp1 = (b  a).cross(p1  a); auto cp2 = (b  a).cross(p2  a); if (cp1.dot(cp2) >= 0) return true; else return false; } bool PointInTriangleSide( const std::vector<Eigen::Vector3d>& triangle, const Eigen::Vector3d& p) { auto a = triangle[0]; auto b = triangle[1]; auto c = triangle[2]; if (SameSide(p,a, b,c) && SameSide(p,b, a,c) && SameSide(p,c, a,b)) return true; else return false; } bool PointInTriangleBasis(const std::vector<Eigen::Vector3d>& triangle, const Eigen::Vector3d& p) { auto a = triangle[0]; auto b = triangle[1]; auto c = triangle[2]; // Compute vectors Eigen::Vector3d v0 = c  a; Eigen::Vector3d v1 = b  a; Eigen::Vector3d v2 = p  a; // Compute dot products double dot00 = v0.dot(v0); double dot01 = v0.dot(v1); double dot02 = v0.dot(v2); double dot11 = v1.dot(v1); double dot12 = v1.dot(v2); // Compute barycentric coordinates auto inv_denom = 1 / (dot00 * dot11  dot01 * dot01); auto u = (dot11 * dot02  dot01 * dot12) * inv_denom; auto v = (dot00 * dot12  dot01 * dot02) * inv_denom; // Check if point is in triangle return (u >= 0) && (v >= 0) && (u + v < 1.0); }
Then I used gtest to benchmark:
 Benchmark Time CPU Iterations  BM_TriangleTestSide 66.0 ns 65.9 ns 10127255 BM_TriangleTestBasis 30.9 ns 30.9 ns 22781566 BM_TriangleTestNaive 24.1 ns 24.1 ns 29210171
The fastest is the naive implementation. Now I have not really spent much time trying to implement the absolute best version of each function, I merely copy pasted and modified the code on the website to make sure each one compiled.
However it's not like I went out of my way to make the implementation inefficient unfarily towards one function. So for example in this specific case, benchmarking suggests the "worse" solution is actually the best in spite trig functions.
So, is it still true that trig functions are synonymous with bottlenecks?
Edit: As noted in the comments a major typo that went unnoticed made the code I posted useless, the correct results are:
 Benchmark Time CPU Iterations  BM_TriangleTestSide 66.4 ns 66.4 ns 10220621 BM_TriangleTestBasis 32.6 ns 32.6 ns 21290255 BM_TriangleTestNaive 60.0 ns 59.9 ns 10408830
So I guess the answer is yes, trig functions remain expensive.