C# Класс burningmime.curves.CurveFitBase

This is the base class containing implementations common to CurveFit and CurveBuilder. Most of this is ported from http://tog.acm.org/resources/GraphicsGems/gems/FitCurves.c
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
_arclen List
_pts List
_squaredError System.Double
_u List

Защищенные методы

Метод Описание
ArcLengthParamaterize ( int first, int last ) : void

Initializes the first (last - first) elements of u with scaled arc lengths.

FindMaxSquaredError ( int first, int last, CubicBezier curve, int &split ) : System.Double

Computes the maximum squared distance from a point to the curve using the current parameterization.

FitCurve ( int first, int last, System.Windows.Vector tanL, System.Windows.Vector tanR, CubicBezier &curve, int &split ) : bool

Tries to fit single Bezier curve to the points in [first ... last]. Destroys anything in _u in the process. Assumes there are at least two points to fit.

GenerateBezier ( int first, int last, System.Windows.Vector tanL, System.Windows.Vector tanR ) : CubicBezier

Generates a bezier curve for the segment using a least-squares approximation. for the derivation of this and why it works, see http://read.pudn.com/downloads141/ebook/610086/Graphics_Gems_I.pdf page 626 and beyond. tl;dr: math.

GetCenterTangent ( int first, int last, int split ) : System.Windows.Vector

Gets the tangent at a given point in the curve.

GetLeftTangent ( int last ) : System.Windows.Vector

Gets the tangent for the start of the cure.

GetRightTangent ( int first ) : System.Windows.Vector

Gets the tangent for the the end of the curve.

InitializeArcLengths ( ) : void

Builds the arc length array using the points array. Assumes _pts has points and _arclen is empty.

Reparameterize ( int first, int last, CubicBezier curve ) : void

Attempts to find a slightly better parameterization for u on the given curve.

Описание методов

ArcLengthParamaterize() защищенный Метод

Initializes the first (last - first) elements of u with scaled arc lengths.
protected ArcLengthParamaterize ( int first, int last ) : void
first int
last int
Результат void

FindMaxSquaredError() защищенный Метод

Computes the maximum squared distance from a point to the curve using the current parameterization.
protected FindMaxSquaredError ( int first, int last, CubicBezier curve, int &split ) : System.Double
first int
last int
curve CubicBezier
split int
Результат System.Double

FitCurve() защищенный Метод

Tries to fit single Bezier curve to the points in [first ... last]. Destroys anything in _u in the process. Assumes there are at least two points to fit.
protected FitCurve ( int first, int last, System.Windows.Vector tanL, System.Windows.Vector tanR, CubicBezier &curve, int &split ) : bool
first int Index of first point to consider.
last int Index of last point to consider (inclusive).
tanL System.Windows.Vector Tangent at teh start of the curve ("left").
tanR System.Windows.Vector Tangent on the end of the curve ("right").
curve CubicBezier The fitted curve.
split int Point at which to split if this method returns false.
Результат bool

GenerateBezier() защищенный Метод

Generates a bezier curve for the segment using a least-squares approximation. for the derivation of this and why it works, see http://read.pudn.com/downloads141/ebook/610086/Graphics_Gems_I.pdf page 626 and beyond. tl;dr: math.
protected GenerateBezier ( int first, int last, System.Windows.Vector tanL, System.Windows.Vector tanR ) : CubicBezier
first int
last int
tanL System.Windows.Vector
tanR System.Windows.Vector
Результат CubicBezier

GetCenterTangent() защищенный Метод

Gets the tangent at a given point in the curve.
protected GetCenterTangent ( int first, int last, int split ) : System.Windows.Vector
first int
last int
split int
Результат System.Windows.Vector

GetLeftTangent() защищенный Метод

Gets the tangent for the start of the cure.
protected GetLeftTangent ( int last ) : System.Windows.Vector
last int
Результат System.Windows.Vector

GetRightTangent() защищенный Метод

Gets the tangent for the the end of the curve.
protected GetRightTangent ( int first ) : System.Windows.Vector
first int
Результат System.Windows.Vector

InitializeArcLengths() защищенный Метод

Builds the arc length array using the points array. Assumes _pts has points and _arclen is empty.
protected InitializeArcLengths ( ) : void
Результат void

Reparameterize() защищенный Метод

Attempts to find a slightly better parameterization for u on the given curve.
protected Reparameterize ( int first, int last, CubicBezier curve ) : void
first int
last int
curve CubicBezier
Результат void

Описание свойств

_arclen защищенное свойство

length of curve before each point (so, arclen[0] = 0, arclen[1] = distance(pts[0], pts[1]), arclen[2] = arclen[1] + distance(pts[1], pts[2]) ... arclen[n -1] = length of the entire curve, etc).
protected List _arclen
Результат List

_pts защищенное свойство

Points in the whole line being used for fitting.
protected List _pts
Результат List

_squaredError защищенное свойство

maximum squared error before we split the curve
protected Double,System _squaredError
Результат System.Double

_u защищенное свойство

current parametrization of the curve. When fitting, u[i] is the parametrization for the point in pts[first + i]. This is an optimization for CurveBuilder, since it might not need to allocate as big of a _u as is necessary to hold the whole curve.
protected List _u
Результат List