Browse Source

Updated constants list

Christophe Riccio 14 years ago
parent
commit
a3b5034d4e
2 changed files with 59 additions and 4 deletions
  1. 26 1
      glm/gtx/constants.hpp
  2. 33 3
      glm/gtx/constants.inl

+ 26 - 1
glm/gtx/constants.hpp

@@ -58,6 +58,16 @@ namespace glm
 	template <typename T>
 	T epsilon();
 
+	/// Return 0.
+	/// @see gtx_constants
+	template <typename T>
+	T zero();
+
+	/// Return 1.
+	/// @see gtx_constants
+	template <typename T>
+	T one();
+
 	/// Return the pi constant.
 	/// @see gtx_constants
 	template <typename T>
@@ -128,6 +138,16 @@ namespace glm
 	template <typename T>
 	T root_two();
 
+	/// Return sqrt(3).
+	/// @see gtx_constants
+	template <typename T>
+	T root_three();
+
+	/// Return sqrt(5).
+	/// @see gtx_constants
+	template <typename T>
+	T root_five();
+
 	/// Return ln(2).
 	/// @see gtx_constants
 	template <typename T>
@@ -151,7 +171,12 @@ namespace glm
 	/// Return 2 / 3.
 	/// @see gtx_constants
 	template <typename T>
-	T twothirds();
+	T two_thirds();
+
+	/// Return the golden ratio constant.
+	/// @see gtx_constants
+	template <typename T>
+	T golden_ratio();
 
 	/// @}
 } //namespace glm

+ 33 - 3
glm/gtx/constants.inl

@@ -34,6 +34,18 @@ namespace glm
 		return std::numeric_limits<T>::epsilon();
 	}
 
+	template <typename T>
+	GLM_FUNC_QUALIFIER T zero()
+	{
+		return T(0);
+	}
+
+	template <typename T>
+	GLM_FUNC_QUALIFIER T one()
+	{
+		return T(1);
+	}
+
 	template <typename T>
 	GLM_FUNC_QUALIFIER T pi()
 	{
@@ -118,6 +130,18 @@ namespace glm
 		return T(1.41421356237309504880168872420969808);
 	}
 
+	template <typename T>
+	GLM_FUNC_QUALIFIER T root_three()
+	{
+		return T(1.73205080756887729352744634150587236);
+	}
+
+	template <typename T>
+	GLM_FUNC_QUALIFIER T root_five()
+	{
+		return T(2.23606797749978969640917366873127623);
+	}
+
 	template <typename T>
 	GLM_FUNC_QUALIFIER T ln_two()
 	{
@@ -139,12 +163,18 @@ namespace glm
 	template <typename T>
 	GLM_FUNC_QUALIFIER T third()
 	{
-		return T(0.333333333333333333);
+		return T(0.3333333333333333333333333333333333333333);
+	}
+
+	template <typename T>
+	GLM_FUNC_QUALIFIER T two_thirds()
+	{
+		return T(0.666666666666666666666666666666666666667);
 	}
 
 	template <typename T>
-	GLM_FUNC_QUALIFIER T twothirds()
+	GLM_FUNC_QUALIFIER T golden_ratio()
 	{
-		return T(0.666666666666666667);
+		return T(1.61803398874989484820458683436563811);
 	}
 } //namespace glm