• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1///////////////////////////////////////////////////////////////////////////////////////////////////
2// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
3///////////////////////////////////////////////////////////////////////////////////////////////////
4// Created : 2007-01-25
5// Updated : 2009-02-19
6// Licence : This source is under MIT License
7// File    : glm/gtx/spline.inl
8///////////////////////////////////////////////////////////////////////////////////////////////////
9
10namespace glm{
11
12template <typename genType>
13GLM_FUNC_QUALIFIER genType catmullRom
14(
15	genType const & v1,
16	genType const & v2,
17	genType const & v3,
18	genType const & v4,
19	typename genType::value_type const & s
20)
21{
22	typename genType::value_type s1 = s;
23	typename genType::value_type s2 = pow2(s);
24	typename genType::value_type s3 = pow3(s);
25
26	typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s;
27	typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2);
28	typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s;
29	typename genType::value_type f4 = s3 - s2;
30
31	return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2);
32
33}
34
35template <typename genType>
36GLM_FUNC_QUALIFIER genType hermite
37(
38	genType const & v1,
39	genType const & t1,
40	genType const & v2,
41	genType const & t2,
42	typename genType::value_type const & s
43)
44{
45	typename genType::value_type s1 = s;
46	typename genType::value_type s2 = pow2(s);
47	typename genType::value_type s3 = pow3(s);
48
49	typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1);
50	typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2;
51	typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s;
52	typename genType::value_type f4 = s3 - s2;
53
54	return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2;
55}
56
57template <typename genType>
58GLM_FUNC_QUALIFIER genType cubic
59(
60	genType const & v1,
61	genType const & v2,
62	genType const & v3,
63	genType const & v4,
64	typename genType::value_type const & s
65)
66{
67	return ((v1 * s + v2) * s + v3) * s + v4;
68}
69
70}//namespace glm
71