• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref gtx_spline
2/// @file glm/gtx/spline.inl
3
4namespace glm
5{
6	template <typename genType>
7	GLM_FUNC_QUALIFIER genType catmullRom
8	(
9		genType const & v1,
10		genType const & v2,
11		genType const & v3,
12		genType const & v4,
13		typename genType::value_type const & s
14	)
15	{
16		typename genType::value_type s1 = s;
17		typename genType::value_type s2 = pow2(s);
18		typename genType::value_type s3 = pow3(s);
19
20		typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s;
21		typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2);
22		typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s;
23		typename genType::value_type f4 = s3 - s2;
24
25		return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2);
26
27	}
28
29	template <typename genType>
30	GLM_FUNC_QUALIFIER genType hermite
31	(
32		genType const & v1,
33		genType const & t1,
34		genType const & v2,
35		genType const & t2,
36		typename genType::value_type const & s
37	)
38	{
39		typename genType::value_type s1 = s;
40		typename genType::value_type s2 = pow2(s);
41		typename genType::value_type s3 = pow3(s);
42
43		typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1);
44		typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2;
45		typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s;
46		typename genType::value_type f4 = s3 - s2;
47
48		return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2;
49	}
50
51	template <typename genType>
52	GLM_FUNC_QUALIFIER genType cubic
53	(
54		genType const & v1,
55		genType const & v2,
56		genType const & v3,
57		genType const & v4,
58		typename genType::value_type const & s
59	)
60	{
61		return ((v1 * s + v2) * s + v3) * s + v4;
62	}
63}//namespace glm
64