SlideShare a Scribd company logo
1 of 32
Mobile Game Programming:
Hermite Spline
jintaeks@dongseo.ac.kr
Division of Digital Contents, DongSeo University.
October 2016
Type of functions
Explicit function
y=
2
𝑅2 − 𝑥2 or y=-
2
𝑅2 − 𝑥2
Implicit function
x2+y2=R2
Parametric representation
x=Rcosθ, y=Rsinθ (0≤ θ < 2π)
2
Order of continuity
 The various order of parametric continuity can be described
as follows:[5]
 C−1: curves include discontinuities
 C0: curves are joined
 C1: first derivatives are continuous
 C2: first and second derivatives are continuous
 Cn: first through nth derivatives are continuous
3
Spline
 In mathematics, a spline is a
numeric function that is piecewise-defined
by polynomial functions.
– A flexible device which can be bent to the
desired shape is known as a flat spline.
 In interpolation problems, spline
interpolation is often preferred
to polynomial interpolation because it
yields similar results to interpolating with
higher degree polynomials while avoiding
instability.
 The most commonly used splines
are cubic splines.
4
Ex) Quadratic spline
5
Ex) Cubic spline
6
Definition of spline
 A spline is a piecewise-polynomial real function
S:[a,b]  R
 on an interval [a,b] composed of k subintervals [ti-1,ti] with
a=t0<t1< … <tk-1<tk=b.
 The restriction of S to an interval i is a polynomial
Pi:[ti-1,ti]R,
 so that
S(t)=P1(t), t0<= t <= t1,
S(t)=P2(t), t1<= t <= t2,
…
S(t)=Pk(t), tk-1<= t <= tk,
 The highest order of the polynomials Pi(t) is said to be
the order of the spline S.
7
Cubic spline
 In numerical analysis, a cubic spline is a spline where each
piece is a third-degree polynomial.
 A cubic Hermite spline Specified by its values and
first derivatives at the end points of the
corresponding domain interval.
8
Unit interval (0,1)
 On the interval (0,1), given a starting point p0 at t = 0 and an
ending point p1 at t = 1 with starting tangent m0 at t = 0 and
ending tangent m1 at t = 1, the polynomial can be defined by
 where t ∈ [0,1].
9
 a point Q(t) on a curve at parameter t can be defined a cubic
equations for each value:
Q(t)=
𝑥(𝑡)
𝑦(𝑡)
=
𝑎 𝑥 𝑡3 + 𝑏𝑥𝑡2 + 𝑐𝑥𝑡 + 𝑑𝑦
𝑎 𝑦 𝑡3 + 𝑏𝑦𝑡2 + 𝑐𝑦𝑡 + 𝑑𝑦
 We can define coefficient matrix C and parameter matrix T,
then Q(t) can be defined like this:
T=
𝑡3
𝑡2
𝑡
1
C=
𝑎 𝑥 𝑏 𝑥 𝑐 𝑥 𝑑 𝑥
𝑎 𝑦 𝑏 𝑦 𝑐 𝑦 𝑑 𝑦
Q(t)=
𝑥(𝑡)
𝑦(𝑡)
=𝐶‧𝑇
10
 We will decompose C with 2×4 Geometry Matrix G and 4×4
Basis Matrix M.
C=G‧M
Q(t)=
𝑥(𝑡)
𝑦(𝑡)
=𝑪‧𝑇 = 𝐺‧M‧T
=
𝑔1𝑥 𝑔2𝑥
𝑔3𝑥 𝑔4𝑥
𝑔1𝑦 𝑔2𝑦
𝑔3𝑦 𝑔4𝑦
𝑚11 𝑚12 𝑚13 𝑚14
𝑚21 𝑚22 𝑚23 𝑚24
𝑚31 𝑚32 𝑚33 𝑚34
𝑚41 𝑚42 𝑚43 𝑚44
𝑡3
𝑡2
𝑡
1
11
Geometry matrix G
 has an information about control data.
 in case of Hermite spline, it has two points and tangent
vectors for each point.
– P1, P2, R1, R2
Base matrix M
 a coefficient matrix for the blending functions.
 blending function means M‧T.
 the summation of all blending functions is 1.
– it means that spline curve calculates the weighted average for control
points.
12
Hermite Spline
 Specified by its values and first derivatives at the end points
of the corresponding domain interval
Geometry matrix G
G=
𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥
𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦
13
Find Base matrix M
 Four conditions to find Base matrix M.
 Begin point is (P1x, P1y), and End point is (P4x, P4y).
Q(0)=
𝑃1𝑥
𝑃1𝑦
Q(1)=
𝑃4𝑥
𝑃4𝑦
 Derivative at Begin point is (R1x, R1y), and derivative at End
point is (R4x, R4y).
Q'(0)=
𝑅1𝑥
𝑅1𝑦
Q'(1)=
𝑅4𝑥
𝑅4𝑦
14
for two end points
 Q(0)=
𝑃1𝑥
𝑃1𝑦
= 𝐺‧M‧T
=
𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥
𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦
𝑚11 𝑚12 𝑚13 𝑚14
𝑚21 𝑚22 𝑚23 𝑚24
𝑚31 𝑚32 𝑚33 𝑚34
𝑚41 𝑚42 𝑚43 𝑚44
𝑡3
𝑡2
𝑡
1
=𝐺‧M
0
0
0
1
 Q(1)=
𝑃4𝑥
𝑃4𝑦
= 𝐺‧M
1
1
1
1
15
for two tangent vector
 Q'(0)=
𝑅1𝑥
𝑅1𝑦
= 𝐺‧M‧T′
=
𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥
𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦
𝑚11 𝑚12 𝑚13 𝑚14
𝑚21 𝑚22 𝑚23 𝑚24
𝑚31 𝑚32 𝑚33 𝑚34
𝑚41 𝑚42 𝑚43 𝑚44
3𝑡2
2𝑡
1
0
=𝐺‧M
0
0
1
0
 Q'(1)=
𝑅4𝑥
𝑅4𝑦
= 𝐺‧M
3
2
1
0
16
Base matrix M

𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥
𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦
= 𝐺 = 𝐺‧𝑀
0 1 0 3
0 1 0 2
0 1 1 1
1 1 0 0
= 𝐺‧𝑀‧𝑀-1
0 1 0 3
0 1 0 2
0 1 1 1
1 1 0 0
=M-1
 M=
2 −3 0 1
−2 3 0 0
1 −2 1 0
1 −1 0 0
17
Blending function
 Q(t)=
𝑥(𝑡)
𝑦(𝑡)
= 𝐺‧M‧T = 𝐺‧𝐵
=(2t3−3t2+1)
𝑃1𝑥
𝑃1𝑦
+(-2t3+3t2)
𝑃4𝑥
𝑃4𝑦
+(t3-2t2+1)
𝑅1𝑥
𝑅1𝑦
+(t3-t2)
𝑅4𝑥
𝑅4𝑦
.
18
2 −3 0 1
−2 3 0 0
1 −2 1 0
1 −1 0 0
𝑡3
𝑡2
𝑡1
0
Meaning of tangent vector R
19
P1 P4
R4
R1
Implement Hermite Spline
class KHermiteCurve
{
public:
float m_a;
float m_b;
float m_c;
float m_d;
20
class KHermiteCurve
{
public:
/// constructor.
/// @param p1: begin point
/// @param p2: end point
/// @param v1: tangent vector at begin point
/// @param v2: tangent vector at end point
KHermiteCurve(float p1, float p2, float v1, float v2)
{
m_d = p1;
m_c = v1;
m_b = -3.0f*p1 + 3.0f*p2 - 2.0f*v1 - v2;
m_a = 2.0f*p1 - 2.0f*p2 + v1 + v2;
}//KHermiteCurve()
21
/// set coefficient of Hermite curve
inline void Construct(float p1, float p2, float v1, float v2)
{
m_d = p1;
m_c = v1;
m_b = -3.0f*p1 + 3.0f*p2 - 2.0f*v1 - v2;
m_a = 2.0f*p1 - 2.0f*p2 + v1 + v2;
}//Construct()
/// calculate first derivative on parameter u.
/// can be used to get tangent vector at u.
/// derivative of equation t^3 + t^2 + t + 1
inline float CalculateDxDu(float u) const
{
return 3.0f*m_a*u*u + 2.0f*m_b*u + m_c;
}//CalculateDxDu()
22
/// get value at parameter u.
inline float CalculateX(float u) const
{
float uu, uuu;
uu = u * u;
uuu = uu * u;
return m_a*uuu + m_b*uu + m_c*u + m_d;
}//CalculateX()
23
KHermiteSpline2
class KHermiteSpline2
{
private:
KHermiteCurve m_aHermiteCurve[2];
public:
/// constructor.
KHermiteSpline2(){}
KHermiteSpline2( const KVector& p0, const KVector& p1, const KVector& dp0, const
KVector& dp1 )
{
m_aHermiteCurve[ 0 ].Construct( p0.m_x, p1.m_x, dp0.m_x, dp1.m_x );
m_aHermiteCurve[ 1 ].Construct( p0.m_y, p1.m_y, dp0.m_y, dp1.m_y );
}//KHermiteSpline2()
24
inline void Construct( const KVector& p0, const KVector& p1, const KVector& dp0,
const KVector& dp1 )
{
m_aHermiteCurve[ 0 ].Construct( p0.m_x, p1.m_x, dp0.m_x, dp1.m_x );
m_aHermiteCurve[ 1 ].Construct( p0.m_y, p1.m_y, dp0.m_y, dp1.m_y );
}//Construct()
25
inline const KVector GetPosition( float u_ ) const
{
return KVector( m_aHermiteCurve[ 0 ].CalculateX( u_ ), m_aHermiteCurve[ 1
].CalculateX( u_ ), 0.f );
}//GetPosition()
inline const KVector GetTangent( float u_ ) const
{
return KVector( m_aHermiteCurve[ 0 ].CalculateDxDu( u_ ), m_aHermiteCurve[ 1
].CalculateDxDu( u_ ), 0.f );
}//GetTangent()
26
Draw a tangent line at u
const float u = 0.5f;
KVector position = spline.GetPosition(u);
KVector tangent = spline.GetTangent(u);
DrawLine(hdc, position, position + tangent * 100.f);
27
Combine Splines
28
Line in 3D space
 Given two 3D points P1 and P2, we can define the line that
passes through these points parametrically as
P(t ) = (1− t )P1 + tP2
 A ray is a line having a single endpoint S and extending to
infinity in a given direction V. Rays are typically expressed by
the parametric equation
P(t ) = S + tV
 Note that this equation is equivalent to previous equation if
we let S = P1 and V = P2 − P1.
29
Distance between a point and a line
30
Spline path tracing demo
31
Hermite spline english_20161201_jintaeks

More Related Content

What's hot

Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devicesMani Kanth
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarsyedArr
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfacesAnkur Kumar
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Computer graphics(parametric cubic curves)
Computer graphics(parametric cubic curves)Computer graphics(parametric cubic curves)
Computer graphics(parametric cubic curves)Sinthia Sarker
 
Overview of the graphics system
Overview of the graphics systemOverview of the graphics system
Overview of the graphics systemKamal Acharya
 
Singular Value Decompostion (SVD): Worked example 2
Singular Value Decompostion (SVD): Worked example 2Singular Value Decompostion (SVD): Worked example 2
Singular Value Decompostion (SVD): Worked example 2Isaac Yowetu
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
2d-transformation
2d-transformation2d-transformation
2d-transformationPooja Dixit
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Mani Kanth
 
Geometric transformation
Geometric transformationGeometric transformation
Geometric transformationDhruv Shah
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination modelAnkit Garg
 
Fuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clusteringFuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clusteringFarah M. Altufaili
 
Introduction to computer graphics part 2
Introduction to computer graphics part 2Introduction to computer graphics part 2
Introduction to computer graphics part 2Ankit Garg
 

What's hot (20)

Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 
Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devices
 
Projection
ProjectionProjection
Projection
 
illumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukarillumination model in Computer Graphics by irru pychukar
illumination model in Computer Graphics by irru pychukar
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Bezier curve computer graphics
Bezier curve computer graphics Bezier curve computer graphics
Bezier curve computer graphics
 
Computer graphics(parametric cubic curves)
Computer graphics(parametric cubic curves)Computer graphics(parametric cubic curves)
Computer graphics(parametric cubic curves)
 
Overview of the graphics system
Overview of the graphics systemOverview of the graphics system
Overview of the graphics system
 
Singular Value Decompostion (SVD): Worked example 2
Singular Value Decompostion (SVD): Worked example 2Singular Value Decompostion (SVD): Worked example 2
Singular Value Decompostion (SVD): Worked example 2
 
Spline representations
Spline representationsSpline representations
Spline representations
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
2d-transformation
2d-transformation2d-transformation
2d-transformation
 
Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...Window to viewport transformation&amp;matrix representation of homogeneous co...
Window to viewport transformation&amp;matrix representation of homogeneous co...
 
Geometric transformation
Geometric transformationGeometric transformation
Geometric transformation
 
Character generation
Character generationCharacter generation
Character generation
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
 
Fuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clusteringFuzzy image processing- fuzzy C-mean clustering
Fuzzy image processing- fuzzy C-mean clustering
 
Introduction to computer graphics part 2
Introduction to computer graphics part 2Introduction to computer graphics part 2
Introduction to computer graphics part 2
 
Computer graphics realism
Computer graphics realismComputer graphics realism
Computer graphics realism
 

Viewers also liked (10)

Analytical chemistry_Instrumentation_Introduction
Analytical chemistry_Instrumentation_IntroductionAnalytical chemistry_Instrumentation_Introduction
Analytical chemistry_Instrumentation_Introduction
 
[Download] rev chapter-5-june26th
[Download] rev chapter-5-june26th[Download] rev chapter-5-june26th
[Download] rev chapter-5-june26th
 
Presentation non parametric
Presentation non parametricPresentation non parametric
Presentation non parametric
 
Parametric equations
Parametric equationsParametric equations
Parametric equations
 
hermite cubic spline curve
hermite cubic spline curvehermite cubic spline curve
hermite cubic spline curve
 
Perspective projection
Perspective projectionPerspective projection
Perspective projection
 
Dda line-algorithm
Dda line-algorithmDda line-algorithm
Dda line-algorithm
 
Presentation on bezier curve
Presentation on bezier curvePresentation on bezier curve
Presentation on bezier curve
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Non parametric tests
Non parametric testsNon parametric tests
Non parametric tests
 

Similar to Hermite spline english_20161201_jintaeks

Tucker tensor analysis of Matern functions in spatial statistics
Tucker tensor analysis of Matern functions in spatial statistics Tucker tensor analysis of Matern functions in spatial statistics
Tucker tensor analysis of Matern functions in spatial statistics Alexander Litvinenko
 
Litvinenko low-rank kriging +FFT poster
Litvinenko low-rank kriging +FFT  posterLitvinenko low-rank kriging +FFT  poster
Litvinenko low-rank kriging +FFT posterAlexander Litvinenko
 
Designing Parametric cubic Curves
Designing Parametric cubic CurvesDesigning Parametric cubic Curves
Designing Parametric cubic CurvesSyed Zaid Irshad
 
Hull White model presentation
Hull White model presentationHull White model presentation
Hull White model presentationStephan Chang
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Alexander Litvinenko
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1luisescobedo38
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Alexander Litvinenko
 
New data structures and algorithms for \\post-processing large data sets and ...
New data structures and algorithms for \\post-processing large data sets and ...New data structures and algorithms for \\post-processing large data sets and ...
New data structures and algorithms for \\post-processing large data sets and ...Alexander Litvinenko
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functionsTarun Gehlot
 
Tp problèmes-à-valeurs-initiales
Tp problèmes-à-valeurs-initialesTp problèmes-à-valeurs-initiales
Tp problèmes-à-valeurs-initialespapillontuba
 
Digital Signal Processing
Digital Signal ProcessingDigital Signal Processing
Digital Signal Processingaj ahmed
 
Csm chapters12
Csm chapters12Csm chapters12
Csm chapters12Pamela Paz
 
K-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codeK-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codegokulprasath06
 

Similar to Hermite spline english_20161201_jintaeks (20)

E33018021
E33018021E33018021
E33018021
 
Tucker tensor analysis of Matern functions in spatial statistics
Tucker tensor analysis of Matern functions in spatial statistics Tucker tensor analysis of Matern functions in spatial statistics
Tucker tensor analysis of Matern functions in spatial statistics
 
Litvinenko low-rank kriging +FFT poster
Litvinenko low-rank kriging +FFT  posterLitvinenko low-rank kriging +FFT  poster
Litvinenko low-rank kriging +FFT poster
 
Designing Parametric cubic Curves
Designing Parametric cubic CurvesDesigning Parametric cubic Curves
Designing Parametric cubic Curves
 
Hull White model presentation
Hull White model presentationHull White model presentation
Hull White model presentation
 
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
Computing f-Divergences and Distances of\\ High-Dimensional Probability Densi...
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...Low rank tensor approximation of probability density and characteristic funct...
Low rank tensor approximation of probability density and characteristic funct...
 
kactl.pdf
kactl.pdfkactl.pdf
kactl.pdf
 
assignment_2
assignment_2assignment_2
assignment_2
 
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
New data structures and algorithms for \\post-processing large data sets and ...
New data structures and algorithms for \\post-processing large data sets and ...New data structures and algorithms for \\post-processing large data sets and ...
New data structures and algorithms for \\post-processing large data sets and ...
 
residue
residueresidue
residue
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 
Tp problèmes-à-valeurs-initiales
Tp problèmes-à-valeurs-initialesTp problèmes-à-valeurs-initiales
Tp problèmes-à-valeurs-initiales
 
Digital Signal Processing
Digital Signal ProcessingDigital Signal Processing
Digital Signal Processing
 
Csm chapters12
Csm chapters12Csm chapters12
Csm chapters12
 
K-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codeK-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source code
 

More from JinTaek Seo

Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseoJinTaek Seo
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeksJinTaek Seo
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseoJinTaek Seo
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seoJinTaek Seo
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksBeginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksBeginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksBeginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...JinTaek Seo
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksJinTaek Seo
 
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksBeginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksBeginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksBeginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksJinTaek Seo
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksJinTaek Seo
 

More from JinTaek Seo (20)

Neural network 20161210_jintaekseo
Neural network 20161210_jintaekseoNeural network 20161210_jintaekseo
Neural network 20161210_jintaekseo
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeks
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks
 
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
 
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeksBeginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeksBeginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks
 
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeksBeginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
 
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
 
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeksBeginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
 
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksBeginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
 
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeksBeginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
 

Recently uploaded

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Configuration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentConfiguration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentBharaniDharan195623
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectErbil Polytechnic University
 

Recently uploaded (20)

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Configuration of IoT devices - Systems managament
Configuration of IoT devices - Systems managamentConfiguration of IoT devices - Systems managament
Configuration of IoT devices - Systems managament
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction Project
 

Hermite spline english_20161201_jintaeks

  • 1. Mobile Game Programming: Hermite Spline jintaeks@dongseo.ac.kr Division of Digital Contents, DongSeo University. October 2016
  • 2. Type of functions Explicit function y= 2 𝑅2 − 𝑥2 or y=- 2 𝑅2 − 𝑥2 Implicit function x2+y2=R2 Parametric representation x=Rcosθ, y=Rsinθ (0≤ θ < 2π) 2
  • 3. Order of continuity  The various order of parametric continuity can be described as follows:[5]  C−1: curves include discontinuities  C0: curves are joined  C1: first derivatives are continuous  C2: first and second derivatives are continuous  Cn: first through nth derivatives are continuous 3
  • 4. Spline  In mathematics, a spline is a numeric function that is piecewise-defined by polynomial functions. – A flexible device which can be bent to the desired shape is known as a flat spline.  In interpolation problems, spline interpolation is often preferred to polynomial interpolation because it yields similar results to interpolating with higher degree polynomials while avoiding instability.  The most commonly used splines are cubic splines. 4
  • 7. Definition of spline  A spline is a piecewise-polynomial real function S:[a,b]  R  on an interval [a,b] composed of k subintervals [ti-1,ti] with a=t0<t1< … <tk-1<tk=b.  The restriction of S to an interval i is a polynomial Pi:[ti-1,ti]R,  so that S(t)=P1(t), t0<= t <= t1, S(t)=P2(t), t1<= t <= t2, … S(t)=Pk(t), tk-1<= t <= tk,  The highest order of the polynomials Pi(t) is said to be the order of the spline S. 7
  • 8. Cubic spline  In numerical analysis, a cubic spline is a spline where each piece is a third-degree polynomial.  A cubic Hermite spline Specified by its values and first derivatives at the end points of the corresponding domain interval. 8
  • 9. Unit interval (0,1)  On the interval (0,1), given a starting point p0 at t = 0 and an ending point p1 at t = 1 with starting tangent m0 at t = 0 and ending tangent m1 at t = 1, the polynomial can be defined by  where t ∈ [0,1]. 9
  • 10.  a point Q(t) on a curve at parameter t can be defined a cubic equations for each value: Q(t)= 𝑥(𝑡) 𝑦(𝑡) = 𝑎 𝑥 𝑡3 + 𝑏𝑥𝑡2 + 𝑐𝑥𝑡 + 𝑑𝑦 𝑎 𝑦 𝑡3 + 𝑏𝑦𝑡2 + 𝑐𝑦𝑡 + 𝑑𝑦  We can define coefficient matrix C and parameter matrix T, then Q(t) can be defined like this: T= 𝑡3 𝑡2 𝑡 1 C= 𝑎 𝑥 𝑏 𝑥 𝑐 𝑥 𝑑 𝑥 𝑎 𝑦 𝑏 𝑦 𝑐 𝑦 𝑑 𝑦 Q(t)= 𝑥(𝑡) 𝑦(𝑡) =𝐶‧𝑇 10
  • 11.  We will decompose C with 2×4 Geometry Matrix G and 4×4 Basis Matrix M. C=G‧M Q(t)= 𝑥(𝑡) 𝑦(𝑡) =𝑪‧𝑇 = 𝐺‧M‧T = 𝑔1𝑥 𝑔2𝑥 𝑔3𝑥 𝑔4𝑥 𝑔1𝑦 𝑔2𝑦 𝑔3𝑦 𝑔4𝑦 𝑚11 𝑚12 𝑚13 𝑚14 𝑚21 𝑚22 𝑚23 𝑚24 𝑚31 𝑚32 𝑚33 𝑚34 𝑚41 𝑚42 𝑚43 𝑚44 𝑡3 𝑡2 𝑡 1 11
  • 12. Geometry matrix G  has an information about control data.  in case of Hermite spline, it has two points and tangent vectors for each point. – P1, P2, R1, R2 Base matrix M  a coefficient matrix for the blending functions.  blending function means M‧T.  the summation of all blending functions is 1. – it means that spline curve calculates the weighted average for control points. 12
  • 13. Hermite Spline  Specified by its values and first derivatives at the end points of the corresponding domain interval Geometry matrix G G= 𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥 𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦 13
  • 14. Find Base matrix M  Four conditions to find Base matrix M.  Begin point is (P1x, P1y), and End point is (P4x, P4y). Q(0)= 𝑃1𝑥 𝑃1𝑦 Q(1)= 𝑃4𝑥 𝑃4𝑦  Derivative at Begin point is (R1x, R1y), and derivative at End point is (R4x, R4y). Q'(0)= 𝑅1𝑥 𝑅1𝑦 Q'(1)= 𝑅4𝑥 𝑅4𝑦 14
  • 15. for two end points  Q(0)= 𝑃1𝑥 𝑃1𝑦 = 𝐺‧M‧T = 𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥 𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦 𝑚11 𝑚12 𝑚13 𝑚14 𝑚21 𝑚22 𝑚23 𝑚24 𝑚31 𝑚32 𝑚33 𝑚34 𝑚41 𝑚42 𝑚43 𝑚44 𝑡3 𝑡2 𝑡 1 =𝐺‧M 0 0 0 1  Q(1)= 𝑃4𝑥 𝑃4𝑦 = 𝐺‧M 1 1 1 1 15
  • 16. for two tangent vector  Q'(0)= 𝑅1𝑥 𝑅1𝑦 = 𝐺‧M‧T′ = 𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥 𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦 𝑚11 𝑚12 𝑚13 𝑚14 𝑚21 𝑚22 𝑚23 𝑚24 𝑚31 𝑚32 𝑚33 𝑚34 𝑚41 𝑚42 𝑚43 𝑚44 3𝑡2 2𝑡 1 0 =𝐺‧M 0 0 1 0  Q'(1)= 𝑅4𝑥 𝑅4𝑦 = 𝐺‧M 3 2 1 0 16
  • 17. Base matrix M  𝑃1𝑥 𝑃4𝑥 𝑅1𝑥 𝑅4𝑥 𝑃1𝑦 𝑃4𝑦 𝑅1𝑦 𝑅4𝑦 = 𝐺 = 𝐺‧𝑀 0 1 0 3 0 1 0 2 0 1 1 1 1 1 0 0 = 𝐺‧𝑀‧𝑀-1 0 1 0 3 0 1 0 2 0 1 1 1 1 1 0 0 =M-1  M= 2 −3 0 1 −2 3 0 0 1 −2 1 0 1 −1 0 0 17
  • 18. Blending function  Q(t)= 𝑥(𝑡) 𝑦(𝑡) = 𝐺‧M‧T = 𝐺‧𝐵 =(2t3−3t2+1) 𝑃1𝑥 𝑃1𝑦 +(-2t3+3t2) 𝑃4𝑥 𝑃4𝑦 +(t3-2t2+1) 𝑅1𝑥 𝑅1𝑦 +(t3-t2) 𝑅4𝑥 𝑅4𝑦 . 18 2 −3 0 1 −2 3 0 0 1 −2 1 0 1 −1 0 0 𝑡3 𝑡2 𝑡1 0
  • 19. Meaning of tangent vector R 19 P1 P4 R4 R1
  • 20. Implement Hermite Spline class KHermiteCurve { public: float m_a; float m_b; float m_c; float m_d; 20
  • 21. class KHermiteCurve { public: /// constructor. /// @param p1: begin point /// @param p2: end point /// @param v1: tangent vector at begin point /// @param v2: tangent vector at end point KHermiteCurve(float p1, float p2, float v1, float v2) { m_d = p1; m_c = v1; m_b = -3.0f*p1 + 3.0f*p2 - 2.0f*v1 - v2; m_a = 2.0f*p1 - 2.0f*p2 + v1 + v2; }//KHermiteCurve() 21
  • 22. /// set coefficient of Hermite curve inline void Construct(float p1, float p2, float v1, float v2) { m_d = p1; m_c = v1; m_b = -3.0f*p1 + 3.0f*p2 - 2.0f*v1 - v2; m_a = 2.0f*p1 - 2.0f*p2 + v1 + v2; }//Construct() /// calculate first derivative on parameter u. /// can be used to get tangent vector at u. /// derivative of equation t^3 + t^2 + t + 1 inline float CalculateDxDu(float u) const { return 3.0f*m_a*u*u + 2.0f*m_b*u + m_c; }//CalculateDxDu() 22
  • 23. /// get value at parameter u. inline float CalculateX(float u) const { float uu, uuu; uu = u * u; uuu = uu * u; return m_a*uuu + m_b*uu + m_c*u + m_d; }//CalculateX() 23
  • 24. KHermiteSpline2 class KHermiteSpline2 { private: KHermiteCurve m_aHermiteCurve[2]; public: /// constructor. KHermiteSpline2(){} KHermiteSpline2( const KVector& p0, const KVector& p1, const KVector& dp0, const KVector& dp1 ) { m_aHermiteCurve[ 0 ].Construct( p0.m_x, p1.m_x, dp0.m_x, dp1.m_x ); m_aHermiteCurve[ 1 ].Construct( p0.m_y, p1.m_y, dp0.m_y, dp1.m_y ); }//KHermiteSpline2() 24
  • 25. inline void Construct( const KVector& p0, const KVector& p1, const KVector& dp0, const KVector& dp1 ) { m_aHermiteCurve[ 0 ].Construct( p0.m_x, p1.m_x, dp0.m_x, dp1.m_x ); m_aHermiteCurve[ 1 ].Construct( p0.m_y, p1.m_y, dp0.m_y, dp1.m_y ); }//Construct() 25
  • 26. inline const KVector GetPosition( float u_ ) const { return KVector( m_aHermiteCurve[ 0 ].CalculateX( u_ ), m_aHermiteCurve[ 1 ].CalculateX( u_ ), 0.f ); }//GetPosition() inline const KVector GetTangent( float u_ ) const { return KVector( m_aHermiteCurve[ 0 ].CalculateDxDu( u_ ), m_aHermiteCurve[ 1 ].CalculateDxDu( u_ ), 0.f ); }//GetTangent() 26
  • 27. Draw a tangent line at u const float u = 0.5f; KVector position = spline.GetPosition(u); KVector tangent = spline.GetTangent(u); DrawLine(hdc, position, position + tangent * 100.f); 27
  • 29. Line in 3D space  Given two 3D points P1 and P2, we can define the line that passes through these points parametrically as P(t ) = (1− t )P1 + tP2  A ray is a line having a single endpoint S and extending to infinity in a given direction V. Rays are typically expressed by the parametric equation P(t ) = S + tV  Note that this equation is equivalent to previous equation if we let S = P1 and V = P2 − P1. 29
  • 30. Distance between a point and a line 30