mirror of
https://github.com/g-truc/glm.git
synced 2024-11-16 23:04:35 +00:00
Merge the two Triangle Normal flavors into one code sample
This commit is contained in:
parent
ea91a4d0bc
commit
8f0bcb50c4
24
doc/glm.tex
24
doc/glm.tex
@ -1302,36 +1302,22 @@ Such behavior follows the precedent set by C and C++'s standard library, in that
|
|||||||
|
|
||||||
\begin{cppcode}
|
\begin{cppcode}
|
||||||
#include <glm/glm.hpp> // vec3 normalize cross
|
#include <glm/glm.hpp> // vec3 normalize cross
|
||||||
|
#include <glm/gtx/fast_square_root.hpp> // fastNormalize
|
||||||
|
|
||||||
glm::vec3 computeNormal
|
using glm::vec3;
|
||||||
(
|
|
||||||
glm::vec3 const & a,
|
vec3 triNormal(vec3 const & a, vec3 const & b, vec3 const & c)
|
||||||
glm::vec3 const & b,
|
|
||||||
glm::vec3 const & c
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return glm::normalize(glm::cross(c - a, b - a));
|
return glm::normalize(glm::cross(c - a, b - a));
|
||||||
}
|
}
|
||||||
\end{cppcode}
|
|
||||||
|
|
||||||
\begin{cppcode}
|
|
||||||
// A faster (but less accurate) alternative:
|
// A faster (but less accurate) alternative:
|
||||||
#include <glm/glm.hpp> // vec3 cross
|
vec3 fastTriNormal(vec3 const & a, vec3 const & b, vec3 const & c)
|
||||||
#include <glm/gtx/fast_square_root.hpp> // fastNormalize
|
|
||||||
|
|
||||||
glm::vec3 computeNormal
|
|
||||||
(
|
|
||||||
glm::vec3 const & a,
|
|
||||||
glm::vec3 const & b,
|
|
||||||
glm::vec3 const & c
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return glm::fastNormalize(glm::cross(c - a, b - a));
|
return glm::fastNormalize(glm::cross(c - a, b - a));
|
||||||
}
|
}
|
||||||
\end{cppcode}
|
\end{cppcode}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\subsection{Matrix Transformations}
|
\subsection{Matrix Transformations}
|
||||||
|
|
||||||
\begin{cppcode}
|
\begin{cppcode}
|
||||||
|
Loading…
Reference in New Issue
Block a user