38+ results for 'float Q_rsqrt repo:quake' (0 ms)
Not the results you expected?
stickvector.c (https://github.com/silver13/h8mini-testing.git) C · 57 lines
README.md (https://github.com/georgek42/inlinec.git) Markdown · 68 lines
8 def Q_rsqrt(number):
9 float Q_rsqrt( float number )
10 {
11 long i;
12 float x2, y;
13 const float threehalfs = 1.5F;
15 x2 = number * 0.5F;
16 y = number;
17 i = * ( long * ) &y; // evil floating point bit level hacking
18 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
19 y = * ( float * ) &i;
23 }
25 print(Q_rsqrt(1.234))
26 ```
27 Inlinec supports gnu-specific c extensions, so you're likely to have reasonable success #includeing glibc headers.
Position.hpp (https://github.com/davechurchill/ualbertabot.git) C++ Header · 181 lines
math_utils.c (https://github.com/r-lyeh/AVA.git) C · 122 lines
27 } Float2UInt;
29 static m_inline float floatRound(float x) {
30 // Probably slower than std::floor(), also depends of FPU settings,
31 // but we only need this for that special sin/cos() case anyways...
42 }
44 static m_inline float floatInvSqrt(float x) {
45 // Modified version of the emblematic Q_rsqrt() from Quake 3.
55 }
57 static m_inline float floatSin(float radians) {
58 static const float A = -2.39e-08f;
83 }
85 static m_inline float floatCos(float radians) {
86 static const float A = -2.605e-07f;
examples.js (https://github.com/mbebenita/WasmExplorer.git) JavaScript · 104 lines
Position.hpp (https://github.com/davechurchill/ualbertabot.git) C++ Header · 176 lines
volk_32f_invsqrt_32f.h (https://github.com/gnuradio/volk.git) C Header · 219 lines
45 * int N = 10;
46 * unsigned int alignment = volk_get_alignment();
47 * float* in = (float*)volk_malloc(sizeof(float)*N, alignment);
48 * float* out = (float*)volk_malloc(sizeof(float)*N, alignment);
71 #include <string.h>
73 static inline float Q_rsqrt(float number)
74 {
75 float x2;
95 static inline void
96 volk_32f_invsqrt_32f_a_avx(float* cVector, const float* aVector, unsigned int num_points)
97 {
98 unsigned int number = 0;
196 static inline void
197 volk_32f_invsqrt_32f_u_avx(float* cVector, const float* aVector, unsigned int num_points)
198 {
199 unsigned int number = 0;
stickvector.c (https://github.com/NotFastEnuf/NFE_Silverware.git) C · 169 lines
10 extern float GEstG[3];
11 extern float Q_rsqrt( float number );
12 extern char aux[];
13 extern float aux_analog[];
15 // error vector between stick position and quad orientation
16 // this is the output of this function
17 float errorvect[3];
18 // cache the last result so it does not get calculated everytime
19 float last_rx[2] = {13.13f , 12.12f};
20 float stickvector[3] = { 0 , 0 , 1};
25 void stick_vector( float rx_input[] , float maxangle)
26 {
27 // only compute stick rotation if values changed
0069.Sqrtx.md (https://github.com/halfrost/LeetCode-Go.git) Markdown · 91 lines
74 // 解法三 Quake III 游戏引擎中有一种比 STL 的 sqrt 快 4 倍的实现 https://en.wikipedia.org/wiki/Fast_inverse_square_root
75 // float Q_rsqrt( float number )
76 // {
77 // long i;
78 // float x2, y;
79 // const float threehalfs = 1.5F;
81 // x2 = number * 0.5F;
82 // y = number;
83 // i = * ( long * ) &y; // evil floating point bit level hacking
84 // i = 0x5f3759df - ( i >> 1 ); // what the fuck?
85 // y = * ( float * ) &i;
vec3.h (https://github.com/Warsow/qfusion.git) C Header · 157 lines
25 }
27 float Length() const { return (float)VectorLength( vec ); }
28 float LengthFast() const { return VectorLengthFast( vec ); }
31 float DistanceTo( const Vec3 &that ) const { return DistanceTo( that.Data() ); }
32 float DistanceTo( const vec3_t that ) const { return (float)Distance( vec, that ); }
33 float FastDistanceTo( const Vec3 &that ) const { return FastDistanceTo( that.Data() ); }
41 float SquareDistance2DTo( const Vec3 &that ) const { return SquareDistanceTo( that.vec ); }
42 float SquareDistance2DTo( const vec3_t that ) const {
43 float dx = vec[0] - that[0];
59 float squareLength = VectorLengthSquared( vec );
60 if( squareLength > 0 ) {
61 float invLength = Q_RSqrt( squareLength );
62 VectorScale( vec, invLength, vec );
63 return squareLength * invLength;
imu.c (https://github.com/silver13/h8mini-testing.git) C · 303 lines
94 // originally from quake3 code
96 float Q_rsqrt( float number )
97 {
116 void vectorcopy(float *vector1, float *vector2);
117 float atan2approx(float y, float x);
133 void vectorcopy(float *vector1, float *vector2)
134 {
135 for (int axis = 0; axis < 3; axis++)
282 // +-0.09 deg error
283 float atan2approx(float y, float x)
284 {
imu.c (https://github.com/silver13/Eachine-E011.git) C · 213 lines
XMath.h (https://github.com/ylmbtm/GameProject3.git) C Header · 514 lines
11 // float Q_rsqrt( float number )
12 // {
13 // long i;
34 Vector2D(float _x = 0.0f, float _y = 0.0f )
35 {
36 m_x = _x;
211 FLOAT m_Left, m_Top, m_Bottom, m_Right;
212 Rect2D(float _left, float _top, float _right, float _bottom)
213 {
214 m_Left = _left;
243 Vector3D(): m_x(0), m_y(0), m_z(0) {}
245 Vector3D(float x1, float y1, float z1): m_x(x1), m_y(y1), m_z(z1) {}
247 Vector3D(const Vector3D& v): m_x(v.m_x), m_y(v.m_y), m_z(v.m_z) {}
Sqrt(x).java (https://github.com/cherryljr/LintCode.git) Java · 94 lines
78 // Magic Number 0x5f3759df !!! So Amazing
79 // 雷神之锤3 源码
80 float Q_rsqrt(float number) {
81 long i;
82 float x2, y;
83 const float threehalfs = 1.5F;
85 x2 = number * 0.5F;
86 y = number;
87 i = * ( long * ) &y; // evil floating point bit level hacking
88 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
89 y = * ( float * ) &i;
rsqrt_carmack.h (https://bitbucket.org/rayburgemeestre/sqrtvis) C Header · 109 lines
Attraction.h (https://github.com/bloomtime/CinderTraer.git) C Header · 51 lines
14 Particle* a;
15 Particle* b;
16 float k;
17 bool on;
18 float distanceMin;
19 float distanceMinSquared;
21 Attraction( Particle* a, Particle* b, float k, float distanceMin );
23 float getMinimumDistance();
45 private:
46 // http://en.wikipedia.org/wiki/Fast_inverse_square_root
47 float Q_rsqrt( float number );
49 };
Math.hpp (https://github.com/kondrak/oculusvr_samples.git) C++ Header · 208 lines
72 }
74 Vector4f(float x, float y, float z, float w) : m_x(x), m_y(y), m_z(z), m_w(w)
75 {
76 }
159 // create based on standard parameters
160 Quaternion(float x, float y, float z, float w) : m_x(x), m_y(y), m_z(z), m_w(w)
161 {
162 }
202 // determine whether a point is in front of or behind a plane (based on its normal vector)
203 int PointPlanePos(float normalX, float normalY, float normalZ, float intercept, const Math::Vector3f &point);
205 void Translate(Matrix4f &matrix, float x, float y=0.0f, float z=0.0f);
cv_neon_mathfun.h (https://github.com/dingjikerbo/Android-Boost.git) C Header · 63 lines
37 sincos_ps..
38 */
39 void sincos_ps(float32x4_t x,float32x4_t *ysin,float32x4_t *ycos);
41 float32x4_t sin_ps(float32x4_t x);
52 float32x4_t inv_sqrt_float32x4( float32x4_t xx );
54 float32x4_t q_rsqrt_float32x4( float32x4_t xx);
56 float32x4_t atanf_cephes(float32x4_t xx);
58 float32x4_t atan2f_cephes(float32x4_t y,float32x4_t x);
59 }
60 #endif // __ARM_NEON__
stickvector.c (https://github.com/silver13/BoldClash-BWHOOP-B-03.git) C · 161 lines
9 extern float GEstG[3];
10 extern float Q_rsqrt( float number );
11 extern char aux[];
13 // error vector between stick position and quad orientation
14 // this is the output of this function
15 float errorvect[3];
16 // cache the last result so it does not get calculated everytime
17 float last_rx[2] = {13.13f , 12.12f};
18 float stickvector[3] = { 0 , 0 , 1};
23 void stick_vector( float rx_input[] , float maxangle)
24 {
25 // only compute stick rotation if values changed
modelo_ciclo_vida.tex (https://github.com/fga-eps-mds/A-Disciplina.git) LaTeX · 216 lines
24 \end{itemize}
25 \begin{lstlisting}
26 float Q_rsqrt( float number)
27 {
28 int i;
29 float x2, y;
30 const float threehalfs = 1.5F;
31 x2 = number * 0.5F;
32 y = number;
33 i = * ( int * ) &y; // evil floating point bit level hacking
34 i = 0x5f3759df - ( i >> 1 ); // what the f***?
35 y = * ( float * ) &i;
volk_32f_invsqrt_32f.h (https://github.com/boiledfrog/gnuradio.git) C Header · 174 lines
7 #include <string.h>
9 static inline float Q_rsqrt( float number )
10 {
11 float x2;
99 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
100 */
101 static inline void volk_32f_invsqrt_32f_neon(float* cVector, const float* aVector, unsigned int num_points){
102 unsigned int number;
103 const unsigned int quarter_points = num_points / 4;
129 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
130 */
131 static inline void volk_32f_invsqrt_32f_generic(float* cVector, const float* aVector, unsigned int num_points){
132 float* cPtr = cVector;
147 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
148 */
149 static inline void volk_32f_invsqrt_32f_u_avx(float* cVector, const float* aVector, unsigned int num_points){
150 unsigned int number = 0;
151 const unsigned int eighthPoints = num_points / 8;
Attraction.cpp (https://github.com/bloomtime/CinderTraer.git) C++ · 119 lines
cv_c_mathfun.h (https://github.com/dingjikerbo/Android-Boost.git) C Header · 43 lines
trickmath.h (https://github.com/AlbertVeli/Carnival.git) C Header · 72 lines
volk_32f_invsqrt_32f.h (https://github.com/trondeau/gnuradio-old.git) C Header · 143 lines
7 #include <string.h>
9 static inline float Q_rsqrt( float number )
10 {
11 float x2;
64 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
65 */
66 static inline void volk_32f_invsqrt_32f_a_sse(float* cVector, const float* aVector, unsigned int num_points){
67 unsigned int number = 0;
68 const unsigned int quarterPoints = num_points / 4;
116 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
117 */
118 static inline void volk_32f_invsqrt_32f_u_avx(float* cVector, const float* aVector, unsigned int num_points){
119 unsigned int number = 0;
120 const unsigned int eighthPoints = num_points / 8;
volk_32f_invsqrt_32f.h (https://github.com/balister/GNU-Radio.git) C Header · 77 lines
6 #include <math.h>
8 static inline float Q_rsqrt( float number )
9 {
10 long i;
14 x2 = number * 0.5F;
15 y = number;
16 i = * ( long * ) &y; // evil floating point bit level hacking
17 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
18 y = * ( float * ) &i;
31 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
32 */
33 static inline void volk_32f_invsqrt_32f_a_sse(float* cVector, const float* aVector, unsigned int num_points){
34 unsigned int number = 0;
35 const unsigned int quarterPoints = num_points / 4;
65 \param num_points The number of values in aVector and bVector to be invsqrted together and stored into cVector
66 */
67 static inline void volk_32f_invsqrt_32f_generic(float* cVector, const float* aVector, unsigned int num_points){
68 float* cPtr = cVector;
stickvector.c (https://github.com/silver13/Eachine-E011.git) C · 73 lines
9 extern float GEstG[3];
10 extern float Q_rsqrt( float number );
12 // error vector between stick position and quad orientation
13 // this is the output of this function
14 float errorvect[3];
15 // cache the last result so it does not get calculated everytime
16 float last_rx[2] = {13.13f , 12.12f};
17 float stickvector[3] = { 0 , 0 , 1};
22 void stick_vector( float rx_input[] , float maxangle)
23 {
24 // only compute stick rotation if values changed
q_math.c (https://github.com/xzero450/revolution.git) C · 1477 lines
447 }
449 unsigned ColorBytes4 (float r, float g, float b, float a) {
450 unsigned i;
718 #if !idppc
719 /*
720 ** float q_rsqrt( float number )
721 */
722 float Q_rsqrt( float number )
757 ===============
758 */
759 float LerpAngle (float from, float to, float frac) {
760 float a;
841 =================
842 */
843 float AngleDelta ( float angle1, float angle2 ) {
844 return AngleNormalize180( angle1 - angle2 );
845 }
Neo-Library-Mathmatics.ads (https://github.com/AdaDoom3/AdaDoom3.git) Ada · 205 lines
148 static int BitReverse( int x ); -- returns the bit reverse of x
149 static int Abs( int x ); -- returns the absolute value of the integer value (for reference only)
150 static float Fabs( float f ); -- returns the absolute value of the floating point value
151 static float Floor( float f ); -- returns the largest integer that is less than or equal to the given value
161 static signed short ClampShort( int i );
162 static int ClampInt( int min, int max, int value );
163 static float ClampFloat( float min, float max, float value );
164 static float AngleNormalize360( float angle );
165 static float AngleNormalize180( float angle );
166 static float AngleDelta( float angle1, float angle2 );
167 static int FloatToBits( float f, int exponentBits, int mantissaBits );
169 static int FloatHash( const float *array, const int numFloats );
170 static float LerpToWithScale( const float cur, const float dest, const float scale );
171 -------
172 private
q_rsqrt.h (https://github.com/DingSoung/DSP.git) C++ Header · 20 lines
1 #ifndef q_rsqrt_H
2 #define q_rsqrt_H
4 //wiki http://en.wikipedia.org/wiki/Fast_inverse_square_root
6 static float q_rsqrt(float number) {
7 long i;
8 float x2, y;
9 const float threehalfs = 1.5F;
11 x2 = number * 0.5F;
12 y = number;
13 i = *(long *)&y;// evil floating point bit level hacking(对浮点数的邪恶位级hack)
14 i = 0x5f3759df - (i >> 1);// what the fuck?(这他妈的是怎么回事?)
15 y = *(float *)&i;
Q_rsqrt_test.c (https://github.com/Necropolis/Q_rsqrt.git) C · 158 lines
7 #include <getopt.h>
9 float Q_rsqrt( float number );
11 uint64_t r;
57 fBegin = (float)atof(optarg);
58 else if(option_index == arg_fStep)
59 fStep = (float)atof(optarg);
60 else if(option_index == arg_fEnd)
61 fEnd = (float)atof(optarg);
143 ** float q_rsqrt( float number )
144 */
145 float Q_rsqrt( float number ) {
146 long i;
147 float x2, y;
Vector3d.h (https://github.com/KonstantinChizhov/Mcucpp.git) C Header · 215 lines
fisr.c (https://github.com/mwhooker/syntax.git) C · 18 lines
1 // The following code is the fast inverse square root implementation from Quake III Arena, stripped of C preprocessor directives, but including the exact original comment text:[9]
3 float Q_rsqrt( float number )
4 {
5 long i;
6 float x2, y;
7 const float threehalfs = 1.5F;
9 x2 = number * 0.5F;
10 y = number;
11 i = * ( long * ) &y; // evil floating point bit level hacking
12 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
13 y = * ( float * ) &i;
Main.h (https://github.com/Andos/Flocking.git) C Header · 166 lines
146 long FixedValue( LPRO object );
147 LPRO LPROFromFixed( LPRDATA rdPtr, long fixedvalue );
148 long returnFloat(LPRDATA rdPtr, float value);
150 /*
154 void DebugObject(Boid boid);
155 */
156 float RotateTowards(float angle, float targetAngle, float speed);
157 float ToRadians(float degrees);
158 float ToDegrees(float radians);
160 int packFloat(float value);
161 void LoopNeighbourBoids(LPRDATA rdPtr, char* loopname, Boid boid, int radius);
164 float clamp(float val, float min, float max);
166 float Q_rsqrt( float number );
fast_inv_sqrt.h (https://github.com/andrewcyu/Algorithm-Implementations.git) C++ Header · 5 lines
fast_inv_sqrt.c (https://github.com/cptjazz/rheo.git) C · 17 lines
1 // __expected:Q_rsqrt(number => $_retval)
2 float Q_rsqrt( float number )
3 {
4 long i;
5 float x2, y;
6 const float threehalfs = 1.5F;
8 x2 = number * 0.5F;
9 y = number;
10 i = * ( long * ) &y; // evil floating point bit level hacking
11 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
12 y = * ( float * ) &i;
carmack.c (https://github.com/seydar/icling.git) C · 17 lines
2 * PURPOSE: IEEE sqrt trickery
3 */
4 float Q_rsqrt( float number ) {
5 long i;
6 float x2, y;
7 const float threehalfs = 1.5F;
9 x2 = number * 0.5F;
10 y = number;
11 i = * ( long * ) &y; // evil floating point bit level hacking
12 i = 0x5f3759df - ( i >> 1 ); // what the fuck?
13 y = * ( float * ) &i;