*** empty log message ***

This commit is contained in:
jiri
2020-01-12 08:55:26 +00:00
parent 2dd7737825
commit 23d53f9a34
4 changed files with 37 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
/*
LA: linear algebra C++ interface library
Copyright (C) 2008-2020 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
Copyright (C) 2020 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,33 @@
using namespace LA_Vecmat3;
//http://en.wikipedia.org/wiki/Fast_inverse_square_root
float LA_Vecmat3::fast_sqrtinv(float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
template<>
Vec3<float> & Vec3<float>::fast_normalize(void) {*this *= fast_sqrtinv(normsqr()); return *this;};
template<typename T>
Vec3<T>& Vec3<T>::fast_normalize(void) {normalize(); return *this;};
template<typename T>
const Vec3<T> Vec3<T>::operator*(const Mat3<T> &rhs) const
{