Exemple #1
0
float vector3::AngleBetweenVectors(const vector3& v0, const vector3& v1)
{
	float d = v0.Dot(v1);
	if ( d >= -1.f && d <= 1.f )
	{
		return acosf( d / ( v0.Length() * v1.Length() ) );
	}

	return 0.f;
}
		BOHGE_FORCEINLINE void RotateAxis(const vector3<T>& axis, T r )
		{
			//T sa, ca;
			//Math::SinCos(r * T(0.5), sa, ca);
			T sc[2];
			Math::SinCos( r * T(0.5), sc );
			if ( Math::isEqual( axis.Length(), T(0.0) ) )
			{
				m_x = sc[0];
				m_y = sc[0];
				m_z = sc[0];
				m_w = sc[1];
			}
			else
			{
				vector3<T> temp = axis;
				temp.NormalizeSelf();
				temp *= sc[0];
				//*this = Quaternion<T>( temp * sc[0], sc[1] );
				m_x = temp.m_x;
				m_y = temp.m_y;
				m_z = temp.m_z;
				m_w = sc[1];
			}
		}
Exemple #3
0
vector3 vector3::Normalize(const vector3& source)
{
	float len = 1.f / source.Length();
	return source * len;
}