 # gustavo rincones

Member

13

5 Neutral

• Rank
Member

• Role
Programmer
• Interests
Education
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## C++ 3 quick ways to calculate the square root in c++

Hola chicos Since I created this post, I've only heard things I already knew, such as undefined behaviors, static members, trap representation in c ++ and modern compilers. I just want to see more efficient ways to calculate the square root. and since the creation of this publication, nobody has placed any sample code. chao
2. ## C++ how to calculate sine and cosine in c++ without STL

Hola Como estas! Alvaro I think that the two functions cannot be compared because their function cannot calculate the sine at all angles and much less negative angles and also because it uses atan that is part of the STL. I think it's not worth it, I say it in a good way and I don't try to insult him. That is all I have to say.
3. ## C++ how to calculate sine and cosine in c++ without STL

Hola Álvaro This function is almost 10 times slower than my current function and is also less accurate in some cases, for example "sine (30)" and still depends on the STL. If I wanted a precise but slow function, I would simply use the Taylor series for sine and cosine, which converges slowly but obtains the exact result.
4. ## C++ how to calculate sine and cosine in c++ without STL

The union can be removed for greater speed. When I wrote this function, I used the union as a static member. static union{int i; float f;} u; which consumes less memory and maintains the same speed. The union takes the largest size bits. In this case the float type. The function can be better written in the form. void sameRadian(const float& rad, float& c, float& s) { int i; float f; i = int(rad * 0.31830988f + 0.5f); c = (i % 2)? 3.14159265f * i - rad - 1.570796f : rad + 1.570796f - 3.14159265f * i; i = int(rad * 0.31830988f); s = (i % 2)? 3.14159265f * i - rad : rad - 3.14159265f * i; if(c < 0.0f) { f = (1.273239f + c * 0.405284f) * c; c = (f + 1.0f) * f * -0.225f + f; } else { f = (1.273239f - c * 0.405284f) * c; c = (f - 1.0f) * f * 0.225f + f; } if(s < 0.0f) { f = (1.273239f + s * 0.405284f) * s; s = (f + 1.0f) * f * -0.225f + f; } else { f = (1.273239f - s * 0.405284f) * s; s = (f - 1.0f) * f * 0.225f + f; } } the union is unnecessary only delays the function.
5. ## C++ how to calculate sine and cosine in c++ without STL

PI / 4 is the case of least convergence and the result is: 0.707816 three digits of precision. As I said from the beginning it is good only for video games. I have used this function a huge number of times to draw circles and calculate rotation matrices without any problem.
6. ## C++ how to calculate sine and cosine in c++ without STL

7. ## C++ how to calculate sine and cosine in c++ without STL

I really didn't know about the blog, but thanks I had no idea. I am new at this.
8. ## C++ how to calculate sine and cosine in c++ without STL

by the beginning of next year I will launch my educational 2d physics engine CirObb engine with educational purposes to help people understand more about this wonderful world of game physics. I am 19 years old and I hope one day to pursue this as a career.
10. ## C++ 3 quick ways to calculate the square root in c++

The third method can also be written this way: float sqrt3(const float& n) { int i = 0x2035AD0C + (*(int*)&n >> 1); return n / *(float*)&i + *(float*)&i * 0.25f; } the static member was removed from the function as a quote from: SeanMiddleditch.
11. ## C++ 3 quick ways to calculate the square root in c++

Very good information and also useful in its entirety. You are right, the "static" member avoids continuous creation of the union in exchange for speed but also completely limits the function. On the other hand, I like being able to see a function written in c ++ on how to calculate the square root in a more efficient way as you just described. I would really like to see that function please.